]> git.sesse.net Git - nageru/commitdiff
When exporting interpolated files, don't include the subtitles meant for Nageru inter...
authorSteinar H. Gunderson <steinar+nageru@gunderson.no>
Mon, 21 Oct 2019 19:43:07 +0000 (21:43 +0200)
committerBigscreen user <bigscreen@bigscreen.party.solskogen.no>
Mon, 21 Oct 2019 20:35:48 +0000 (22:35 +0200)
futatabi/video_stream.cpp
futatabi/video_stream.h

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();
index f156be9af662578ee96cabec201f3337a08b09bc..12e8ed123a532db2ae3726790356dd43ecd816b2 100644 (file)
@@ -12,6 +12,7 @@ extern "C" {
 #include "frame_on_disk.h"
 #include "jpeg_frame_view.h"
 #include "queue_spot_holder.h"
+#include "shared/mux.h"
 #include "shared/ref_counted_gl_sync.h"
 
 #include <atomic>
@@ -29,7 +30,6 @@ extern "C" {
 class ChromaSubsampler;
 class DISComputeFlow;
 class Interpolate;
-class Mux;
 class QSurface;
 class QSurfaceFormat;
 class YCbCrConverter;
@@ -174,6 +174,7 @@ private:
        FrameOnDisk last_frame1, last_frame2;
 
        std::string last_frame;
+       Mux::WithSubtitles with_subtitles;  // true for streaming, false for export to file.
 };
 
 #endif  // !defined(_VIDEO_STREAM_H)