X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fffmpeg%2Fconsumer%2Fstreaming_consumer.cpp;h=95fa9c0eb8f23e23d75ee21f58b538eea2fc60d5;hb=c4edb05bbed7276f5956e8d2995c40d71a9f065f;hp=d390cb4574209bba1e4632275779da9bc2bc7e20;hpb=863e2203fa69a4b5f17ef29a50510467d192fb44;p=casparcg diff --git a/modules/ffmpeg/consumer/streaming_consumer.cpp b/modules/ffmpeg/consumer/streaming_consumer.cpp index d390cb457..95fa9c0eb 100644 --- a/modules/ffmpeg/consumer/streaming_consumer.cpp +++ b/modules/ffmpeg/consumer/streaming_consumer.cpp @@ -67,6 +67,16 @@ extern "C" namespace caspar { namespace ffmpeg { namespace { +bool is_pcm_s24le_not_supported(const AVFormatContext& container) +{ + auto name = std::string(container.oformat->name); + + if (name == "mp4" || name == "dv") + return true; + + return false; +} + class ffmpeg_consumer { public: @@ -252,7 +262,9 @@ public: const auto audio_codec = audio_codec_name ? avcodec_find_encoder_by_name(audio_codec_name->c_str()) - : avcodec_find_encoder(oc_->oformat->audio_codec); + : (is_pcm_s24le_not_supported(*oc_) + ? avcodec_find_encoder(oc_->oformat->audio_codec) + : avcodec_find_encoder_by_name("pcm_s24le")); if (!video_codec) CASPAR_THROW_EXCEPTION(user_error() << msg_info( @@ -436,7 +448,7 @@ private: &codec); if (!st) - CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Could not allocate video-stream.") << boost::errinfo_api_function("av_new_stream")); + CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Could not allocate video-stream.") << boost::errinfo_api_function("avformat_new_stream")); auto enc = st->codec; @@ -772,12 +784,12 @@ private: in_video_format_.width, in_video_format_.height); - src_av_frame->format = AV_PIX_FMT_BGRA; - src_av_frame->width = in_video_format_.width; - src_av_frame->height = in_video_format_.height; - src_av_frame->sample_aspect_ratio.num = sample_aspect_ratio.numerator(); - src_av_frame->sample_aspect_ratio.den = sample_aspect_ratio.denominator(); - src_av_frame->pts = video_pts_; + src_av_frame->format = AV_PIX_FMT_BGRA; + src_av_frame->width = in_video_format_.width; + src_av_frame->height = in_video_format_.height; + src_av_frame->sample_aspect_ratio.num = sample_aspect_ratio.numerator(); + src_av_frame->sample_aspect_ratio.den = sample_aspect_ratio.denominator(); + src_av_frame->pts = video_pts_; video_pts_ += 1;