+ // 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()) {
+ AVPacket pkt;
+ av_init_packet(&pkt);
+ pkt.stream_index = mux->get_subtitle_stream_idx();
+ assert(pkt.stream_index != -1);
+ pkt.data = (uint8_t *)qf.subtitle.data();
+ pkt.size = qf.subtitle.size();
+ pkt.flags = 0;
+ pkt.duration = lrint(TIMEBASE / global_flags.output_framerate); // Doesn't really matter for Nageru.
+ mux->add_packet(pkt, qf.output_pts - 1, qf.output_pts - 1);
+ }
+