[MPlayer-users] switch_audio on *.ts files

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Jun 20 11:48:23 CEST 2009


On Fri, Jun 19, 2009 at 11:31:59PM +0200, RVM wrote:
> El Viernes, 19 de Junio de 2009 14:56, Reimar Döffinger escribió:
> > On Fri, Jun 19, 2009 at 01:37:41PM +0200, rvm wrote:
> > > 2009/6/19 Reimar Döffinger <Reimar.Doeffinger at gmx.de>:
> > > > Probably, there are two kinds on stream IDs in MPlayer and -vid
> > > > originally selected one that made no sense.
> > > > They are still confused in some places and this is probably one.
> > > > See if this patch fixes it for you:
> > > > Index: command.c
> > > > ===================================================================
> > > > --- command.c   (revision 29371)
> > > > +++ command.c   (working copy)
> > > > @@ -2029,7 +2029,7 @@
> > > >     { "channels", mp_property_channels, CONF_TYPE_INT,
> > > >      0, 0, 0, NULL },
> > > >     { "switch_audio", mp_property_audio, CONF_TYPE_INT,
> > > > -     CONF_RANGE, -2, MAX_A_STREAMS - 1, NULL },
> > > > +     CONF_RANGE, -2, 65535, NULL },
> > > >     { "balance", mp_property_balance, CONF_TYPE_FLOAT,
> > > >      M_OPT_RANGE, -1, 1, NULL },
> > > >
> > > > @@ -2075,7 +2075,7 @@
> > > >     { "aspect", mp_property_aspect, CONF_TYPE_FLOAT,
> > > >      0, 0, 0, NULL },
> > > >     { "switch_video", mp_property_video, CONF_TYPE_INT,
> > > > -     CONF_RANGE, -2, MAX_V_STREAMS - 1, NULL },
> > > > +     CONF_RANGE, -2, 65535, NULL },
> > > >     { "switch_program", mp_property_program, CONF_TYPE_INT,
> > > >      CONF_RANGE, -1, 65535, NULL },
> > >
> > > No, I'm afraid it doesn't fix it.
> > > The only difference it that now mplayer doesn't print the error "The
> > > switch_video option must be <= 255", but still it doesn't change to
> > > the specified video track. switch_audio doesn't work either if passing
> > > the ID printed with -identify.
> >
> > Ah, sorry, I looked at the MPEG-PS code, your case is TS.
> > I think this might work, Nico do you think it is correct?
> > (Compilation still in progress so I haven't tested yet).
> > Index: libmpdemux/demux_ts.c
> > ===================================================================
> > --- libmpdemux/demux_ts.c       (revision 29371)
> > +++ libmpdemux/demux_ts.c       (working copy)
> > @@ -3378,14 +3378,9 @@
> >                         }
> >                         else    //audio track <n>
> >                         {
> > -                               for(i = 0; i < 8192; i++)
> > -                               {
> > -                                       if(priv->ts.streams[i].id == n &&
> > priv->ts.streams[i].type == reftype) -                                     
> >  {
> > +                               if (n >= 8192 || priv->ts.streams[n].type
> > != reftype) return DEMUXER_CTRL_NOTIMPL; +                               i
> > = n;
> >                                                 sh =
> > priv->ts.streams[i].sh; -                                              
> > break;
> > -                                       }
> > -                               }
> >                         }
> >
> >                         if(sh)
> 
> Works!
> With these two patches switch_audio and set_property switch_video work with 
> the -identify IDs.
> 
> But there's a problem... it seems with this patch switching programs (either 
> with the TAB key or with set_property switch_program) stops working...

Try attached.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_ts.c
===================================================================
--- libmpdemux/demux_ts.c	(revision 29371)
+++ libmpdemux/demux_ts.c	(working copy)
@@ -3378,14 +3375,9 @@
 			}
 			else	//audio track <n>
 			{
-				for(i = 0; i < 8192; i++)
-				{
-					if(priv->ts.streams[i].id == n && priv->ts.streams[i].type == reftype)
-					{
+				if (n >= 8192 || priv->ts.streams[n].type != reftype) return DEMUXER_CTRL_NOTIMPL;
+				i = n;
 						sh = priv->ts.streams[i].sh;
-						break;
-					}
-				}
 			}
 
 			if(sh)
@@ -3456,12 +3448,12 @@
 				if(!vid_done && priv->ts.streams[pmt->es[j].pid].type == TYPE_VIDEO)
 				{
 					vid_done = 1;
-					prog->vid = priv->ts.streams[pmt->es[j].pid].id;
+					prog->vid = pmt->es[j].pid;
 				}
 				else if(!aid_done && priv->ts.streams[pmt->es[j].pid].type == TYPE_AUDIO)
 				{
 					aid_done = 1;
-					prog->aid = priv->ts.streams[pmt->es[j].pid].id;
+					prog->aid = pmt->es[j].pid;
 				}
 			}
 


More information about the MPlayer-users mailing list