diff options
| -rw-r--r-- | abs/core-testing/mplayer-wrapper/PKGBUILD | 6 | ||||
| -rw-r--r--[-rwxr-xr-x] | abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl | 95 | 
2 files changed, 75 insertions, 26 deletions
diff --git a/abs/core-testing/mplayer-wrapper/PKGBUILD b/abs/core-testing/mplayer-wrapper/PKGBUILD index c64875d..2dbf67d 100644 --- a/abs/core-testing/mplayer-wrapper/PKGBUILD +++ b/abs/core-testing/mplayer-wrapper/PKGBUILD @@ -1,16 +1,15 @@  pkgname=mplayer-wrapper  pkgver=1	 -pkgrel=9 +pkgrel=10  pkgdesc="wrapper for mplayer and mplayer derivatives"  arch=('i686' 'x86_64') -depends=('perl')  +depends=('perl' 'vdpauinfo')   source=(mplayer-wrapper.pl)  license=('GPL2') -install=mplayer-wrapper.install  build() {     LH_ROOT=/usr/LH     mkdir -p $startdir/pkg/$LH_ROOT/bin/ @@ -19,3 +18,4 @@ build() {     # executables     install -m0755 -D *.pl  $startdir/pkg/$LH_ROOT/bin/  } +md5sums=('c21a8b05d2134262c876396bde9da0a2') diff --git a/abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl b/abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl index da0e838..18f3caf 100755..100644 --- a/abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl +++ b/abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl @@ -97,10 +97,13 @@ sub dynamic_parameters () {      my($mediafile)=@_;      my @parameters = ();      my $codec=""; +    my $xresolution=0; +    my $yresolution=0;      my %vdpau_supported_modes=(); +    my $vf_parameters="";      # See if the GPU and driver support vdpau for GPU-based accelerated decoding -    my $command="vdpinfo |"; +    my $command="vdpauinfo |";      # On supported hardware, vdpinfo produces relevant results that look something like this (see      # http://www.phoronix.com/forums/showthread.php?t=14493 for additional details, or run      # vdpinfo on vdpau-capable hardware yourself): @@ -130,49 +133,95 @@ sub dynamic_parameters () {      }      close(SHELL); -    # figure out what codec the video uses -    my $command="mplayer -identify -frames 0 \"$mediafile\" | grep ID_VIDEO_CODEC | cut -c 16- |"; +    # Learn some things about the video: codec and resolution +    my $command="mplayer -identify -frames 0 \"$mediafile\" |";      open(SHELL, $command);      while (<SHELL>) {  	chop; -	$codec = $_; -	#print "DEBUG: codec is $codec\n"; +	if (m/ID_VIDEO_CODEC=(.*)/g) { +	    $codec = $1; +	    #print "DEBUG: codec is $codec\n"; +	} elsif (m/ID_VIDEO_WIDTH=(.*)/g) { +	    $xresolution = $1; +	    #print "DEBUG: x resolution is $xresolution\n"; +	} elsif (m/ID_VIDEO_HEIGHT=(.*)/g) { +	    $yresolution = $1; +	    #print "DEBUG: y resolution is $yresolution\n"; +	}      }      close(SHELL); -    # We should use vdpau if it's available and helps with the codec we need to decode. -    if ($codec eq "ffh264") { # h.264 -	if ($vdpau_supported_modes{"H264"}) { -	    push(@parameters, "-vo vdpau"); -	    push(@parameters, "-vc ffh264vdpau"); +    # see if it's a malformed 4:3 video with top and side bars, in need of cropping +    my $crop_candidate=""; +    my $biggestX=0; +    my $biggestY=0; +    # The algorithm here is trial and error.  Skip 6 minutes into a video, and look at 40 frames of +    # video.  Videos shorter than 6 minutes will not end up being examined for letterboxing badness. +    # In a longer video, use the least-recommended pruning that mplayer suggests, among the frames polled. +    my $command="mplayer -ss 360 -ao null -vo null -vf cropdetect -frames 40 \"$mediafile\" | grep CROP | tail -1 |"; +    open(SHELL, $command); +    while (<SHELL>) { +	if (m/-vf (crop=.*)\)/g) { +	    $crop_candidate = $1; +	    print "DEBUG: $crop_candidate\n"; +	    if ($crop_candidate =~ m/(\d+):(\d+)/) { +		if (($1 > $biggestX) && ($2 > $biggestY)) { +		    $biggestX = $1; +		    $biggestY = $2; +		    print "newX: $biggestX\n"; +		    print "newY: $biggestY\n"; +		} +	    }  	} -    } elsif ($codec eq "ffmpeg2") { # MPEG2 -	if ($vdpau_supported_modes{"MPEG2"}) { -	    push(@parameters, "-vo vdpau"); -	    push(@parameters, "-vc ffmpeg12vdpau"); +	if (($biggestX != $xresolution) || ($biggestY != $yresolution)) { +	    $vf_parameters = $crop_candidate;  	} +	print "DEBUG: crop parameter is $vf_parameters\n"; +    } +    close(SHELL); -	# ??? although MPEG1 is rare, it seems as if it should work with -vc ffmpeg12vdpau as well -	 -	# problems have been reported with WMV3 support -	 +    # If there are no crop parameters, use vdpau if it's supported.  Don't use vdpau if there's cropping +    # because vdpau doesn't work with mplayer's cropping video filter. + +    # We should use vdpau if it's available and helps with the codec we need to decode. +    if ($vf_parameters eq "") { +	if ($codec eq "ffh264") { # h.264 +	    if ($vdpau_supported_modes{"H264"}) { +		push(@parameters, "-vo vdpau"); +		push(@parameters, "-vc ffh264vdpau"); +	    } +	} elsif ($codec eq "ffmpeg2") { # MPEG2 +	    if ($vdpau_supported_modes{"MPEG2"}) { +		push(@parameters, "-vo vdpau"); +		push(@parameters, "-vc ffmpeg12vdpau"); +	    } +	     +	    # ??? although MPEG1 is rare, it seems as if it should work with -vc ffmpeg12vdpau as well +	     +	    # problems have been reported with WMV3 support +	      #    } elsif ($codec eq "ffwmv3") { # WMV3  #	if ($vdpau_supported) {  #	push(@parameters, "-vo vdpau");  #	push(@parameters, "-vc ffwmv3vdpau");  #    } -	# problems have been reported with WVC1 support -	 +	    # problems have been reported with WVC1 support +	      #    } elsif ($codec eq "ffvc1") { # WVC1  #	if ($vdpau_supported) {  #	push(@parameters, "-vo vdpau");  #	push(@parameters, "-vc ffvc1vdpau");  #    } - -    } else { +	     +	} else { # any codec that doesn't work with vdpau +	    push(@parameters, "-vo xv,x11,"); +	    push(@parameters, "-vc ,"); +	    push(@parameters, "-vf pp=lb,$vf_parameters"); +	} +    } else { # there is a crop parameter  	push(@parameters, "-vo xv,x11,");  	push(@parameters, "-vc ,"); -	push(@parameters, "-vf pp=lb,"); # doesn't actually work with vdpau, but doesn't break anything +	push(@parameters, "-vf pp=lb,$vf_parameters");      }      return(@parameters);  }  | 
