Friday, September 25, 2009

Batch Transcoding with VLC 1.0.x

After I upgraded my VLC player to v1.0.x, I realised my batch transcoding script stopped working. After much tinkering with the syntax and googling, I've got it working again. Here is the updated script:

#!/bin/bash
vcodec="mp4v"
acodec="mp4a"
bitrate="3072"
arate="192"
ext="mp4"
mux="mp4"
# Modify the path to VLC on your machine accordingly
vlc="/Applications/VLC.app/Contents/MacOS/VLC"
fmt="MPG"
dst="/Dest/Path/"
for a in *$fmt; do
  echo $a
  $vlc -I dummy -vvv "./$a" --sout="#transcode{vcodec=$vcodec,\
  vb=$bitrate,acodec=$acodec,ab=$arate}:std{mux=$mux,\
  dst=\"$dst$a.$ext\",access=file}" vlc://quit
  touch -m -r $a $dst$a.$ext
done

No comments: