maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   Request: TCPMP (https://talk.maemo.org/showthread.php?t=19989)

josiahg777 2008-06-01 18:57

Re: Request: TCPMP
 
Quote:

Originally Posted by iliaden (Post 180784)
if you find one - tell me!
other calculators I miss: spacetime (great graphing tools, as well as the capacity to derivate, integrate, take limits and matrices)


The new Garnet VM supports mathLib so both easyCalc and spacetime should work now! I'm looking forward to trying them when I get home :)

Oh and thanks for the mplayer line! I no longer miss TCPMP :P
I bundled it into a quick dirty shell-script that I'll post as soon as I get home :) It's kind of a work in progress but it works :)

josiahg777 2008-06-02 00:47

Re: Request: TCPMP
 
Okay, here we go :)

Download, remove the ".txt" from the end, drop it in /usr/bin and chmod +x it :)

This script when called by mplayer-opt <FILENAME> will read the size of the video and choose the appropriate low-res for it. It will then echo what resolution it chose and then call mplayer with the the optomized flags (-hardframedrop -noslices etc).

It's a work in progress and I plan on adding options to it and maybe some better optomizations if I can find them. It's also my first shell script ever so any feedback/corrections/suggestions are more than welcome!

EDIT: UPDATE AVAILABLE, SCROLL DOWN

iliaden 2008-06-02 11:17

Re: Request: TCPMP
 
good idea; has a few small [or maybe crucial] problems:
1) you measure the video by the width ONLY. usually the problems occur not only due to the resolution, but also due to the bitrate and the amount of complete image changes per time (fast-paced action).
2) just for me:
Code:

-lavdopts "$FAST"lowres="$FULL"
does the -lavdopts fast actually help? I never noticed any difference on all my videos.

3)
Code:

mplayer -really-quiet -noslices -hardframedrop -lavdopts "$FAST"lowres="$FULL" -vo omapfb "$NAME"
why the
Code:

-vo omapfb
?
is this really necessary? I never had any problems with the video decoder, and I thought that MPlayer usually choses optimally...

4)
Code:

if [ $WIDTH -gt 1600 ]
then setting lowres ON, 1/8 resolution
elif [ $WIDTH -gt 800 ]
then setting lowres ON, 1/4 resolution
elif [ $WIDTH -gt 400 ]
then setting lowres ON, 1/2 resolution
else setting lowres OFF
fi

the width of the screen is 800. not all the videos whose width is between 400 and 800 would lag. as I said, it also depends on the bitrate and the number of complete scene changes per second. Is there any way to check the bitrate of a file (and get the output usable in a script)? If so, the script could be enabled iff the video bitrate > ~900 kbps, or if the total bitrate > 1024kbps. And just to verify, these values sound reasonable to all?

oh, and one last thing:
Quote:

Known Issues: This script will not work with videos whose aspect ratio has not been declared
unless the video file is broken, how is this possible?

Jaffa 2008-06-02 12:08

Re: Request: TCPMP
 
Quote:

Originally Posted by iliaden (Post 187914)
Is there any way to check the bitrate of a file (and get the output usable in a script)?

Yes, tablet-encode does exactly that: see the mediaInfo() function in https://garage.maemo.org/plugins/scm...74&view=markup

HTH,

Andrew

josiahg777 2008-06-04 06:57

Re: Request: TCPMP
 
Quote:

Originally Posted by iliaden (Post 187914)
does the -lavdopts fast actually help? I never noticed any difference on all my videos.

I don't actually know if it helps or not, it was suggested in the MPlayer documentation and it certainly can't hurt. The MPlayer documentation does say that it will only make a difference using some MP4 and .H264 codecs.

Quote:

why the
Code:

-vo omapfb
?
Hmmm... Good point. I think omapfb is the default anyway. The only reason it's still there is because I was experimenting with different video outs and ended up just setting it back to omapfb. It's been removed.

Quote:

the width of the screen is 800. not all the videos whose width is between 400 and 800 would lag.
This is very true. I was simply following the guidelines for video encoding posted here: http://maemo.org/community/wiki/VideoEncoding/
Feel free to suggest a better sliding scale :)

Quote:

Is there any way to check the bitrate of a file (and get the output usable in a script)?
Yes, actually, it's quite easy. Just add the following to the awk line:
Code:

/ID_VIDEO_BITRATE/ { print substr( $0, 18, length($0) )
I'm adding support for this to the script, I don't quite know what to do with it though. I added it as a setting to determine the threshold resolution for resizing the video. I'm not entirely convinced this is the correct way to implement it.

Quote:

If so, the script could be enabled iff the video bitrate > ~900 kbps, or if the total bitrate > 1024kbps. And just to verify, these values sound reasonable to all?
I don't actually have much experience with bitrate values but sure, I'll go ahead and add these.
EDIT: I also read in the video's FPS but I don't currently do anything with it. What should I do with it?

Quote:

oh, and one last thing:
unless the video file is broken, how is this possible?
I don't know actually... But -lavdopts lowres refused to re-size some of the videos I downloaded (for reference they were Apple TV ads) complaining that "No suitable aspect ratio was found". Hence, I stuck that line in to cover my butt.

Okay, here's version 0.2: mplayer-opt
I updated the link in the previous post as well.

I really need to learn about debian packaging so I can bundle this into an installable .deb

bunanson 2008-06-04 07:35

Re: Request: TCPMP
 
I ran it on xterm, /bin/ash: illegal option -

?

n810/2008OS

bun

josiahg777 2008-06-04 07:54

Re: Request: TCPMP
 
Crap! That'll teach me to upload stuff at one in the morning. Sorry about that, I fixed the error :) It should work fine now :)

bunanson 2008-06-04 07:57

Re: Request: TCPMP
 
For some reason, I can only copy your script and make one out of it. Your link does not seem to be able to dl, or, even worst, I do not know how to dl from your link :)

I redl/rerun again, and this time...........same error. Sorry,


bun

josiahg777 2008-06-04 08:04

Re: Request: TCPMP
 
EDIT: Okay try this one: mplayer-opt
Download and run:

tar -xzvPf Mopt.tar

on it :)
Then:
cd /usr/bin
chmod +x mplayer-opt

FIXED: Unfortunately it's my server's problem :( I don't own the webspace directly, I sublease it from one of my friends so I don't have permission to fix it. Try right clicking on it and selecting "Save as" ?

iliaden 2008-06-04 11:12

Re: Request: TCPMP
 
I believe that in the code you are using, FPS should not matter.
I experimented a bit with -framedrop and -hardframedrop, while keeping an eye on the original FPS. here's what I got:
- on low bitrate videos, all FPS play well, and all the slightest lags can be removed by -framedrop.

- on high bitrate videos:
1) -framedrop increases performance, reducing the lag, but not always entirely
2) -harframedrop reduces the lag even further, but OFTEN screws up colors, by keeping the previous ones.

now, concerning FPS: unless the video has been anyhow converted, It's between 27 and 30 FPS. MPlayer -quiet -framedrop would play all of those videos, with the bitrate < 900kbps without any problem. The problem only occurs with the videos with actions scenes, with a larger amount of key frames (those that need to be loaded entirely, not just the modifications to the previous scene). I have no clue how to determine this in a file, specially if it's only a small segment of it. The theoretical ideal would be that the mplayer parameters would change in the middle of the clip, but this IS impossible.

my suggestion (made at 7 am, might be crazy):
- if the video has already been somehow converted (i.e. framerate < 12 fps), just run mplayer -quiet -framedrop file
- if the video has not yet been converted:
- check bitrate. if < 750 bps, "mplayer -quiet -framedrop"
if 750 > < 900, look at resolution. if width > 530, add lowres=1
if width < 530, "mplayer -quiet -framedrop"
if > 900, look at resolution. if width > 800, add lowres, depending on bitrate
if width < 800, use lowres=1|2, depending on bitrate.

this idea sounds to create quite a long code, yet I can't yet figure out how to place a cycle, since the requirements are different for each step.
anyways, does this idea sounds to optimize something?

Ilia

iliaden 2008-06-04 11:53

Re: Request: TCPMP
 
off topic:
Quote:

Originally Posted by josiahg777 (Post 187742)
The new Garnet VM supports mathLib so both easyCalc and spacetime should work now! I'm looking forward to trying them when I get home :)

I installed mathlib and spacetime on Garnet VM. DOES NOT WORK (well, it does, just there is no keyboard display, needed to enter everything (I need it mostly for calculus, so no derivatives, integrals, limits...))

josiahg777 2008-06-05 03:42

Re: Request: TCPMP
 
Hmmmm sucks about spacetime.

And yeah that sounds pretty reasonable... I don't exactly know how to implement it in a particularly elegant way either... I've been programming for a little while but I've never touched UNIX before this attempt at a script... I think we're onto something here though. I'll touch up the script tomorrow, I've got studying to do tonight :/ But I think I can work your suggestions in pretty well.

One request though... Would it be possible for you to test it as it is right now with a bunch of videos and look for a specific error? I get an error "sh not found: <SECOND WORD OF MULTIPLE WORD FILENAME>" And I have no idea where it comes from. It seems to be reported BEFORE any of my code is invoked. Also, if anyone with more UNIX experience could look into it that'd be much appreciated :)

Thanks :)

iliaden 2008-06-05 14:46

Re: Request: TCPMP
 
sorry, can't try this right now, will do a bit later (tomorrow most probably). just leave the script in the archive.
I do have a hunch though: if you have a filename, say "movie number 1.avi", with spaces, when you enter the path, it would look like:
"/path/to/clip/movie\ number\ 1.avi" the space character is entered as "\ ". could this be the problem?

josiahg777 2008-06-05 19:07

Re: Request: TCPMP
 
Quote:

"/path/to/clip/movie\ number\ 1.avi" the space character is entered as "\ ". could this be the problem?
I had originally had this thought too, but even when I'm careful about typing the file name in, and even when I use tab-completion to input the file name I still get the same error :(

I'll take a look at it tonight and hopefully post up a new version :) Many thanks for your interest and suggestions!!

josiahg777 2008-06-07 04:15

Re: Request: TCPMP
 
Alrighty :) here we go :)

Download here then untar by
tar -xzvPf Mopt.tar

Changelog:

Modified script to make decisions based on bitrate as well as resolution
Gave proper credit to iliaden as one of the authors

iliaden 2008-06-08 16:56

Re: Request: TCPMP
 
hi,

I don't really think that this credit is "proper". I didn't write any code myself (since I cannot post it on some site for everyone), so it's not the best idea. you could put me under "ideas contributions". And it would look nicer if you wrote my name, not the nickname: Ilia Denotkine. guess where the nick came from ;)

Code:

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

code looks good. just for me, to make sure: the file you enter would be with or without the path, and if without, is the default root, user folder or the path where you are?

Code:

if [ $FPS -lt 12 -o $BITRATE -lt 750 ]
then
    mplayer -quiet -framedrop "$NAME"
    exit 0
fi

not "mplayer -quiet -framedrop -noslices "$NAME""

next, the bitrate is in what, bytes or kilobytes per second?
Code:

if [ $BITRATE -lt 16000 ]
elif [ $BITRATE -lt 128000 ]

128mbps or 128kbps. one seems to be INCREDIBLY large, the other one extremely low. could you clarify this please?

and one last comment: the difference between -framedrop and -hardframedrop should be determined by the bitrate and/or fps, not the ORIGINAL resolution.
maybe it's better to write:
Code:

if $FPS -gt 25
    $FRAMEDROP="hardframedrop"
    REST OF THE CODE HERE (the optimizations you wrote, this "if" thus remains independent of the rest"
else
    $FRAMEDROP="framedrop"
    REST OF THE CODE (or a simple goto would do the trick here in order not to rewrite)
fi

looks good?

josiahg777 2008-06-08 17:51

Re: Request: TCPMP
 
Quote:

Originally Posted by iliaden (Post 189831)
I don't really think that this credit is "proper". I didn't write any code myself (since I cannot post it on some site for everyone), so it's not the best idea. you could put me under "ideas contributions". And it would look nicer if you wrote my name, not the nickname: Ilia Denotkine. guess where the nick came from ;)

I still believe It's proper :) You've contributed just as much to this as I have :) And my apologies for not putting in your full name, I had no way of accessing it or knowing it (The forum doesn't post it, I checked your profile before adding that line) but I'd be more than happy to change this in the next version

Quote:

code looks good. just for me, to make sure: the file you enter would be with or without the path, and if without, is the default root, user folder or the path where you are?
The path that gets entered here is the same as if you had entered it on the command line and just gets passed to MPlayer in the end so an absolute path or a relative path will work equally well. The only difference is you do NOT have to escape space characters because it gets read as a full string

Quote:

next, the bitrate is in what, bytes or kilobytes per second?
MPlayer reads video bitrate in bytes per second. Please suggest a better value, I'm absolutely clueless what bitrates to use as delimeters. I was actually following the "standard" bitrates from http://en.wikipedia.org/wiki/Bit_rate
for lack of a better reference :P

Quote:

and one last comment: the difference between -framedrop and -hardframedrop should be determined by the bitrate and/or fps, not the ORIGINAL resolution.
maybe it's better to write:
Code:

if $FPS -gt 25
    $FRAMEDROP="hardframedrop"
    REST OF THE CODE HERE (the optimizations you wrote, this "if" thus remains independent of the rest"
else
    $FRAMEDROP="framedrop"
    REST OF THE CODE (or a simple goto would do the trick here in order not to rewrite)
fi

looks good?
Yeah that sounds very reasonable, I'll make sure and change this in the next version... Although having been well disciplined by my CompSci professors I might have an allergic reaction to a "goto" statement :D lol I'll see what I can do with it.

With respect to the next version I'm going out of town this afternoon and I won't be home until late Saturday night so I'm probably not going to be able to work on this and I definitely won't be able to upload anything. I'll try and get the next version out by next Sunday afternoon though :) Sorry about that.

You're more than free to edit the code however you like, if you'll just email me the edited code I'd be more than happy to tar it up (or you can do it, either way) and host it on my webspace :) My email address is josiahgaskin@gmail.com I usually reply to email the same day, same with PMs in this forum.

bunanson 2008-06-09 02:30

Re: Request: TCPMP
 
Crashed.

Report:
Opening /media/mmc1/Jsu.m4v ...
Video width is 640, video bitrate is 0, video fps is 29
MPlayer 1.0rc1-maemo.27.n8x0 (C) 2000-2006 MPlayer Team
CPU: ARM
Internet Tablet OS version: RX-34+RX-44_2008SE_2.2007.51-3_PR_MR0
Menu inited: /etc/mplayer/menu.conf

Playing /media/mmc1/Jsu.m4v.

Quicktime/MOV file format detected.
VIDEO: [avc1] 640x480 24bpp 29.970 fps 0.0 kbps ( 0.0 kbyte/s)
[omapfb] Nokia N800/N810 hardware detected
[omapfb] tearsync is enabled
================================================== ========================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
================================================== ========================
================================================== ========================
Trying to force audio codec driver family dspmp3...
Trying to force audio codec driver family libmad...
Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio) decoder)
================================================== ========================
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
AO: [sdl] 44100Hz 2ch s16le (2 bytes per sample)
Starting playback...
VDec: vo config request - 640 x 480 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
VO: [omapfb] 640x480 => 640x480 Planar YV12 [fs] [zoom]
[omapfb] ARM JIT scaler (quality=2): 640x480 YV12 => 640x480 YUV420
__________________________________________________ ___
...
Movie-Aspect is undefined - no prescaling applied.
VO: [omapfb] 640x480 => 640x480 Planar YV12 [fs] [zoom][omapfb] ARM JIT scaler (quality=2): 640x480 YV12 => 640x480 YUV420
process 1946: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
D-Bus not built with -rdynamic so unable to print a backtrace


MPlayer interrupted by signal 6 in module: stop_maemo_screensaver
- MPlayer crashed. This shouldn't happen.
It can be a bug in the MPlayer code _or_ in your drivers _or_ in your
gcc version. If you think it's MPlayer's fault, please read
DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and
won't help unless you provide this information when reporting a possible bug.
/usr/bin # mplayer-opt /media/mmc1/Jsu.m4v >/media/mmc1/mopt1.txt
[MENU] Can't open menu config file: /home/user/.mplayer/menu.conf
ISO: Unknown File Type Major Brand: M4V
process 1964: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
D-Bus not built with -rdynamic so unable to print a backtrace


MPlayer interrupted by signal 6 in module: stop_maemo_screensaver
- MPlayer crashed. This shouldn't happen.
It can be a bug in the MPlayer code _or_ in your drivers _or_ in your
gcc version. If you think it's MPlayer's fault, please read
DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and
won't help unless you provide this information when reporting a possible bug.



__________________________________________________ ___

Suggestions?


bun

iliaden 2008-06-09 03:30

Re: Request: TCPMP
 
@bunanson: well, analyze this logically:
1) the script (which I presume you have read) will simply output the "mplayer -noslices -framedrop /media/mmc1/Jsu.m4v", since the bitrate is 0. This narrows the problem down to MPlayer.
the fact that mplayer determined the bitrate to be 0 shows two possibilities: 1- mplayer is poorly written and 2- the file is somewhat corrupted.
Does this problem occur with every single file or just this one?

@josiahg777:
no optimization needed (based on a n8x0, OS2008, and no background, cpu-eating processes) for bitrate <650kbps (650000bps) here are my suggested values:
Code:

if [ $BITRATE -lt 650000 ]
then
        if [ $WIDTH -gt 800 ]
        then
            FULL=1
            echo ...setting lowres ON, 1/2 resolution
    else
            mplayer -quiet -framedrop -noslices "$NAME"
            exit 0
    fi
else
        if [ $WIDTH -lt 800 ]
        then
                if [ $BITRATE -gt 65000 ]
                then
                        FULL=1
                        echo ...setting lowres ON, 1/2 resolution
                elif [ $BITRATE -gt 1024000 ]
                then
                        FULL=2
                        echo ...setting lowres ON, 1/4 resolution
                else
                        echo ...playing video with original resolution
                        mplayer -quiet -framedrop -noslices "$NAME"
                fi
        else
                if [ $WIDTH -gt `expr 4 \\* $MAX_WIDTH` -o $BITRATE -gt 3000000 ]
                then
                    FULL=3
                    echo ...setting lowres ON, 1/8 resolution
                elif [ $WIDTH -gt `expr 2 \\* $MAX_WIDTH` -o $BITRATE -gt 1024000 ]
                then
                    FULL=2
                    echo ... setting lowres ON, 1/4 resolution
                elif [ $WIDTH -gt $MAX_WIDTH -o $BITRATE -gt 650000 ]
                then
                    FULL=1
                    echo ... setting lowres ON, 1/2 resolution
                else
                    FULL=0
                    FAST=""
                    echo ... setting lowres OFF
                fi
        fi
fi

to e certain no lag occurs, the values of all the bitrates could be 50000 lower, but the values I entered seem good.
you agree?

Ilia

qole 2008-06-11 18:32

Re: Request: TCPMP
 
I'm subscribing here because this seems to be where the exciting developments in smooth video playback on the N800 are happening! Now to bundle this up into a gui so the user doesn't need to see all of this. Perhaps you could use pipeline's dbus-switchboard hack so you can run your script when the user clicks on any video file in Filemanager.

EDIT: Fixed link. Sorry!

iliaden 2008-06-11 23:46

Re: Request: TCPMP
 
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]:
Quote:

Originally Posted by qole (Post 162227)
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"


qole 2008-06-14 09:16

Re: Request: TCPMP
 
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:
Quote:

sh: Big: unknown operand
sh: Big: unknown operand
It sits for a very long time at the
Quote:

Opening Your Big Video File.avi...
,
spits out three errors,
Quote:

[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:
Quote:

/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.

iliaden 2008-06-14 11:00

Re: Request: TCPMP
 
Hi,

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

first:
Quote:

[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...

Quote:

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)

Quote:

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.


Quote:

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)

midwinter 2008-06-15 00:02

Re: Request: TCPMP
 
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 2008-06-15 00:17

Re: Request: TCPMP
 
@ midwinter:
I tried the -softvol-max 1000 on my n800. No success. Can anyone copy this, or is this a problem with my device?

josiahg777 2008-06-15 19:43

Re: Request: TCPMP
 
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

iliaden 2008-06-15 21:17

Re: Request: TCPMP
 
@ 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.

josiahg777 2008-06-15 21:26

Re: Request: TCPMP
 
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

qole 2008-06-16 16:28

Re: Request: TCPMP
 
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?

iliaden 2008-06-16 20:44

Re: Request: TCPMP
 
thanks for the help (the "-softvol=yes" part mainly)

Quote:

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.

josiahg777 2008-06-16 20:48

Re: Request: TCPMP
 
Quote:

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?
We'll be sure and link to it :)

And yes, mplayer lets you set the x/width value, and then it will set the y/height value according to the aspect ratio, or you can do it the other way around, or you can set the x and the y and ignore the aspect ratio to stretch the video any way you want. It's a very versatile program. But as iliaden mentioned this takes far more CPU than pixel doubling or quadrupling which is hardware accelerated.

On this note, I'm wondering if we should put in a feature that comes from the other end? For a really low resolution video could we call mplayer's built-in deinterlacing/postprocessing functions perhaps?

EDIT: I'm hoping to post up a new version with iliaden's changes tonight, my apologies for the wait

qole 2008-06-16 20:56

Re: Request: TCPMP
 
I was thinking that you could always resize to 240 height x whatever width and then pixel-double it. The problem with simply halving the resolution is that if the resolution is less than 480 high, the halved resolution will be very low, and that looks noticeably ugly. But if you aim for 240 high, then the video will always be exactly doubled, and that looks fine.

qole 2008-06-18 16:36

Re: Request: TCPMP
 
Pipeline has a much more robust mime-handler system in this thread. He started a new thread and I didn't notice. This is why it is important to put a forwarding address at the end of the old thread when you're starting a new one!

josiahg777 2008-06-19 18:01

Re: Request: TCPMP
 
Okay, the new version is hosted, sorry it took me so long.

Instructions are as before:
Download: Mopt.tar
Untar with
tar -zxvPf Mopt.tar
Then make executable:
chmod +x /usr/bin/mplayer-opt

This version is identical to the last one iliaden posted, I'm really sorry I haven't been able to make any changes, my schedule is kind of hectic right now.

TODO:
--FIX: Script now crashes if not given a filename as a command line paramenter
--ADD: Support needed for post-processing low-res videos
--ADD: mime-handling needed

iliaden 2008-06-19 22:19

Re: Request: TCPMP
 
Sorry guys, I'm a bit busy these days. I will have time to work on this only starting sunday... sorry for not being able to help much right now.

TODO (added):
- ADD: parameters to work if entered in any order (not just the first one) [working on it... almost done!]
- ADD: parameter to define output resolution (both halved, quartered, or arbitrary) [I will do it]
- ADD: GUI (anyone ???)
- ADD: *.deb installer packaging

josiahg777 2008-06-20 00:47

Re: Request: TCPMP
 
I'll see what I can do about deb packaging... I've been meaning to learn about that :P

And do we really need a GUI? Maybe so... I'll take a look at the source for the existing Mplayer GUI and see if we can maybe make it point to mplayer-opt instead.

I think I'll have some time for these two tomorrow, but I can't make any promises :D

qole 2008-06-20 04:30

Re: Request: TCPMP
 
Quote:

Originally Posted by josiahg777 (Post 193698)
I'll see what I can do about deb packaging... I've been meaning to learn about that :P

Check out PyPackager. It really is an easy way to make a .deb package. I just did my first package yesterday.

josiahg777 2008-06-21 00:50

Re: Request: TCPMP
 
Status update:

FIXED: Script will not crash anymore if it is invoked without any arguments

Added: I had forgotten to add a test to see whether or not the video file actually exists. This is now handled more elegantly.

Still working on:
I'm (slowly) learning PyPackager, but the generated .deb it created for me won't install due to an "Incompatible application package" error. Grrr... I'll work on this later tonight or tomorrow, I need a break.

So, all this said and done, I'll upload an updated version by tomorrow night :)

iliaden 2008-06-21 02:37

Re: Request: TCPMP
 
quick update (for me)

Quote:

FIXED: Script now crashes if not given a filename as a command line paramenter
you mean that it doesn't crash anymore...

2: I'm going to my brother's after prom. If I am alive sunday, I will post a new part of the script. otherwise, my alcohol system would be cleared of blood...

qwerty12 2008-06-21 07:07

Re: Request: TCPMP
 
Quote:

Originally Posted by josiahg777 (Post 194006)
I'm (slowly) learning PyPackager, but the generated .deb it created for me won't install due to an "Incompatible application package" error. Grrr... I'll work on this later tonight or tomorrow, I need a break.

Make the section user/multimedia

(or whatever the equivalent is, I use dh_make/debhelper and dpkg-buildpackage in scratchbox)


All times are GMT. The time now is 00:28.

vBulletin® Version 3.8.8