Author Topic: Mplayer Performance Tweaks  (Read 4195 times)

kkazakov13

  • Sr. Member
  • ****
  • Posts: 408
    • View Profile
Mplayer Performance Tweaks
« on: February 14, 2007, 05:01:17 pm »
Quote
kkazakov13: I notice you have a 3200 also, may  I ask how you encode your videos and what mplayer parameters you use when playing them? I always have terrible trouble with this.
[div align=\"right\"][{POST_SNAPBACK}][/a][/div]

That's my script I wrote for converting movies:

Code: [Select]
#!/bin/bash

# default values
MAX_WIDTH=640
MAX_HEIGHT=480

AUDIO_BITRATE=48000
VIDEO_BITRATE=500

# rotate mode
ROTATE=1

# running priority
PROCESS_PRIORITY="-15"

# video/audio setup
VIDEO="lavc"
VIDEO_CODEC="mpeg4"
AUDIO="mp2:abitrate=128"
LAMEOPTS="cbr:br=128:mode=3"

# default values
WANT_SCALE="Y"
#WANT_ROTATE="Y"

# for subtitles only
SUB_ENCODING="cp1251"

# for cropping, comment if none
#CROP="640:336:0:90"

# settings end here, don't modify below

INFILE="$1"
OUTFILE="$2"
SUBFILE="$3"

INFO_LINE=`mplayer "$1" -vo somethingtofail 2>/dev/null | grep ^VIDEO`
INPUT_RES=`echo "$INFO_LINE" | gawk -F" " '{print $3}'`

if [ -z "$INPUT_RES" ]; then
    echo ""
    echo "*** ERROR: Could not get input resolution, file broken/not existing?"
    echo ""
    exit
fi

#quick & durty
if [ -z "$OUTFILE" ]; then
    OUTFILE="z-$1"
fi

if [ ! -z "$SUBFILE" ]; then
    SUB=" -sub $SUBFILE "
fi


INPUT_WIDTH=`echo "$INPUT_RES" | awk -Fx '{print $1}'`
INPUT_HEIGHT=`echo "$INPUT_RES" | awk -Fx '{print $2}'`

echo "File     : $INFILE"

#echo "$INFO_LINE"
echo "Input    : $INPUT_RES"

#that's multiply factor
FACTOR=`echo "scale = 5; $INPUT_WIDTH / $INPUT_HEIGHT" | bc`

#it's absolute value
FABS=`echo " $FACTOR > 1 " | bc`


# calculate the new size
if [ $FABS -eq "1" ]; then
    WIDTH=$MAX_WIDTH
    HEIGHT=`echo "scale = 0; $MAX_WIDTH / $FACTOR / 1 " | bc`
else
    HEIGHT=$MAX_HEIGHT
    WIDTH=`echo "scale = 0; $MAX_HEIGHT * $FACTOR / 1 " | bc`
fi

# check if width is even/or not
CHECK=`echo " $WIDTH / 2 " | bc`
CHECK=`echo " $CHECK * 2 " | bc`
if [ $CHECK -ne $WIDTH ]; then
    WIDTH=$CHECK
fi

# check if height is even/or not
CHECK=`echo " $HEIGHT / 2 " | bc`
CHECK=`echo " $CHECK * 2 " | bc`
if [ $CHECK -ne $HEIGHT ]; then
    HEIGHT=$CHECK
fi

# check boundaries
if [ $HEIGHT -ge $MAX_HEIGHT ]; then
    HEIGHT=$MAX_HEIGHT
fi

if [ $WIDTH -ge $MAX_WIDTH ]; then
    WIDTH=$MAX_WIDTH
fi

echo "Output   : $WIDTH""x""$HEIGHT"

CMD1="nice -19 mencoder $INFILE -ovc $VIDEO -lavcopts vcodec=$VIDEO_CODEC:vbitrate=$VIDEO_BITRATE:vpass=1 -lameopts $LAMEOPTS"


if [ ! -z "$WANT_SCALE" ] && [ -z "$WANT_ROTATE" ]; then
    CMD1="$CMD1 -vf scale=$WIDTH:$HEIGHT"
    
    if [ ! -z "$CROP" ]; then
    CMD1="$CMD1,crop=$CROP "
    else
    CMD="$CMD1 "
    fi
    
fi

if [ ! -z "$WANT_ROTATE" ] && [ -z "$WANT_SCALE" ]; then
    CMD1="$CMD1 -vf rotate=$ROTATE "
fi

if [ ! -z "$WANT_ROTATE" ] && [ ! -z "$WANT_SCALE" ]; then
    CMD1="$CMD1 -vf scale=$WIDTH:$HEIGHT,rotate=$ROTATE "
fi

CMD1="$CMD1 -oac lavc -lavcopts acodec=$AUDIO -o $OUTFILE $SUB -subcp $SUB_ENCODING $AUDIO_RATE $ADD_EXTRA"
CMD2=`echo "$CMD1" | sed s/vpass=1/vpass=2/`

#echo $CMD1
#exit

$CMD1
$CMD2


echo "Done."
echo ""

Note: You can comment $CMD2 , as this is the second pass. Not that big difference in the size/quality, anyway.

And that's my custom mplayer i use:

[a href=\"http://z.drun.net/packages/mplayer-2in1_1.0_armv5tel.ipk]http://z.drun.net/packages/mplayer-2in1_1.0_armv5tel.ipk[/url]

It installs 3 versions of mplayer , which has different capabilities.


My /etc/mplayer/mplayer.conf:

Code: [Select]
framedrop = yes
cache = 1024
dr = yes
af=resample=44100
vo = bvdd
really-quiet = yes
font = /usr/share/mplayer/arial-36/font.desc

If the movie requires more cpu power than normal, I do it like this:

using few scripts, which can be aliases:

beware that those scripts will NOT work on non-3100/3200

cpu4 :
Code: [Select]
#!/bin/sh

echo '2000210' > /proc/zaurus/CCCR;sleep 1; echo '0a' > /proc/zaurus/VCORE; echo '416'

cpu5 :
Code: [Select]
#!/bin/sh

echo '2000214' > /proc/zaurus/CCCR;sleep 1; echo '0c' > /proc/zaurus/VCORE; echo '520'

cpu6 :

Code: [Select]
#!/bin/sh

echo '2000218' > /proc/zaurus/CCCR;sleep 1; echo '0e' > /proc/zaurus/VCORE; echo '624'

few additional scripts that help me:

mplayer_o :

Code: [Select]
#!/bin/sh

cpu5
/usr/bin/mplayer "$@"
cpu4

mplayer_oo :

Code: [Select]
#!/bin/sh

cpu6
/usr/bin/mplayer "$@"
cpu4


--------
Starting mplayer with 520 mhz:

Code: [Select]
mplayer_o /path/to/movie.avi
in 624 mhz:

Code: [Select]
mplayer_oo /path/to/movie.avi

_always_ in console. I hate to say it but doesn't work in X flawlessly. X always takes some CPU time.

that's all folks

I really watch a lot of movies like this  Specially when I can't on the big screen, of course.
« Last Edit: February 15, 2007, 07:23:23 am by kkazakov13 »
SL-C3200 ** FOR SALE :( **
https://www.oesf.org/forum/index.php?showtopic=25969

Canon K30225 CF wireless card
Taxan iTax-LAN10 wired card
My packages for customized pdaXrom beta 3

zi99y

  • Sr. Member
  • ****
  • Posts: 282
    • View Profile
Mplayer Performance Tweaks
« Reply #1 on: February 14, 2007, 05:40:33 pm »
This is just what I needed, I'll give it a go with a few avi's.

Ta v much.

psycoman

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://www.tuxforum.com.br
Mplayer Performance Tweaks
« Reply #2 on: February 15, 2007, 05:12:08 am »
kkazakov13,

i make some changes in cpuoverclock.py and it integrated in pdaxii13 5.2+

usage:

call cpuoverclock.py wity -c options to see a list of frequencies
Code: [Select]
root-:) cpuoverclock.py -c
initializing Terminal interface
Model: SL-C3200
Freq.: 416Mhz
List: 0-104Mhz 1-208Mhz 2-312Mhz *3-416Mhz 4-520Mhz 5-624Mhz
root-:)

To Change frequence use the option -i <index of freqs>
Code: [Select]
root-:) cpuoverclock.py -c -i 5
Old Freq: 3 - 416Mhz
New Freq: 5 - 624Mhz
root-:)

you can download it here: hxxp://zaurus.servehttp.com/feed/patchs/cpuoverclockt.py

Please, let me know any bug.
« Last Edit: February 15, 2007, 06:31:48 am by psycoman »

kkazakov13

  • Sr. Member
  • ****
  • Posts: 408
    • View Profile
Mplayer Performance Tweaks
« Reply #3 on: February 15, 2007, 06:51:40 am »
I don't really want to execute *python* scripts to actually echo some stuff in /proc ... my scripts are fine for me , executing them from console. If they don't work on your machine, then ok, use cpuoverclock.py
SL-C3200 ** FOR SALE :( **
https://www.oesf.org/forum/index.php?showtopic=25969

Canon K30225 CF wireless card
Taxan iTax-LAN10 wired card
My packages for customized pdaXrom beta 3

zi99y

  • Sr. Member
  • ****
  • Posts: 282
    • View Profile
Mplayer Performance Tweaks
« Reply #4 on: February 20, 2007, 08:42:19 am »
I've not been able to run your script as I've had some trouble with my debian server and can't get mencoder to run, maybe a codec issue.. I intend to sort it when I have full gui access sometime.

Anyway, I've been using this converter for windows (http://www.erightsoft.com/SUPER.html) which is pretty damn good as it goes. I've not found any good encoding combinations that run smoothly for 640x480, so I've been encoding all my videos at 320x240

The script I use to play the vids is as follows:

Code: [Select]
mplayer -vo bvdd -fbmode qvga -ao oss -ac mad -vm -x 320 -y 240 "$*"
And the results are VERY good, I get no slowdown issues, runs smoothly because it's using the BVDD driver. Note that you cannot use the BVDD driver when xrandr resizes the screen to this resolution, so you have to do it in mplayer.

The problem with this is; when you start the script, the screen gets corrupted in a rather scary way before the video kicks in. Also when you quit playing the video, the screen remains black until it is refreshed (I switch to fullscreen in any app to restore it).

Anyone else use this method? I've been doing it quite a lot lately and doesn't seem to have damaged anything but I'd be mortified if it killed the screen....

kkazakov13

  • Sr. Member
  • ****
  • Posts: 408
    • View Profile
Mplayer Performance Tweaks
« Reply #5 on: February 20, 2007, 10:16:51 am »
Your way is setting 320x240 ... mine is 640x480. Of course for videos 320x240, in console, mplayer performance is the best.

for graphics one - i have the same problems as you, and basically prefer to go console for smoothest playback, without X involved
SL-C3200 ** FOR SALE :( **
https://www.oesf.org/forum/index.php?showtopic=25969

Canon K30225 CF wireless card
Taxan iTax-LAN10 wired card
My packages for customized pdaXrom beta 3

zi99y

  • Sr. Member
  • ****
  • Posts: 282
    • View Profile
Mplayer Performance Tweaks
« Reply #6 on: February 20, 2007, 10:20:29 am »
Did you try to run with my mplayer settings at 320x240? If so do you get the same graphical corruption ?

I'll give it a go without running X and see how much faster it is. Would rather not leave the desktop though.

kkazakov13

  • Sr. Member
  • ****
  • Posts: 408
    • View Profile
Mplayer Performance Tweaks
« Reply #7 on: February 20, 2007, 10:54:05 am »
I don't care much about the desktop - I prefer stability and smooth playback, without annoying crap like this. Anyway  - I can't alt+tab while watching movie, so where's the difference?
SL-C3200 ** FOR SALE :( **
https://www.oesf.org/forum/index.php?showtopic=25969

Canon K30225 CF wireless card
Taxan iTax-LAN10 wired card
My packages for customized pdaXrom beta 3

zi99y

  • Sr. Member
  • ****
  • Posts: 282
    • View Profile
Mplayer Performance Tweaks
« Reply #8 on: February 20, 2007, 10:57:49 am »
The difference for me is that I want to be able to suspend at a moments notice and pop the Z back in my pocket. If I was not in X I would have to wait for it to load before suspending - shutting down is out of the question!!

I'm still curious if anyone gets this graphic corruption and if it's anything to worry about hardware-wise...

Antikx

  • Hero Member
  • *****
  • Posts: 1147
    • View Profile
    • http://tyrannozaurus.com
Mplayer Performance Tweaks
« Reply #9 on: February 20, 2007, 02:59:30 pm »
I dont' recall getting the corruption before playing but I do remember seeing it after stopping the movie. I tend to play movies without X running though. It increases speed a bit too.
if you want to suspend in non-X windows, just type:
Code: [Select]
apm --suspendAfter you press enter you can close the lid with confidence that it will shut down.
Kanpai,
-Antikx (Twitter, Mugshot and PodNova)
C1000 - pdaXrom R198 (Celestial Environment)
tyrannozaurus.com
[img]http://www.tyrannozaurus.com/files/category_pictures/general_1.png\" border=\"0\" class=\"linked-sig-image\" /]
Zaurus news/blogs feed from Zaurus users
Free Windows, Linux, or Web RSS readers.
Featured pages at tyrannozaurus:
Sharp Petition, ScummVM, Cacko, pdaXii13, and Celestial Environment