Notices


Reply
Thread Tools
iliaden's Avatar
Posts: 267 | Thanked: 50 times | Joined on Feb 2008 @ Montreal, Canada
#61
Thanks, this is a very interesting idea.
I will make sure this is added to the final release, but not until then. I think it's better to concentrate on the script itself first, and only then go for the gui. However, the method you offered has a slight problem: most people would just run their videos through a media player.
I, myself, am not quite familiar with the MPlayer package built for maemo, but I do know it has a gui. Could you point to the file to be modified in order for the gui to launch "mplayer-opt FILE" instead of "mplayer FILE". I believe this would be the most convenient for a common end user.

@josiahg777
I [just] found this [by following the provided link and by adding the "h" to http]:
Originally Posted by qole View Post
MPlayer makes a bit of a hash of the WMV and the aspect ratio is all wrong. The aspect ratio can be fixed by adding another parameter to the mplayer command line: "-aspect 16:9" ... but that really should be some kind of dialog: "what aspect ratio? [ ] 4:3 [ ] 16:9 (WS)"
should we add some parameters to our script? If so, how do I remove the difference in the parameter order? i.e., how do I say "if any parameter is -PARAMETER, do this..."?


And I made a few updates, and removed an impossible if situation, so this script should be version 4 (yet I don't have any hosting sites ).
Changelog: 1) added a "-o" and "--original" option: bypass the script. this could be useful to compare the modifications with the original.
2) corrected the bitrate values
3) added the "hardframedrop" for files with FPS > 25
4) corrected authors' names
5) modified echo returns
Here it is:
Code:
#! /bin/sh -f
if [ $1 == "-h" -o $1 == "--help" ]
then
   echo -e "\n \t \t Usage: mplayer-opt [FILENAME] \n"
   echo This script calls MPlayer with several optimizations 
   echo -e "\t to allow smooth playback of most content"
   echo -e "\t both with and without optimization"
   echo Known Issues: This script will not work with videos
   echo -e "\t whose aspect ratio has not been declared"
   echo Authors: Josiah Gaskin, Ilia Denotkine. Version: 0.4
   exit 0
fi
if [ $1 == "-o" -o $1 == "--original" ]
then
    NAME=$2
    echo -n Playing video without ANY modifications...
    mplayer "$NAME"
    exit 0
fi

if [ $# -eq 0 ]
then
    echo -n Please enter the name of the file: 
    read NAME
else
    NAME=$1
fi

echo Opening $NAME ...
PARAMS=$(mplayer -nosound -vo null -really-quiet -ss 01:00:00 -identify "$NAME" | awk '/ID_VIDEO_WIDTH/ { print substr( $PARAMS, 16, length($PARAMS) ) } /ID_VIDEO_FPS/ { print substr( $PARAMS, 14, length($PARAMS) ) } /ID_VIDEO_BITRATE/ { print substr( $PARAMS, 18, length($PARAMS) ) }')

BITRATE=`echo $PARAMS | cut -d " " -f 1`
WIDTH=`echo $PARAMS | cut -d " " -f 2`
FPS=`echo $PARAMS | cut -d " " -f 3 | cut -c-2`

echo -n Video width is $WIDTH, video bitrate is $BITRATE, video fps is $FPS

if [ $FPS -gt 25]
then
	HARD="hard"
else
	HARD=""
fi

if [ $FPS -lt 15 -o $BITRATE -lt 500000 ]
then
    echo -n ... playing file with original resolution
    mplayer -quiet -framedrop -noslices "$NAME"
    exit 0
fi

FAST="fast:"
MAX_WIDTH=800
if [ $BITRATE -lt 650000 ]
then
	if [ $WIDTH -gt 800 ]
	then
	    FULL=1
            echo -n ... reducing resolution to 1/2 of the original
    else
    	mplayer -quiet -"$HARD"framedrop -noslices "$NAME"
    	exit 0
    fi
else
	if [ $WIDTH -lt 800 ]
	then
		if [ $BITRATE -gt 65000 ]
		then 
			FULL=1
			echo -n ... reducing resolution to 1/2 of the original
		else 
			FULL=2
			echo -n ... reducing resolution to 1/4 of the original
		fi
	else
		if [ $WIDTH -gt `expr 4 \\* $MAX_WIDTH` -o $BITRATE -gt 3000000 ]
		then 
		    FULL=3
		    echo -n ... reducing resolution to 1/8 of the original
		elif [ $WIDTH -gt `expr 2 \\* $MAX_WIDTH` -o $BITRATE -gt 1024000 ]
		then
		    FULL=2
		    echo -n ... reducing resolution to 1/4 of the original
		elif [ $WIDTH -gt $MAX_WIDTH -o $BITRATE -gt 650000 ]
		then
		    FULL=1
		    echo -n ... reducing resolution to 1/2 of the original
		else 
		    FULL=0
		    FAST=""
		    echo ... playing file with original resolution
		fi
	fi
fi
mplayer -quiet -noslices -"$HARD"framedrop -lavdopts "$FAST"lowres="$FULL" "$NAME"

Last edited by iliaden; 2008-06-14 at 11:00.
 

The Following 2 Users Say Thank You to iliaden For This Useful Post:
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#62
I finally tried your script (v 0.4) tonight. I pasted from your message into a file I named /usr/bin/optmplayer

The file was a half-hour TV show. I did not record it or transcode it.

I used tab completion on a file name with spaces, so it automatically backslash-escaped the name. Let's say the name was "Your Big Video File.avi", so it was displayed on the command line as Your \Big \Video \File.avi

I got two errors immediately:
sh: Big: unknown operand
sh: Big: unknown operand
It sits for a very long time at the
Opening Your Big Video File.avi...
,
spits out three errors,
[mpeg4 @ 0x46ade4]ac-tex damaged at 6 3
[mpeg4 @ 0x46ade4]Error at MB: 105
[mpeg4 @ 0x46ade4]concealing 715 DC, 715 AC, 715 MV errors
and then lists the width, bitrate, and fps.

(The bitrate seems ridiculously high (1240984), especially since the file plays with only a few stutters without optimization, and MPlayer itself later says it is 1108.3 kbps (135.3 kbyte/s). Also, when I play the file normally, the mplayer output includes all of that information, almost instantly, on the terminal right after it says "AVI file format detected". Is there any way to play 1 second of the file and capture and parse that output from MPlayer?)

I then get an error:
/usr/bin/optmplayer: line 43: [23: not found
and then it outputs, "reducing resolution to 1/2 of the original"

Ironically, the output still stutters a bit.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!

Last edited by qole; 2008-06-14 at 09:22.
 
iliaden's Avatar
Posts: 267 | Thanked: 50 times | Joined on Feb 2008 @ Montreal, Canada
#63
Hi,

just woke up, so give me 10 minutes to figure it all out.

first:
[mpeg4 @ 0x46ade4]ac-tex damaged at 6 3
[mpeg4 @ 0x46ade4]Error at MB: 105
[mpeg4 @ 0x46ade4]concealing 715 DC, 715 AC, 715 MV errors
the first two errors indicate that the file is corrupted (at the 105th megabyte). this is not the script's fault...

The bitrate seems ridiculously high (1240984)
this is a normal bitrate. of the 1108.3 kbps, I would estimate the audio stream to be 128 kbps, and the video stream to be ~950 kbps. those values are perfectly normal (and far from being the largest values possible)

I then get an error:
my mistake: forgot a space
if [$FPS -gt 25] , while it should be if [ $FPS -gt 25]

just corrected it in the precious post.


It sits for a very long time at the "Opening Your Big Video File.avi..."
this is interesting. I will look at it after work don't expect any updates from me in the next 14 hours (unless I get an illumination)
 

The Following User Says Thank You to iliaden For This Useful Post:
Posts: 96 | Thanked: 1 time | Joined on Jul 2007 @ Utah
#64
On my most recent flight, I was almost entirely unable to hear dialogue on videos in canola even with earphones in. Hell, it was difficult to hear them even in the concourse.
 
iliaden's Avatar
Posts: 267 | Thanked: 50 times | Joined on Feb 2008 @ Montreal, Canada
#65
@ midwinter:
I tried the -softvol-max 1000 on my n800. No success. Can anyone copy this, or is this a problem with my device?
 
Posts: 425 | Thanked: 132 times | Joined on Mar 2008 @ California
#66
Hey Guys

I'm back with fast internet at last! Looks like some good stuff has happened while I've been gone! Thanks iliaden!

I'll try your revised version tonight and mod it if necessary and host it up,

oh and i'll also try the volume thing out
__________________
Promises are like babies. Fun to make, but hard to deliver.

Warning: dates on calendar are closer than they appear.
 
iliaden's Avatar
Posts: 267 | Thanked: 50 times | Joined on Feb 2008 @ Montreal, Canada
#67
@ Josiah:
the -softvol-max filter was taken from the mplayer man page. It does not seem to work with the internet tablets.

Also, I will rewrite the first part of the script to make it better for the arguments. This would mean I will change from "if the first argument is..." to "if ANY argument is..."
the only way I see doing this is a loop, going from 1 to $#. anyone can suggest a more elegant way? If so, please do in the next 6-7 hours, since it is then that I will rewrite the script.

oh, and a thought just crossed my mind: would it be reasonable to start a new thread for this script, or should we just continue here, although it isn't [anymore] related to TCPMP. the only relation that still exists is that we're trying to implement most of tcpmp's features in one script.

Last edited by iliaden; 2008-06-15 at 21:20.
 
Posts: 425 | Thanked: 132 times | Joined on Mar 2008 @ California
#68
Hmmm I think by this time a new thread would be appropriate... Although the script really is still an Alpha product but if we make that clear to people then it should be fine.

And I believe that that's the best way to do it (looking at command line arguments)... Although, don't be too quick to take my word for it, I know next to nothing about shell scripting and I've only been able to come this far through the help of hours of google searches
__________________
Promises are like babies. Fun to make, but hard to deliver.

Warning: dates on calendar are closer than they appear.
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#69
the softvol-max parameter does work on the tablet. I think you have to use two extra parameters, "-softvol=yes" and maybe "-ao=sdl".

See these two threads.

If you start a new thread, maybe post a link to it from this thread.

ALSO: Is there any way to arbitrarily resize a video, or are you forced to halve or quarter the size?
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 
iliaden's Avatar
Posts: 267 | Thanked: 50 times | Joined on Feb 2008 @ Montreal, Canada
#70
thanks for the help (the "-softvol=yes" part mainly)

Is there any way to arbitrarily resize a video, or are you forced to halve or quarter the size?
the division by two (or four since it's both height and width) is the procedure for reducing a video size which would require the least CPU power. all that the computer does is to find the average color of four adjacent pixels, and display that color, stretched out onto these four pixels. Any other size (even 2/3) would require way more CPU, and we are trying to optimize playback.

I will look for an[other] way to keep the best video display under 100% cpu usage, but due to a lack of ideas, I am trying to make this manner the most optimal.
 
Reply


 
Forum Jump


All times are GMT. The time now is 02:04.