From 058330fb422a66d22c9b4e213afeec3ade903a0d Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 21 Oct 2019 21:43:07 +0200 Subject: [PATCH] When exporting interpolated files, don't include the subtitles meant for Nageru internal consumption. --- futatabi/video_stream.cpp | 10 ++++++++-- futatabi/video_stream.h | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/futatabi/video_stream.cpp b/futatabi/video_stream.cpp index 9647836..3cd56a0 100644 --- a/futatabi/video_stream.cpp +++ b/futatabi/video_stream.cpp @@ -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(); diff --git a/futatabi/video_stream.h b/futatabi/video_stream.h index f156be9..12e8ed1 100644 --- a/futatabi/video_stream.h +++ b/futatabi/video_stream.h @@ -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 @@ -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) -- 2.39.2