[mythtv-users] Fwd: transcoding a bunch of files

Christopher Meredith chmeredith at gmail.com
Thu Oct 29 01:07:39 UTC 2009


On Wed, Oct 28, 2009 at 4:38 PM, Richard Morton
<richard.e.morton at gmail.com> wrote:
>
>
>
> Hi There,
>
> I think taking some of the things from the perl script and doing it
> all in bash is probably the best approach. Unfortunately, I won't be
> able to do any work on it for at least 2 weeks as I have a bunch of
>
> well, if that is a very kind offer to look at it, it can for sure wait a
> couple of weeks. I would appreciate seeing your work so I can brush up on
> bash, never looked at PERL previously; was considering picking up Python at
> some point.
>
> thanks again... if that wasnt an offer, sorry for the mis-understanding; I
> would still appreciate a look at your code though

Sure, no problem. Here's the DV script:

http://monopedilos.com/dokuwiki/doku.php?id=dv2mkv

I have since updated the script to give the user the choice between
h264/vorbis/MKV or h264/aac/MP4 (for online streaming purposes). That
introduces some output conditionals. My hdpvrcutter script is the
other one I mentioned, but the input conditionals are not in the
version on my wiki. A portion of the perl that I used is here:

### Use ffmpeg to figure out the audio properties
$info = `ffmpeg -i $filename 2>&1 | grep Audio`;
$info =~ s/\,//g;
@fields = split(' ', $info);
$audiofmt = $fields[3];
$abitrate = $fields[9];
print $abitrate;

if ($audiofmt eq "aac")
{
#	$audioarg = "-oac mp3lame -lameopts abr:br=128";
#	$audioarg = "-channels 6 -oac lavc -lavcopts acodec=ac3:abitrate=${abitrate}";
	$preconvert = "mencoder -ovc copy -channels 6 -oac lavc -lavcopts
acodec=ac3:abitrate=160 \"$filename\" -o ${recordings_dir}/temp.mpg;";
	$filename2 = "${recordings_dir}/temp.mpg";
}

if ($audiofmt eq ac3)
{
#	$audioarg = "-oac copy"
#       $audioarg = "-channels 6 -oac lavc -lavcopts
acodec=ac3:abitrate=${abitrate}";
	$preconvert = "";
	$filename2 = "$filename";
}

This basically makes an array out of the input file properties and
then it is possible to separate out the values in the array to
correspond to things like video format, audio format, audio channels,
video bitrate, etc. In the example above, I then determine what
mencoder options to use depending on the input file format.

(For the sake of clarity, these scripts were to serve very different
functions, but the principles can be applied.)


More information about the mythtv-users mailing list