[FFmpeg-devel] [PATCH] movenc: support non-standard DVD subtitles muxing.
Nicolas George
nicolas.george at normalesup.org
Mon Jul 9 10:30:51 CEST 2012
The format is imitated on what can be found in the file
unsupported-embedded-subs-2.mp4 from the MPlayer sample collection.
The subtitles in a file remuxed from that sample can now be decoded
by ffplay and vlc (2.0.2).
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
libavformat/movenc.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 89072d5..51bf97b 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -325,6 +325,8 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
// plus 1 bit to indicate upstream and 1 bit set to 1 (reserved)
if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
avio_w8(pb, 0x15); // flags (= Audiostream)
+ else if(track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)
+ avio_w8(pb, 0xE1); // flags
else
avio_w8(pb, 0x11); // flags (= Visualstream)
@@ -997,11 +999,17 @@ static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
avio_wb32(pb, 0); /* size */
+ if (track->enc->codec_id == CODEC_ID_DVD_SUBTITLE)
+ ffio_wfourcc(pb, "mp4s");
+ else
avio_wl32(pb, track->tag); // store it byteswapped
avio_wb32(pb, 0); /* Reserved */
avio_wb16(pb, 0); /* Reserved */
avio_wb16(pb, 1); /* Data-reference index */
+ if (track->enc->codec_id == CODEC_ID_DVD_SUBTITLE)
+ mov_write_esds_tag(pb, track);
+ else
if (track->enc->extradata_size)
avio_write(pb, track->enc->extradata, track->enc->extradata_size);
@@ -1388,6 +1396,7 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
descr = "SoundHandler";
} else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (track->tag == MKTAG('t','x','3','g')) hdlr_type = "sbtl";
+ else if (track->tag == 0xE0) hdlr_type = "subp";
else hdlr_type = "text";
descr = "SubtitleHandler";
} else if (track->enc->codec_tag == MKTAG('t','m','c','d')) {
--
1.7.10.4
More information about the ffmpeg-devel
mailing list