]> git.sesse.net Git - nageru/blobdiff - futatabi/video_stream.cpp
When exporting interpolated files, don't include the subtitles meant for Nageru inter...
[nageru] / futatabi / video_stream.cpp
index 9647836feaa4294a4653bdb8eb7b84b8af77da27..3cd56a022401ac8cec245d8ac29f36ebb35c1894 100644 (file)
@@ -235,6 +235,12 @@ VideoStream::VideoStream(AVFormatContext *file_avctx)
        memset(y.get(), 16, global_flags.width * global_flags.height);
        memset(cb_or_cr.get(), 128, (global_flags.width / 2) * global_flags.height);
        last_frame = encode_jpeg(y.get(), cb_or_cr.get(), cb_or_cr.get(), global_flags.width, global_flags.height);
+
+       if (file_avctx != nullptr) {
+               with_subtitles = Mux::WITHOUT_SUBTITLES;
+       } else {
+               with_subtitles = Mux::WITH_SUBTITLES;
+       }
 }
 
 VideoStream::~VideoStream()
@@ -297,7 +303,7 @@ void VideoStream::start()
 
        size_t width = global_flags.width, height = global_flags.height;  // Doesn't matter for MJPEG.
        mux.reset(new Mux(avctx, width, height, Mux::CODEC_MJPEG, /*video_extradata=*/"", audio_codecpar,
-                         AVCOL_SPC_BT709, COARSE_TIMEBASE, /*write_callback=*/nullptr, Mux::WRITE_FOREGROUND, {}, Mux::WITH_SUBTITLES));
+                         AVCOL_SPC_BT709, COARSE_TIMEBASE, /*write_callback=*/nullptr, Mux::WRITE_FOREGROUND, {}, with_subtitles));
 
        avcodec_parameters_free(&audio_codecpar);
        encode_thread = thread(&VideoStream::encode_thread_func, this);
@@ -668,7 +674,7 @@ void VideoStream::encode_thread_func()
 
                // Hack: We mux the subtitle packet one time unit before the actual frame,
                // so that Nageru is sure to get it first.
-               if (!qf.subtitle.empty()) {
+               if (!qf.subtitle.empty() && with_subtitles == Mux::WITH_SUBTITLES) {
                        AVPacket pkt;
                        av_init_packet(&pkt);
                        pkt.stream_index = mux->get_subtitle_stream_idx();