diff options
| author | James Meyer <james.meyer@operamail.com> | 2009-08-01 03:14:54 (GMT) | 
|---|---|---|
| committer | James Meyer <james.meyer@operamail.com> | 2009-08-01 03:14:54 (GMT) | 
| commit | 7b35632e80f168d8c5f2220bf610ee7e24b81270 (patch) | |
| tree | 8facf3fa565911f056a08e38f6a5eed0f756f9c6 /abs/core-testing/mplayer-wrapper | |
| parent | 7e10f51870aa10be3b35d7912a7b54e30f608bb8 (diff) | |
| parent | 7accc0f042acdfdca9f067b1d4011d6ac01b1a74 (diff) | |
| download | linhes_pkgbuild-7b35632e80f168d8c5f2220bf610ee7e24b81270.zip linhes_pkgbuild-7b35632e80f168d8c5f2220bf610ee7e24b81270.tar.gz linhes_pkgbuild-7b35632e80f168d8c5f2220bf610ee7e24b81270.tar.bz2 | |
Merge branch 'HEAD' of ssh://jams@knoppmyth.net/mount/repository/LinHES-PKGBUILD
Conflicts:
	abs/core-testing/LinHES-config/PKGBUILD
Diffstat (limited to 'abs/core-testing/mplayer-wrapper')
| -rw-r--r-- | abs/core-testing/mplayer-wrapper/PKGBUILD | 11 | ||||
| -rwxr-xr-x | abs/core-testing/mplayer-wrapper/bin/mplayer-resumer.pl | 188 | ||||
| -rwxr-xr-x | abs/core-testing/mplayer-wrapper/bin/mplayer-wrapper.pl | 110 | ||||
| -rw-r--r-- | abs/core-testing/mplayer-wrapper/mplayer-wrapper.install | 38 | ||||
| -rwxr-xr-x | abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl | 212 | 
5 files changed, 258 insertions, 301 deletions
| diff --git a/abs/core-testing/mplayer-wrapper/PKGBUILD b/abs/core-testing/mplayer-wrapper/PKGBUILD index 82f1082..c64875d 100644 --- a/abs/core-testing/mplayer-wrapper/PKGBUILD +++ b/abs/core-testing/mplayer-wrapper/PKGBUILD @@ -1,6 +1,6 @@  pkgname=mplayer-wrapper -pkgver=1 -pkgrel=1 +pkgver=1	 +pkgrel=9  pkgdesc="wrapper for mplayer and mplayer derivatives"  arch=('i686' 'x86_64') @@ -10,7 +10,12 @@ source=(mplayer-wrapper.pl)  license=('GPL2') +install=mplayer-wrapper.install  build() { +   LH_ROOT=/usr/LH +   mkdir -p $startdir/pkg/$LH_ROOT/bin/ +     cd $startdir -   install -m0777 -D bin/*  $startdir/pkg/usr/LH/bin/ +   # executables +   install -m0755 -D *.pl  $startdir/pkg/$LH_ROOT/bin/  } diff --git a/abs/core-testing/mplayer-wrapper/bin/mplayer-resumer.pl b/abs/core-testing/mplayer-wrapper/bin/mplayer-resumer.pl deleted file mode 100755 index c785a25..0000000 --- a/abs/core-testing/mplayer-wrapper/bin/mplayer-resumer.pl +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/perl - -use Shell; -use strict; -use POSIX qw(floor); - -# Written by Bob Igo from the MythTV Store at http://MythiC.TV -# Email: bob@stormlogic.com -# -# If you run into problems with this script, please send me email - -# PURPOSE: -# -------------------------- -# This is a wrapper script to prove the concept of having MythTV -# resume playback of previously-stopped video where you left off. -# It's likely that a good solution will look different than this -# initial code. - -# RATIONALE: -# -------------------------- -# Watching 90% of a video and stopping causes you to return to the -# beginning again the next time you watch it.  Remembering where -# you were in the video and resuming at that position is a much nicer -# behavior for the user. -# -# By default, mplayer spits out timecode information that tells you -# where you are in the video, to the tenth of a second.  Mplayer also -# supports a seek feature on the command-line.  We can make use of these -# features to write an mplayer wrapper that will remember the last -# position in a video file and resume to it on playback. - -# PARAMETERS: -# -------------------------- -# see print_usage() below - -# FILES: -# -------------------------- -# $infile, the video to play -# $resumefile, the video's resume file (see get_resume_filename() below) - -# KNOWN ISSUES: -# -------------------------- -# Mplayer misreports the timecodes on .nuv MPEG-2 files.  Currently, anything -# captured via an HDTV tuner card and put into your /myth/video directory -# will fail with this resumer. -# -# Current theories include the timecode having to do with the show's broadcast -# time, recording time, or perhaps its upload time to the station that -# broadcast it. - -# DESIGN LIMITATION: -# ------------------------- -# If the video file to be played is on a read-only filesystem, or otherwise -# lives in a location that cannot be written to, resume will fail.  This is -# because the current implementation uses a file parallel to the video file -# to store the timecode. -# - -# CHANGE LOG: -# 5/3/2006 -# Added last time started checking. -# If this script is restarted within $tdiff (default 5 seconds) -# then it will delete the file used to keep track of the videos -# resume position. - - -my $infile; -my $resumefile; -my $mplayer_parameters; -my $fudge_factor=2; # number of additional seconds to skip back before playback -my $tnow;    # Time now. -my $tprev;   # Time the prog was last started.  -             # Returned from the modification time of the xx.resume file. -my $tdiff=5; # How many seconds before we should start from  -             # the beginning of the movie -#DEBUG -#open(DEBUG,">/tmp/debug") || die "unable to open debug file"; - -sub init () { -    $tnow = time(); -    $infile = @ARGV[$#ARGV]; - -    $resumefile = &get_resume_filename($infile); -    # This returns the 9th element of the 13 element array  -    # created by the stat function. -    $tprev = (stat ($resumefile))[9];  -    # if this file is restarted in less than 5 seconds then  -    # remove the .resume file -    if ( ($tnow - $tprev) < $tdiff ) { -        unlink($resumefile); -    } - -    $mplayer_parameters = join(' ',@ARGV[0..$#ARGV-1]); -} - -&init(); -&save_time_offset(&mplayer($mplayer_parameters,$infile), $resumefile); - -#close(DEBUG); - -# For $pathname, return $path.$filename.resume -sub get_resume_filename () { -    my($pathname)=@_; -     -    my $idx = rindex($pathname,"/"); - -    if ($idx == -1) { # There was no "/" in $pathname -	return ".".$pathname.".resume"; -    } else { -	# Now we need to split out the path from the filename. -	my $path = substr($pathname,0,$idx+1); -	my $filename = substr($pathname,$idx+1); -	return "$path.$filename.resume"; -    } -} - -# Calls mplayer and returns the last known video position -sub mplayer () { -    my($parameters,$infile)=@_; -    my $seconds=0; -    my $timecode=&get_time_offset($infile); -    my $command = "mplayer $parameters -ss $timecode \"$infile\" 2>&1 2>/dev/null |"; - -    open(SHELL, $command); -    # The kind of line we care about looks like this example: -    # A:1215.2 V:1215.2 A-V:  0.006 ct:  0.210 207/201 13%  0%  1.9% 0 0 68% -    # But all we care to look at is the first number. -     -    while (<SHELL>) { -	#print DEBUG $_; -	if (m/A: *[0-9]+\.[0-9]/) { # See if this line has timecodes on it -	    my $last_timecode_line = &extract_last_timecode_line($_); -	    if ($last_timecode_line =~ m/ *([0-9]+\.[0-9]) V/) { -		$seconds=$1; -	    } -	} -    } -    close(SHELL); - -    return $seconds; - -    sub extract_last_timecode_line () { -	my ($line)=@_; -	my @lines=split('A:',$line); -	return @lines[$#lines-1]; -    } -} - -# Save the last known video position -sub save_time_offset () { -    my($seconds, $resumefile)=@_; - -    open(RESUMEFILE, ">$resumefile") || die "Unable to open $resumefile for writing"; -    print RESUMEFILE "$seconds"; -    close(RESUMEFILE); -} - -# returns the number of seconds corresponding to the last known video position, -# in hh:mm:ss format, compatible with the "-ss" parameter to mplayer -sub get_time_offset () { -    my($videofile)=@_; -    my($resumefile) = &get_resume_filename($videofile); -    my $seconds=0; -    my $timecode; - -    open(RESUMEFILE, "<$resumefile") || return "00:00:00"; -    while(<RESUMEFILE>) { -	$seconds=$_; -    } -    close(RESUMEFILE); - -    my $hours = floor($seconds/3600); -    $seconds = $seconds - $hours*3600; - -    my $minutes = floor($seconds/60); -    $seconds = int($seconds - $minutes*60) - $fudge_factor; - -    $timecode = sprintf "%02d:%02d:%02d",$hours,$minutes,$seconds; -#    print "TIMECODE: $timecode\n"; -    return $timecode; -} - -sub print_usage () { -    print "USAGE:\n"; -    print "\t",$ARGV[0], "[mplayer parameters] video_file\n"; -    print "\t","e.g. ",$ARGV[0], "-fs -zoom my.mpg\n"; -    print "\t","Version 5/3/2006\n"; -} diff --git a/abs/core-testing/mplayer-wrapper/bin/mplayer-wrapper.pl b/abs/core-testing/mplayer-wrapper/bin/mplayer-wrapper.pl deleted file mode 100755 index 583786d..0000000 --- a/abs/core-testing/mplayer-wrapper/bin/mplayer-wrapper.pl +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/perl - -use Shell; -use strict; -use POSIX qw(floor); - -# Written by Bob Igo from the MythTV Store at http://MythiC.TV -# including some original code and contributions from Nick C. -# and graysky. -# Email: bob@stormlogic.com -# -# If you run into problems with this script, please send me email - -# PURPOSE: -# -------------------------- -# This is a wrapper script that tries to find the best parameters -# for calling an underlying video player.  The outer layer determines -# the best playback parameters, while the inner layer picks the best -# player to call. - -# RATIONALE: -# -------------------------- -# Default video playback options are not optimal on all hardware or -# for all video types.  In addition, common video players do not -# offer to bookmark video so that you can resume where you left off. -# Both of these problems can be addressed by this wrapper. - -# PARAMETERS: -# -------------------------- -# The same parameters you'd use for mplayer, some of which may be -# translated automatically for use with smplayer. - -# FILES: -# -------------------------- -# $mediafile, the file to play - -sub run () { -    my $mediafile = @ARGV[$#ARGV]; -    my $player = &pick_player(); - -    my $player_parameters = join(' ', -				 &translate_parameters($player,@ARGV[0..$#ARGV-1]), -				 &dynamic_parameters($mediafile)); -    &player($player,$player_parameters,$mediafile); -} - -&run(); - -# Translates any parameters into ones that will be compatible with the given player. -sub translate_parameters() { -    my($player,@parameters)=@_; - -    if ($player eq "smplayer") { -	# Stupidly, smplayer uses a different set of command-line parameters than generic -	# mplayer, so we need to translate mplayer-centric ones into the few that are -	# available in smplayer-ese. -	my %smplayer_parameter_translation_array = ( -	    "-fs" => "-fullscreen", -	    "-zoom" => " " -	    ); -	 -	sub translate() { -	    my($flag)=@_; -	    return $smplayer_parameter_translation_array{$flag}; -	} -	 -	return map(&translate($_), @parameters); -    } else { -	return @parameters; -    } -} - -# Returns an array of dynamic parameters based in part on the media. -sub dynamic_parameters () { -    my($mediafile)=@_; -    return(); # ??? empty for now; further development required -} - -# Find the best player for use on this system.  The script prefers smplayer, -# which has built-in bookmarking, falling back to mplayer-resumer.pl, which -# implements bookmarking as an mplayer wrapper, if smplayer cannot be found. -# Finally, if no bookmarking players can be found, a barebones mplayer is used. -sub pick_player () { -    my @possible_players = ("smplayer", "mplayer-resumer.pl", "mplayer"); -    my $command; -    my $candidate_player; -    foreach (@possible_players) { -	$candidate_player = $_; -	$command = "which $candidate_player |"; -	open(SHELL, $command); -	if (<SHELL>) { -	    #print "player $candidate_player : $_\n"; -	    return $candidate_player; -	} -	close(SHELL); -    } -} - -# Calls player -sub player () { -    my($player,$parameters,$mediafile)=@_; -    my $command = "$player $parameters \"$mediafile\" 2>&1 2>/dev/null |"; - -    #print "DEBUG: command is:\n$command\n"; -    open(SHELL, $command); -    while (<SHELL>) { -	print $_; -    } -    close(SHELL); -} diff --git a/abs/core-testing/mplayer-wrapper/mplayer-wrapper.install b/abs/core-testing/mplayer-wrapper/mplayer-wrapper.install new file mode 100644 index 0000000..18f1b75 --- /dev/null +++ b/abs/core-testing/mplayer-wrapper/mplayer-wrapper.install @@ -0,0 +1,38 @@ +# This is a default template for a post-install scriptlet.  You can +# remove any functions you don't need (and this header). + +# arg 1:  the new package version +pre_install() { +/bin/true +} + +# arg 1:  the new package version +post_install() { +/bin/true +} + +# arg 1:  the new package version +# arg 2:  the old package version +pre_upgrade() { +  /bin/true +} + +# arg 1:  the new package version +# arg 2:  the old package version +post_upgrade() { +  /bin/true +} + +# arg 1:  the old package version +pre_remove() { +  /bin/true +} + +# arg 1:  the old package version +post_remove() { +  /bin/true +} + +op=$1 +shift +$op $* diff --git a/abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl b/abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl new file mode 100755 index 0000000..da0e838 --- /dev/null +++ b/abs/core-testing/mplayer-wrapper/mplayer-wrapper.pl @@ -0,0 +1,212 @@ +#!/usr/bin/perl + +use Shell; +use strict; +use POSIX qw(floor); + +# Written by Bob Igo from the MythTV Store at http://MythiC.TV +# including some original code and contributions from Nick C. +# and graysky. +# Email: bob@stormlogic.com +# +# If you run into problems with this script, please send me email + +# PURPOSE: +# -------------------------- +# This is a wrapper script that tries to find the best parameters +# for calling an underlying video player.  The outer layer determines +# the best playback parameters, while the inner layer picks the best +# player to call. + +# RATIONALE: +# -------------------------- +# Default video playback options are not optimal on all hardware or +# for all video types.  In addition, common video players do not +# offer to bookmark video so that you can resume where you left off. +# Both of these problems can be addressed by this wrapper. + +# PARAMETERS: +# -------------------------- +# The same parameters you'd use for mplayer, some of which may be +# translated automatically for use with smplayer. + +# FILES: +# -------------------------- +# $mediafile, the file to play + +sub run () { +    my $mediafile = @ARGV[$#ARGV]; +    my $player = &pick_player(); + +    # mplayer evaluates configuration options in the following order, with +    # later-evaluated options overriding earlier-evaluated ones, both within +    # a given configuration location and between them: +    # 1) system-wide configuration/profiles, /etc/mplayer/mplayer.conf +    # 2) user-specific configuration/profiles, ~/.mplayer/config +    # 3) commandline configuration parameters +    # 4) file-specific configuration, ~/.mplayer/[filename].conf +    # 5) any nonstandard configuration file, included via "-include" parameter +    # +    # This script's dynamic configuration options fall in at 2.5 above, +    # so commandline options, file-specific configuration options, +    # or a nonstandard configuration file will override the options that +    # the script creates, but system-wide and user-specific configuration +    # will be overridden by the dynamic configuration options. +    # +    # This is sub-optimal, as the easiest way for a user to compensate for +    # a misfiring configuration rule would be to override it in a configuration +    # file.  Instead, they will have to change the way they run this script. + +    my $player_parameters = join(' ', +				 &dynamic_parameters($mediafile), +				 &translate_parameters($player,@ARGV[0..$#ARGV-1])); +    &player($player,$player_parameters,$mediafile); +} + +&run(); + +# Translates any parameters into ones that will be compatible with the given player. +sub translate_parameters() { +    my($player,@parameters)=@_; + +    if ($player eq "smplayer") { +	# Stupidly, smplayer uses a different set of command-line parameters than generic +	# mplayer, so we need to translate mplayer-centric ones into the few that are +	# available in smplayer-ese. +	my %smplayer_parameter_translation_array = ( +	    "-fs" => "-fullscreen", +	    "-zoom" => " " +	    ); +	 +	sub translate() { +	    my($flag)=@_; +	    return $smplayer_parameter_translation_array{$flag}; +	} +	 +	return map(&translate($_), @parameters); +    } else { +	# currently, all other players used by this wrapper work with mplayer parameters +	return @parameters; +    } +} + +# Returns an array of dynamic parameters based on the media type, +# the presence of special playback decoding hardware, and the +# general capability of the CPU. +sub dynamic_parameters () { +    my($mediafile)=@_; +    my @parameters = (); +    my $codec=""; +    my %vdpau_supported_modes=(); + +    # See if the GPU and driver support vdpau for GPU-based accelerated decoding +    my $command="vdpinfo |"; +    # 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): +    # +    #MPEG1             0  2  4096  4096 +    #MPEG2_SIMPLE      3  2  4096  4096 +    #MPEG2_MAIN        3  2  4096  4096 +    #H264_MAIN        41  4  4096  4096 +    #H264_HIGH        41  4  4096  4096 +     +    my $grabbing_modes=0; +    open(SHELL, $command); +    while (<SHELL>) { +	chop; +	if (m/Decoder Capabilities/gi) { +	    $grabbing_modes=1; +	    #print "*** MODES START NOW" +	} elsif (m/Output Surface/gi) { +	    $grabbing_modes=0; +	} elsif ($grabbing_modes) { +	    if (m/[A-Z]+[0-9]+/g) { +		s/(_.*)//g; +		#print "*** GRABBED MODE $_\n"; +		$vdpau_supported_modes{$_} = 1; +	    } +	} +    } +    close(SHELL); +     +    # figure out what codec the video uses +    my $command="mplayer -identify -frames 0 \"$mediafile\" | grep ID_VIDEO_CODEC | cut -c 16- |"; +    open(SHELL, $command); +    while (<SHELL>) { +	chop; +	$codec = $_; +	#print "DEBUG: codec is $codec\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"); +	} +    } 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 +	 +#    } elsif ($codec eq "ffvc1") { # WVC1 +#	if ($vdpau_supported) { +#	push(@parameters, "-vo vdpau"); +#	push(@parameters, "-vc ffvc1vdpau"); +#    } + +    } else { +	push(@parameters, "-vo xv,x11,"); +	push(@parameters, "-vc ,"); +	push(@parameters, "-vf pp=lb,"); # doesn't actually work with vdpau, but doesn't break anything +    } +    return(@parameters); +} + +# Find the best player for use on this system.  The script prefers smplayer, +# which has built-in bookmarking, falling back to mplayer-resumer.pl, which +# implements bookmarking as an mplayer wrapper, if smplayer cannot be found. +# Finally, if no bookmarking players can be found, a barebones mplayer is used. +sub pick_player () { +    #my @possible_players = ("smplayer", "mplayer-resumer.pl", "mplayer"); +    my @possible_players = ("mplayer-resumer.pl", "mplayer"); +    my $command; +    my $candidate_player; +    foreach (@possible_players) { +	$candidate_player = $_; +	$command = "which $candidate_player |"; +	open(SHELL, $command); +	if (<SHELL>) { +	    #print "player $candidate_player : $_\n"; +	    return $candidate_player; +	} +	close(SHELL); +    } +} + +# Calls player +sub player () { +    my($player,$parameters,$mediafile)=@_; +    my $command = "$player $parameters \"$mediafile\" 2>&1 |"; + +    print "DEBUG: $0's player command is: *** $command ***\n"; +    open(SHELL, $command); +    while (<SHELL>) { +	print $_; +    } +    close(SHELL); +} | 
