diff options
author | James Meyer <james.meyer@operamail.com> | 2010-04-04 19:19:34 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2010-04-04 19:19:34 (GMT) |
commit | 57bf063a8ecc8593ca9ef414582fd4d0e3fa645b (patch) | |
tree | 900aa339da9504674ac74b39dd24b852ab57eca1 /abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl | |
parent | 52a3c918e68f44a7cb3a93d36283b78c6327e6c4 (diff) | |
parent | 046827612a3c895ff4682d52ffc64c4e116225e1 (diff) | |
download | linhes_pkgbuild-57bf063a8ecc8593ca9ef414582fd4d0e3fa645b.zip linhes_pkgbuild-57bf063a8ecc8593ca9ef414582fd4d0e3fa645b.tar.gz linhes_pkgbuild-57bf063a8ecc8593ca9ef414582fd4d0e3fa645b.tar.bz2 |
Merge branch 'HEAD' of ssh://jams@knoppmyth.net/mount/repository/LinHES-PKGBUILD
Diffstat (limited to 'abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl')
-rw-r--r--[-rwxr-xr-x] | abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl | 95 |
1 files changed, 72 insertions, 23 deletions
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); } |