#!/usr/bin/perl -w
#
# Convert videos using VLC to a 3gp file suited for mobile phones
# 12.1.08 Beat Rubischon <beat@0x1b.ch>
#
use strict;

while(my $in=shift) {
    $in=~/(.*)\.[^.]*$/;
    my $out="$1.3gp";
    print "$in $out\n";

    my $pid=fork;
    if ($pid==0) {
        exec "/Applications/VLC.app/Contents/MacOS/VLC",
	     "-I", "dummy", $in, "vlc:quit",
	     "--sout", "#transcode{ ".
	     "vcodec=H263,vb=168,width=176,height=144,deinterlace,".
             "acodec=mp4a,ab=32,channels=2,samplerate=22100}".
             ":std{access=file,mux=mp4,dst=$out}";
        die "exec() failed";
    }

    wait;
}
