summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-05-09 08:03:18 -0700
committerJohn Stebbins <[email protected]>2016-05-17 10:11:30 -0600
commit2facb50c81364f1f0faa62a7da879447e848ee93 (patch)
tree80cd7d09f34097cf779cdb1a78f6a2df2f4c47fc
parente3815957e8a6be2a06a526cac803340f9b6ad1b6 (diff)
muxavformat: fix last subtitle persistence in mp4
libav doesn't seems to honor the duration of the subtitle AVPacket. It is required to send an "empty" subtitle packet to terminate all subtitles, including the last one.
-rw-r--r--libhb/muxavformat.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libhb/muxavformat.c b/libhb/muxavformat.c
index 7aa9b654a..ef72130b6 100644
--- a/libhb/muxavformat.c
+++ b/libhb/muxavformat.c
@@ -1051,7 +1051,29 @@ static int avformatMux(hb_mux_object_t *m, hb_mux_data_t *track, hb_buffer_t *bu
buf = tmp;
}
if (buf == NULL)
+ {
+ if (job->mux == HB_MUX_AV_MP4 && track->type == MUX_TYPE_SUBTITLE)
+ {
+ // Write a final "empty" subtitle to terminate the last
+ // subtitle that was written
+ if (track->duration > 0)
+ {
+ AVPacket empty_pkt;
+ uint8_t empty[2] = {0,0};
+
+ av_init_packet(&empty_pkt);
+ empty_pkt.data = empty;
+ empty_pkt.size = 2;
+ empty_pkt.dts = track->duration;
+ empty_pkt.pts = track->duration;
+ empty_pkt.duration = 90;
+ empty_pkt.convergence_duration = empty_pkt.duration;
+ empty_pkt.stream_index = track->st->index;
+ av_interleaved_write_frame(m->oc, &empty_pkt);
+ }
+ }
return 0;
+ }
if (track->type == MUX_TYPE_VIDEO && (job->mux & HB_MUX_MASK_MKV) &&
buf->s.renderOffset < 0)