[FFmpeg-devel] [PATCH] add support for text subtitles in MOV

Reimar Döffinger Reimar.Doeffinger
Sat Jan 26 21:48:04 CET 2008


Hello,
attached patch adds support for that.
It discards the advanced styles version (specifying font etc) and only
exports the text.
You might want to do some "cosmetics", like using an extra variable or
also checking codec_type or just adding a flag into MOVContext to
indicate if text subtitle processing should be done...
Samples:
http://samples.mplayerhq.hu/mov/subtitles-embedded/subtitlemovie.mov
http://samples.mplayerhq.hu/mov/subtitles-embedded/water_phase_diagram_cap.mov

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavformat/mov.c
===================================================================
--- libavformat/mov.c	(revision 11620)
+++ libavformat/mov.c	(working copy)
@@ -233,6 +233,9 @@
     else if(type == MKTAG('s', 'u', 'b', 'p')) {
         st->codec->codec_type = CODEC_TYPE_SUBTITLE;
         st->codec->codec_id = CODEC_ID_DVD_SUBTITLE;
+    } else if(type == MKTAG('t', 'e', 'x', 't')) {
+        st->codec->codec_type = CODEC_TYPE_SUBTITLE;
+        st->codec->codec_id = CODEC_ID_TEXT;
     }
     get_be32(pb); /* component  manufacture */
     get_be32(pb); /* component flags */
@@ -1532,6 +1535,12 @@
     } else {
 #endif
         av_get_packet(s->pb, pkt, sample->size);
+        if (s->streams[sc->ffindex]->codec->codec_id == CODEC_ID_TEXT) {
+            int textlen = FFMIN(AV_RB16(pkt->data), sample->size - 2);
+            textlen = FFMAX(textlen, 0);
+            memmove(pkt->data, pkt->data + 2, textlen);
+            pkt->size = textlen;
+        }
 #ifdef CONFIG_DV_DEMUXER
         if (mov->dv_demux) {
             void *pkt_destruct_func = pkt->destruct;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080126/a0b977c8/attachment.pgp>



More information about the ffmpeg-devel mailing list