Discussion:
[vlc-devel] Patch to filter audio PIDs by --audio-language in TS streams
Mark Paulus
2007-09-21 17:37:25 UTC
Permalink
Hi,

Attached are 2 patches that I have created against
the trunk.

The purpose is to allow for the use of the --audio-language
command line option to limit out certain audio streams
from a TS file.

Some background:

I have a mythtv setup that captures DVB TS streams from
an Avermedia AV180 QAM capable card. I also have a
Hauppauge MVPMC front-end for my mythtv system.

Due to certain limitations of the MVPMC device (namely,
proprietary libraries and no data-sheets), there are
many struggles with playing TS with AC3 audio streams
and keeping the A/V streams in sync. So, I was looking
for the best transcode option, and vlc offers it with this
set of options:

vlc -I dummy -vvv "$whole_filename" --sout-all --audio-language eng --sout "#transcode{acodec=mp2a,ab=192,scale=1,channels=2,deinterlace,audio-sync}:std{mux=ps,access=file,dst=\"/var/video/tmp/$filename.tmp\"}" --file-logging vlc:quit >> $logfile 2>&1

However:
Some of the streams (notably stuff from Toon Disney channel) have 2 audio streams,
spa & eng. My MVPMC device gets confused with this.
I have also seen several other requests to be able to
"filter out" certain PIDs from a TS while transcoding,
and the latest applicable reply I saw seemed to imply that
one should "quit whining and start coding". So, here is
my coding attempt to solve the problem.

The ts patch filters out the stream on the demux side.
The ps patch would be redundant in this case, as it
will filter out on the outbound re-muxing side.

This is hopefully a starting/discussion point, as if it
looks good, then perhaps I might be interested in adding
filtering in the demuxer to drop PIDs by pid. But,
that would require more work, and probably the addition
of another module option, such as --sout-ts-pid-list <string>
which would be a comma-delimited list of PIDs to keep.
Which wouldn't be quite as useful in a batch type environment
as it would require an inspection of each stream beforehand
to figure out which pids to keep. The solution I have
proposed will hopefully be more automated, as one needs to
merely know one's location/language, and then only get the
relevant streams. And, it can be overridden by specifying
another language using the --audio-language option.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ts.svn-diff
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20070921/3bd5b923/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ps.svn-diff
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20070921/3bd5b923/attachment-0001.ksh>
Laurent Aimar
2007-09-21 18:19:09 UTC
Permalink
Post by Mark Paulus
The purpose is to allow for the use of the --audio-language
command line option to limit out certain audio streams
from a TS file.
I think a more generic way would be to use stream_out
module "duplicate" (modules/stream_out/duplicate.c)
It can already select es by type (audio,video,..), by es id, by
program number, ...
You could just add another way to select es like audio-language=list.

For your problem, you may also try :
vlc file.ts --audio-language=value --sout '#...'
(ie without the --sout-all)
Or you can filter by PID using
vlc file.ts --ts-es-id-pid --sout '#duplicate{es=pid1,pid2,pid3}:transcode{}:...'
--
fenrir
Laurent Aimar
2007-09-21 18:29:40 UTC
Permalink
Post by Laurent Aimar
Or you can filter by PID using
vlc file.ts --ts-es-id-pid --sout '#duplicate{es=pid1,pid2,pid3}:transcode{}:...'
Sorry, the right syntax is
vlc file.ts --ts-es-id-pid --sout '#duplicate{dst="transcode{}:...",select="es=pid1,es=pid2"}

If you have
video pid: 100
audio 1 pid: 101
audio 2 pid: 102
vlc file.ts --ts-es-id-pid --sout '#duplicate{dst="transcode{}:...",select="es=100,es=101", \
dst="transcode{}:...",select="es=100,es=102"}
will create 2 outputs, one with first audio, and the second with the other audio.

You could of course run duplicate after the transcode part.
vlc file.ts --ts-es-id-pid --sout 'transcode{}:#duplicate{dst="...", select="..",
dst="...", select=".."}'

Regards,
--
fenrir
Mark Paulus
2007-09-21 19:38:41 UTC
Permalink
Post by Laurent Aimar
Post by Laurent Aimar
Or you can filter by PID using
vlc file.ts --ts-es-id-pid --sout '#duplicate{es=pid1,pid2,pid3}:transcode{}:...'
Sorry, the right syntax is
vlc file.ts --ts-es-id-pid --sout '#duplicate{dst="transcode{}:...",select="es=pid1,es=pid2"}
If you have
video pid: 100
audio 1 pid: 101
audio 2 pid: 102
vlc file.ts --ts-es-id-pid --sout '#duplicate{dst="transcode{}:...",select="es=100,es=101", \
dst="transcode{}:...",select="es=100,es=102"}
will create 2 outputs, one with first audio, and the second with the other audio.
You could of course run duplicate after the transcode part.
vlc file.ts --ts-es-id-pid --sout 'transcode{}:#duplicate{dst="...", select="..",
dst="...", select=".."}'
I think this solution would enable to extract specific PIDs. However, for my use,
extracting by PID id isn't quite practical, because this is being
done in a Myth user job, that is run whenever I select it, after
a recording. So, I'm much more interested in being able to select
the audio stream by the language identifier, if it exists. In my
one test case, I have
2496 - spanish audio track (lang=spa)
2497 - MPEG2 Video
2498 - english audio track (lang=eng)
2499 - Private unknown track

So, in my case I want 2497 & 2498. But, I don't want to have to
select them by id, because I think that would take a fair amount
of scripting using dvbsnoop or something to look inside the stream,
to figure out which audio pid I want. Especially when VLC already
has that info right at its fingertips.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: mark.paulus.vcf
Type: text/x-vcard
Size: 296 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20070921/fe1bf2be/attachment.vcf>
Christophe Massiot
2007-09-21 19:43:09 UTC
Permalink
Post by Mark Paulus
vlc -I dummy -vvv "$whole_filename" --sout-all --audio-language eng --sout
"#transcode{acodec=mp2a,ab=192,scale=1,channels=2,deinterlace,audio-sync}:std{mux=ps,access=file,dst=\"/var/video/tmp/$filename.tmp\"}" --file-logging vlc:quit >> $logfile 2>&1
Some of the streams (notably stuff from Toon Disney channel) have 2 audio
streams, spa & eng. My MVPMC device gets confused with this.
I have also seen several other requests to be able to
"filter out" certain PIDs from a TS while transcoding,
If you remove --sout-all from the command-line above, only the selected
audio language will be output.
--
Christophe Massiot.
Loading...