[FFmpeg-devel] [PATCH] movenc: support non-standard DVD subtitles muxing.
Baptiste Coudurier
baptiste.coudurier at gmail.com
Wed Jul 11 22:07:39 CEST 2012
On 07/10/2012 09:04 PM, Philip Langdale wrote:
> On Mon, 9 Jul 2012 10:30:51 +0200
> Nicolas George <nicolas.george at normalesup.org> wrote:
>
>> 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')) {
>
> Looks reasonable to me, and matches what I've seen in other dvd subtitle
> samples.
>
I believe this can be simplified by using already existing functions.
mp4_get_codec_tag and setting track->tag to "mp4s"
This is only valid in mp4 as well.
--
Baptiste COUDURIER
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list