diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 7383b3f2b..37924accb 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -425,6 +425,26 @@ int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt) { return 0; } +void fix_deprecated_pix_fmt(AVCodecContext *ctx) { + // Fix deprecated formats + switch ( ctx->pix_fmt ) { + case AV_PIX_FMT_YUVJ422P : + ctx->pix_fmt = AV_PIX_FMT_YUV422P; + break; + case AV_PIX_FMT_YUVJ444P : + ctx->pix_fmt = AV_PIX_FMT_YUV444P; + break; + case AV_PIX_FMT_YUVJ440P : + ctx->pix_fmt = AV_PIX_FMT_YUV440P; + break; + case AV_PIX_FMT_NONE : + case AV_PIX_FMT_YUVJ420P : + default: + ctx->pix_fmt = AV_PIX_FMT_YUV420P; + break; + } +} + #if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100) #else unsigned int zm_av_packet_ref( AVPacket *dst, AVPacket *src ) { diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index 5c95bcad2..d694531b3 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -379,6 +379,7 @@ void zm_dump_codecpar(const AVCodecParameters *par); #endif int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt); +void fix_deprecated_pix_fmt(AVCodecContext *); bool is_video_stream(const AVStream *); bool is_audio_stream(const AVStream *); @@ -423,4 +424,5 @@ int zm_add_samples_to_fifo(AVAudioFifo *fifo, AVFrame *frame); int zm_get_samples_from_fifo(AVAudioFifo *fifo, AVFrame *frame); + #endif // ZM_FFMPEG_H