[MPlayer-dev-eng] [PATCH] DVB TS subtitle not working if corresponding PID doesn't occur at beginning for -demux lavf

K.S. Ng ksnghk at yahoo.com.hk
Wed Sep 29 15:30:16 CEST 2010


Hello,

Subtitles in DVB broadcast very often occur dynamically, i.e. subtitle 
streams and their respective PID information in the PMT occur only when 
present. It is found that demux-lavf (mplayer invoked with -demux lavf) 
is not aware of such subtitle streams if their PIDs are not present when 
opening the transport stream.

Below is a small patch to fix this issue. I've tested it with DVB 
broadcast in Hong Kong.

Please kindly review!

Thanks,
K.S. Ng

Index: libmpdemux/demux_lavf.c
===================================================================
--- libmpdemux/demux_lavf.c     (revision 32358)
+++ libmpdemux/demux_lavf.c     (working copy)
@@ -77,6 +77,7 @@
     int vstreams[MAX_V_STREAMS];
     int sstreams[MAX_S_STREAMS];
     int cur_program;
+    int nb_streams_last;
 }lavf_priv_t;
 
 static int mp_read(void *opaque, uint8_t *buf, int size) {
@@ -573,6 +574,8 @@
         demuxer->video->id=-2; // audio-only
     } //else if (best_video > 0 && demuxer->video->id == -1) 
demuxer->video->id = best_video;
 
+    priv->nb_streams_last = priv->avfc->nb_streams;
+
     return demuxer;
 }
 
@@ -581,7 +584,7 @@
     AVPacket pkt;
     demux_packet_t *dp;
     demux_stream_t *ds;
-    int id;
+    int id, i;
     mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_lavf_fill_buffer()\n");
 
     demux->filepos=stream_tell(demux->stream);
@@ -589,6 +592,14 @@
     if(av_read_frame(priv->avfc, &pkt) < 0)
         return 0;
 
+    if( priv->nb_streams_last != priv->avfc->nb_streams ) {
+        mp_msg(MSGT_DEMUX, MSGL_DBG2, "Nb streams changed %d %d\n", 
priv->nb_streams_last, priv->avfc->nb_streams);
+        for(i=priv->nb_streams_last; i<priv->avfc->nb_streams; i++) {
+            handle_stream(demux, priv->avfc, i);
+        }
+    }
+    priv->nb_streams_last = priv->avfc->nb_streams;
+
     id= pkt.stream_index;
 
     if(id==demux->audio->id){



More information about the MPlayer-dev-eng mailing list