From: Helge Norberg Date: Tue, 28 Mar 2017 09:44:41 +0000 (+0200) Subject: [ffmpeg_consumer] #513 Fixed parsing of -pix_fmt in consumer X-Git-Tag: 2.1.0_Beta2~30 X-Git-Url: https://git.sesse.net/?p=casparcg;a=commitdiff_plain;h=c89e636fa292907609cac6201d410df44853e2ff [ffmpeg_consumer] #513 Fixed parsing of -pix_fmt in consumer --- diff --git a/CHANGELOG b/CHANGELOG index 249e936d0..c90fce6e9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -41,6 +41,8 @@ Consumers BT.601 color matrix instead of the BT.709 color matrix. RGB codecs like qtrle was never affected but all the YCbCr based codecs were. + Fixed bug in parsing of paths containing -. + + Fixed bugs where previously effective arguments like -pix_fmt were + ignored. o DeckLink consumer: + Rewrote the frame hand-off between send() and ScheduledFrameCompleted() in a way that hopefully resolves all dead-lock scenarios previously possible. diff --git a/modules/ffmpeg/consumer/ffmpeg_consumer.cpp b/modules/ffmpeg/consumer/ffmpeg_consumer.cpp index 188fa4188..b0c3460e6 100644 --- a/modules/ffmpeg/consumer/ffmpeg_consumer.cpp +++ b/modules/ffmpeg/consumer/ffmpeg_consumer.cpp @@ -381,8 +381,9 @@ public: { configure_video_filters( *video_codec, - try_remove_arg(options_, - boost::regex("vf|f:v|filter:v")).get_value_or("")); + try_remove_arg(options_, boost::regex("vf|f:v|filter:v")) + .get_value_or(""), + try_remove_arg(options_, boost::regex("pix_fmt"))); configure_audio_filters( *audio_codec, @@ -650,7 +651,8 @@ private: void configure_video_filters( const AVCodec& codec, - std::string filtergraph) + std::string filtergraph, + const boost::optional& preferred_pix_fmt) { video_graph_.reset( avfilter_graph_alloc(), @@ -698,12 +700,33 @@ private: #pragma warning (push) #pragma warning (disable : 4245) - FF(av_opt_set_int_list( + if (preferred_pix_fmt) + { + auto requested_fmt = av_get_pix_fmt(preferred_pix_fmt->c_str()); + auto valid_fmts = from_terminated_array(codec.pix_fmts, AVPixelFormat::AV_PIX_FMT_NONE); + + if (!cpplinq::from(valid_fmts).contains(requested_fmt)) + CASPAR_THROW_EXCEPTION(user_error() << msg_info(*preferred_pix_fmt + " is not supported by codec.")); + + std::vector fmts = { requested_fmt, AVPixelFormat::AV_PIX_FMT_NONE }; + + FF(av_opt_set_int_list( + filt_vsink, + "pix_fmts", + fmts.data(), + -1, + AV_OPT_SEARCH_CHILDREN)); + } + else + { + FF(av_opt_set_int_list( filt_vsink, "pix_fmts", codec.pix_fmts, -1, AV_OPT_SEARCH_CHILDREN)); + } + #pragma warning (pop)