From: Steinar H. Gunderson Date: Sat, 5 Aug 2023 12:03:24 +0000 (+0200) Subject: Add AVFMT_FLAG_AUTO_BSF when muxing, just in case. X-Git-Tag: 2.3.0~30 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=09901e0f11c33c5e4b5ceef71036d61686e5fc68 Add AVFMT_FLAG_AUTO_BSF when muxing, just in case. --- diff --git a/shared/mux.cpp b/shared/mux.cpp index 9216055..819638c 100644 --- a/shared/mux.cpp +++ b/shared/mux.cpp @@ -50,6 +50,13 @@ struct PacketBefore { Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const string &video_extradata, const AVCodecParameters *audio_codecpar, AVColorSpace color_space, int time_base, function write_callback, WriteStrategy write_strategy, const vector &metrics, WithSubtitles with_subtitles) : write_strategy(write_strategy), avctx(avctx), write_callback(write_callback), metrics(metrics) { + // MPEG-TS ostensibly needs some conversions (e.g. for differing start codes), + // so let FFmpeg insert them as needed in case we are muxing to that. + // Curiously enough, things actually seem to go quite fine without + // (and it also seems FFmpeg's MPEG-TS muxer automatically does stuff like + // repeat PPS/SPS before keyframes for us), but it can't hurt. + avctx->flags |= AVFMT_FLAG_AUTO_BSF; + AVStream *avstream_video = avformat_new_stream(avctx, nullptr); if (avstream_video == nullptr) { fprintf(stderr, "avformat_new_stream() failed\n");