mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 03:10:04 +08:00
更新 FFmpeg API 支持 FFmpeg 5 (#1434)
This commit is contained in:
parent
cb00dbab0f
commit
d8b9c5b102
@ -33,10 +33,10 @@ std::shared_ptr<AVPacket> alloc_av_packet(){
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<bool decoder = true, typename ...ARGS>
|
template<bool decoder = true, typename ...ARGS>
|
||||||
AVCodec *getCodec(ARGS ...names);
|
const AVCodec *getCodec(ARGS ...names);
|
||||||
|
|
||||||
template<bool decoder = true>
|
template<bool decoder = true>
|
||||||
AVCodec *getCodec(const char *name) {
|
const AVCodec *getCodec(const char *name) {
|
||||||
auto codec = decoder ? avcodec_find_decoder_by_name(name) : avcodec_find_encoder_by_name(name);
|
auto codec = decoder ? avcodec_find_decoder_by_name(name) : avcodec_find_encoder_by_name(name);
|
||||||
if (codec) {
|
if (codec) {
|
||||||
InfoL << (decoder ? "got decoder:" : "got encoder:") << name;
|
InfoL << (decoder ? "got decoder:" : "got encoder:") << name;
|
||||||
@ -45,7 +45,7 @@ AVCodec *getCodec(const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<bool decoder = true>
|
template<bool decoder = true>
|
||||||
AVCodec *getCodec(enum AVCodecID id) {
|
const AVCodec *getCodec(enum AVCodecID id) {
|
||||||
auto codec = decoder ? avcodec_find_decoder(id) : avcodec_find_encoder(id);
|
auto codec = decoder ? avcodec_find_decoder(id) : avcodec_find_encoder(id);
|
||||||
if (codec) {
|
if (codec) {
|
||||||
InfoL << (decoder ? "got decoder:" : "got encoder:") << avcodec_get_name(id);
|
InfoL << (decoder ? "got decoder:" : "got encoder:") << avcodec_get_name(id);
|
||||||
@ -54,7 +54,7 @@ AVCodec *getCodec(enum AVCodecID id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<bool decoder = true, typename First, typename ...ARGS>
|
template<bool decoder = true, typename First, typename ...ARGS>
|
||||||
AVCodec *getCodec(First first, ARGS ...names) {
|
const AVCodec *getCodec(First first, ARGS ...names) {
|
||||||
auto codec = getCodec<decoder>(names...);
|
auto codec = getCodec<decoder>(names...);
|
||||||
if (codec) {
|
if (codec) {
|
||||||
return codec;
|
return codec;
|
||||||
@ -139,9 +139,11 @@ FFmpegFrame::Ptr FFmpegSwr::inputFrame(const FFmpegFrame::Ptr &frame) {
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FFmpegDecoder::FFmpegDecoder(const Track::Ptr &track) {
|
FFmpegDecoder::FFmpegDecoder(const Track::Ptr &track) {
|
||||||
|
#if (LIBAVCODEC_VERSION_MAJOR < 58)
|
||||||
avcodec_register_all();
|
avcodec_register_all();
|
||||||
AVCodec *codec = nullptr;
|
#endif
|
||||||
AVCodec *codec_default = nullptr;
|
const AVCodec *codec = nullptr;
|
||||||
|
const AVCodec *codec_default = nullptr;
|
||||||
switch (track->getCodecId()) {
|
switch (track->getCodecId()) {
|
||||||
case CodecH264:
|
case CodecH264:
|
||||||
codec_default = getCodec(AV_CODEC_ID_H264);
|
codec_default = getCodec(AV_CODEC_ID_H264);
|
||||||
@ -181,7 +183,9 @@ FFmpegDecoder::FFmpegDecoder(const Track::Ptr &track) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//保存AVFrame的引用
|
//保存AVFrame的引用
|
||||||
|
#ifdef FF_API_OLD_ENCDEC
|
||||||
_context->refcounted_frames = 1;
|
_context->refcounted_frames = 1;
|
||||||
|
#endif
|
||||||
_context->flags |= AV_CODEC_FLAG_LOW_DELAY;
|
_context->flags |= AV_CODEC_FLAG_LOW_DELAY;
|
||||||
_context->flags2 |= AV_CODEC_FLAG2_FAST;
|
_context->flags2 |= AV_CODEC_FLAG2_FAST;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user