Monday 24 September 2007

vlc transcoding for portable players

Here's the script I use to transcode all the video files in the current directory to 320 pixel wide MP4 format files suitable for playback on devices limited in both CPU and RAM - in my case my mobile phone.

Total bitrate (video and audio) is 128kbps, which works out as roughly 1MB a minute. This works better on cartoons than it does on live action or CG. Audio is downsampled to mono 11025hz to avoid excessive artifacting.

#!/bin/bash
vcodec="mp4v"
acodec="mp4a"
bitrate="96"
w=320
arate="32"
asrate="11025"
achannels="1"
ext="mp4"
mux="mp4"
vlc="vlc"
out="/media/files/video/portable/"

for a in *; do
if ! [ -f "$out$a.$ext" ]
then
$vlc -I dummy -vvv "$a" --sout "#transcode{vcodec=$vcodec,vb=$bitrate,width=$w,autocrop,scale,deinterlace,audio-sync,acodec=$acodec,ab=$arate,samplerate=$asrate,channels=$achannels}:standard{mux=$mux,dst=\"$out$a.$ext\",access=file}" vlc:quit
fi
done

Labels: , , , , ,

mp3togo Usage

Here's a handy script that uses mp3togo to transcode everything in your music library into nice, cleanly tagged mp3 files suitable for use on a portable player. In this case it transcodes using the "tape" preset, which I find perfectly acceptable for the purpose.

To use the script, you'll need to:
  1. Install mp3togo and all related packages
  2. Copy and paste the script into a new text file. Alter the "src" and "out" variables to point to the correct path.
  3. chmod the script executable.
  4. Execute!

#!/bin/sh
src="/media/files/audio/library"
out="/media/files/audio/portable/"
preset="tape"

if [ -f /tmp/mp3togo.m3u ]
then
mp3togo -p /tmp/mp3togo.m3u -d 0 -C lame -E "--preset $preset" --format %a-%l-%t -u -o $out
rm /tmp/mp3togo.m3u
else
find $src -type f > /tmp/mp3togo.tmp
sort /tmp/mp3togo.tmp > /tmp/mp3togo.m3u
rm /tmp/mp3togo.tmp
mp3togo -p /tmp/mp3togo.m3u -d 0 -C lame -E "--preset $preset" --format %a-%l-%t -u -o $out
rm /tmp/mp3togo.m3u
fi

Labels: