[mythtv-users] How to locate the correct audio track when transcoding?

Robin Neatherway robthebob at gmail.com
Mon Dec 11 13:36:51 UTC 2006

On 12/11/06, David Watkins <watkinshome at gmail.com> wrote:
> Bearing in mind that mythtv always selects the right audio track when
> playing back the original recording, how do I extract this information
> and supply it to the transcoding process so that I get just the audio
> track that I need into the transcoded file?

In my experience, it is always the lower of the two PIDs associated
with the two audio tracks. The following perl subroutine is what I use
in an encoding script to get the PIDs of the video, audio and subtitle

sub getTsPids {
	my $file = shift(@_);
	my %pids;
	my $VIDEO_STREAM = "0x10000002";
	my $AUDIO_STREAM = "0x50";
	my $TITLE_STREAM = "0x3000001";
	my @streams = `mplayer -v $file -novideo -nosound -frames 0 2>&1 |
grep PARSE_PMT | sort | uniq`;
	foreach (@streams) {
		/pid=(0x[\dabcdef]*) \((\d*)\), type=(0x\d*),/;
		print "$1 $2 $3\n";
		if($3 eq $VIDEO_STREAM) {$pids{'video'} = $2;}
		if($3 eq $TITLE_STREAM) {$pids{'title'} = $2;}	
		if($3 eq $AUDIO_STREAM and (not defined($pids{'audio'}) or $2 <
$pids{'audio'})) {$pids{'audio'} = $2;}
	return %pids;

The mplayer line seems to get the right info out, or it did last time
I played with this anyway (about 6 months).

Hope that helps,

More information about the mythtv-users mailing list