Saturday, February 10, 2007

scripted rendering!

I am very happy to say that I've been able to script a couple pieces of the rendering process. Once I've edited my HDV masterpiece, I export out an .m2v file and an mp3, layer 2 file, according to my previous post:
http://crazedmuleproductions.blogspot.com/2006/11/cam-compatible-hdv-edit-chain-part-ii.html

I then use the following script to:
1) combine the .m2v and .m2a as a program stream (using mplex)
2) convert the program stream to a transport stream, MPEG-TS file (using VLC)
3) convert the MPEG-TS to a DVD compatible mpg (using ffmpeg)
4) lastly, convert the DVD to an iTunes compatible format (again, using ffmpeg)

Obviously, their is inherent quality loss in each step. I tried to eliminate one conversion step by rendering to the iTunes format direct from the HDV source, but for some reason, ffmpeg gave me errors. So, I saved time and just converted from the DVD source. I will revisit this problem in a later post.

I can say that scripting VLC kicks ass! No more GUI!! Yay!

Here is the script. Don't forget to "chmod a+x " in order to run it.

Note that when run, the script will ask for a filename. That filename must be common to the .m2v and .m2a files. For example, start with two files called test.m2v and test.m2a. The script will prompt you for the filename, at which point you will enter "test" and hit enter. After that, the script will chug away and render each of the files to the filename test., where format will vary by the destination type (.ps/.m2t/.mpg/.mov).

Good luck!

#!/bin/bash -v
#
# This script converts HDV content
echo "Type in the name of the m2a/m2v files for mplex'ing"
read NAME
echo "Mplex'ing $NAME"
mplex -f 3 -b 2000 ${NAME}.m2a ${NAME}.m2v -o ${NAME}.ps

echo "VLC'ing $NAME"
vlc $NAME.ps --sout '#duplicate{dst=std{access=file,mux=ts,dst="'$NAME'.m2t"}}' vlc:quit

echo "FFMPEG convert to DVD"
ffmpeg -i ${NAME}.m2t -target dvd ${NAME}.mpg

echo "FFMPEG convert to MOV"
ffmpeg -i ${NAME}.m2t -f mov -vcodec mpeg4 -qscale 7 -s 320x180 -r 29.97 -aspect 16:9 -acodec aac -ac 2 -ab 128 ${NAME}.mov
echo "Done"

No comments: