From 09901e0f11c33c5e4b5ceef71036d61686e5fc68 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 5 Aug 2023 14:03:24 +0200 Subject: [PATCH] Add AVFMT_FLAG_AUTO_BSF when muxing, just in case. --- shared/mux.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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"); -- 2.39.2