]> git.sesse.net Git - nageru/commitdiff
Add AVFMT_FLAG_AUTO_BSF when muxing, just in case.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 5 Aug 2023 12:03:24 +0000 (14:03 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 5 Aug 2023 12:03:24 +0000 (14:03 +0200)
shared/mux.cpp

index 921605574d0a496841bc42215c4573b24faf3170..819638c480c04f22a98a6364ecf1b1cb59ef569c 100644 (file)
@@ -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<void(int64_t)> write_callback, WriteStrategy write_strategy, const vector<MuxMetrics *> &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");