#!/usr/bin/perl
###########
# eva700 Transcoder.
#
# it's called like this:
# Foo.Flv
#
# Questions/Comments: toxic@doobie.com
#
# Code is provided as-is, without warranty of any kind, and
# may be redistributed under the GNU Public License, Version 2
##########
# Set these appropriately for your environment
#
my $FFMPEG_BIN = "/usr/bin/ffmpeg";
my $VIDEO_DIR = "/var/www/htdocs/media/";
use IO::Handle;
use CGI;
my $c = new CGI;
my %V = $c->Vars;
# Be aware that this is unchecked, ugly, and can
# very easily be manipulated to read arbitrary files.
# Either trust your users, or add sanity checking here.
my $video = $VIDEO_DIR . $V{'v'};
open (FILE, "$FFMPEG_BIN -i \"$video\" -acodec mp3 -vcodec xvid -vtag xvid -ab 128kb -b 1500kb -async 60 -f avi - 2>/dev/null|");
# Give ffmpeg a little head start.
sleep 3;
print $c->header(-type=>"video/x-msvideo");
while () {print;}