#!/usr/bin/perl -w
use constant TRUE => 1 ;
use constant FALSE => 0 ;
# TO EDIT
my $mplayer = "mplayer -msglevel all=1:vfilter=5:cplayer=5";
my $lowresvf = "fspp,hqdn3d,scale"; # bitrate < 1024
my $medresvf1 = "pp,hqdn3d,scale"; # (1024 < bitrate < 2048 and codec not wmv or h264) or codec mpeg2
my $medresvf2 = "hqdn3d,scale"; # 1024 < bitrate < 2048 and codec wmv or h264
my $highresvf = ""; # bitrate > 2048
my $isorep = "/mnt/isoloop";
# DECLARED
my (@temp,@sub,$filename);
my $movie=""; my $vf=""; my $af=""; my $lavdopts=""; my $vo=""; my $sublist=""; my $subsearch=""; my $srtsearch=""; my $cache="";
my $croplines = "default";
my $highcache = 8192;
my $isofile = FALSE;
my $crop = TRUE; my $dvdcrop = FALSE; my $nopp = FALSE; my $desint = FALSE; my $hrtf = FALSE;
#-Get command line arguments
&get_cmdargs;
#-Get filename without extension
@temp = $filename =~ m/[^.]+/g; #-On separe les arguments dans un tableau par le point
$movie = $temp[0]; #-On recrée correctement le nom du fichier : il peut comporter des points
for ($i=1; $i < @temp-1; $i++) {
$movie = $movie . "." . $temp[$i];
}
#-Load all subtitles files
$srtsearch = $movie . "*" . ".srt"; #-Les critères de recherche de sous-titres
$subsearch = $movie . "*" . ".sub";
$srtsearch = met_en_forme ($srtsearch); #-Mise en forme
$subsearch = met_en_forme ($subsearch); #-Mise en forme
@sub = split ("\n", `ls $srtsearch 2> /dev/null` . `ls $subsearch 2> /dev/null`); #-On retire les retours chariot
if (@sub) {
$sublist = $sub[0]; #-Et on les remplace par des virgules
for ($i=1; $i < @sub; $i++) {
$sublist = $sublist . "," . $sub[$i];
}
$sublist = met_en_forme ($sublist);
$sublist = "-sub ".$sublist;
}
#-On met en forme le nom du fichier film
$filename = met_en_forme ($filename);
#-Change cache value for network and removable medias
if ($filename =~ m/\/media\//) {
printf "The file is from a network or removable media : set high value for cache";
#$cache = "-cache $highcache";
$cache = "-cache $highcache";
}
# Declare $isofile if file is iso
#if ( (`file $filename` =~ m/ISO/) || (`file $filename` =~ m/UDF/) ){
if (`file $filename` =~ m/UDF/) {
$isofile = TRUE;
print "File type is ISO, loop mount in $isorep, crop will be adjusted\n";
}
#-Lecture de la config de mplayer
$config=`grep -v \\# ~/.mplayer/config`;
@data = split ("\n", $config);
foreach (@data) {
# $vf = $_ if $_ =~ m/vf=/;
$af = $_ if $_ =~ m/af=/;
$lavdopts = $_ if $_ =~ m/lavdopts=/;
}
#$vf =~ s/vf=//g;
$af =~ s/af=//g;
$lavdopts =~ s/lavdopts=//g;
#printf "DEBUG : Config initiale de mplayer : vf : non charge, af : $af, lavdopts : $lavdopts\n";
#-Identify movie
&movie_ident;
#-Video filters
&vf_adjust if ($nopp == FALSE); # Don't do postprocessing if -nopp option set
#-Video Cropping
if ($width != 0 && $height != 0) {
&do_crop if $crop;
&do_dvdcrop if $dvdcrop;
}
# Nombres de canaux audio et opts relatives
$channels = 2;
#if ($channels eq "")
# { $channels = 2 };
#if ($channels == 6 && $af ne "")
# { $af="hrtf,".$af; }
#if ($channels == 6 && $af eq "")
# { $af="hrtf"; }
#if ($channels == 2 && $af ne "")
# { $af="$af"; }
#printf "la config audio est af : $af -- channels : $channels\n";
#-Annule extinction moniteur
#system "xset s off; xset -dpms";
#-Demarre la lecture
&launch_mplayer;
#-Remet en place extinction moniteur
#system "xset s on; xset +dpms";
#-Umount isoloop if necessary
system "sudo isoumount.sh /mnt/isoloop" if $isofile;
#---------------------- SUBROUTINES -----------------------------
sub get_cmdargs {
if ((!$ARGV[0]) || ($ARGV[0] eq -help)) {
printf "Syntax : playmovie