[FFmpeg-devel] [PATCH] Bluray Subtitle Support, v7 (Updated patch to v12)

Reimar Döffinger Reimar.Doeffinger
Wed Aug 26 13:34:45 CEST 2009


On Wed, Aug 26, 2009 at 10:47:14AM +0000, Carl Eugen Hoyos wrote:
> Reimar D?ffinger <Reimar.Doeffinger <at> gmx.de> writes:
> 
> > 
> > On Wed, Aug 26, 2009 at 11:00:52AM +0200, Reimar D?ffinger wrote:
> > > When muxing into AVI for xsub I first get a crash, and after fixing that
> > > I get "scale/rate is 0/1 which is invalid. (This file has been generated by
> > > broken software.)" when trying to play the result.
> > 
> > Ok, I have a couple of issue with the AVI demuxer and other stuff.
> > The first one is that the time base of subtitle streams stays at
> > the default of 90 kHz, which is a bit questionable but probably
> > acceptable.
> > The second and bigger one is that the avi muxer uses the (completely
> > undocumented btw.) ff_parse_specific_params which seems to guess a time
> > base.
> > The issue with this is that for this it uses the codec values and only
> > those, which are never set for subtitles, overwriting the perfectly
> > good values from the stream time base. WTF?
> > Later this causes a crash due to a division by 0 when rescaling the
> > subtitle time base to the now broken stream time base.
> > This "fixes" it, but I have no idea if it makes anything actually work:
> 
> With the patch, subtitles are actually encoded (file size 10 times bigger), but
> nothing is shown on playback: Perhaps because of these messages while encoding:
> [xsub @ 0x141e450]No more than 4 subtitle colors supported (256 found.)
>     Last message repeated 6 times

No, you need this patch, but Michael will have to comment on what is the
right approach (it disables empty packets for timestamp encoding for
subtitles, which causes the massive size increase):
Index: libavformat/avienc.c
===================================================================
--- libavformat/avienc.c        (revision 19710)
+++ libavformat/avienc.c        (working copy)
@@ -232,10 +232,11 @@
         put_le32(pb, 0); /* initial frame */
 
         ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
+        if (au_scale && au_byterate)
+            av_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
 
-        put_le32(pb, au_scale); /* scale */
-        put_le32(pb, au_byterate); /* rate */
-        av_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
+        put_le32(pb, s->streams[i]->time_base.num); /* scale */
+        put_le32(pb, s->streams[i]->time_base.den); /* rate */
 
         put_le32(pb, 0); /* start */
         avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this
offset to fill later */
@@ -491,7 +492,8 @@
     int size= pkt->size;
 
 //    av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %d\n", pkt->dts,
 //    avi->packet_count[stream_index], stream_index);
-    while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avi->packet_count[stream_index]){
+    while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avi->packet_count[stream_index] &&
+          s->streams[stream_index]->codec->codec_type != CODEC_TYPE_SUBTITLE){
         AVPacket empty_packet;
 
         av_init_packet(&empty_packet);



More information about the ffmpeg-devel mailing list