#!/usr/bin/perl -w

use strict;

my $elifile;

while($elifile = shift()) {

  if($elifile !~ m/\.eli$/) {
    print "This is no Edit List file! [$elifile]\n";
    next;
  }

  my $audiofile = $elifile;
  $audiofile =~ s/\.eli$/.mpa/g;

  my $videofile = $elifile;
  $videofile =~ s/\.eli$/.m2v/g;

  my $mpegfile  = $elifile;
  $mpegfile =~ s/\.eli$/.mpeg/g;

  system("lav2wav \"$elifile\" | mp2enc -r 48000 -b 384 -o \"$audiofile\"");

  system("lav2yuv \"$elifile\" 2> /dev/null | mpeg2enc -M 3 -S 3900 -B 384 -q 4 -b 6000 -f 8 -o \"$videofile\"");

  system("mplex -f 8 $audiofile $videofile -o $mpegfile");
}

