[mythtv-users] Mplayer wrapper: semi-intelligent software scaling

Baxter Kylie baxter.kylie at gmail.com
Thu Jun 28 17:56:04 UTC 2007


Hi. I had need for a wrapper script for mplayer to handle
semi-intelligent scaling. Because none of the existing wrappers I had
found served my needs I wrote up my own and thought I'd share the
fruits of my labor, so to speak...

It's a wrapper for mplayer designed for use-scenarios where use of the
command line or gui isn't practical (eg, a mythbox). The solution it
provides is intelligent dynamic fullscreen software scaling that
adapts itself to the aspect ratio of the content so that it does not
attempt to scale to a resolution > than your display's (and thus warn
and instead default to a poor quality display native scale)

Caveats:
1) This is not meant for command-line kings who love to throw options
all around. I am assuming you have pre-determined use scenarios and
that those scenarios are captured in the form of config profiles. It
passes optional profiles and since profiles stack this should serve
most purposes.

In my case, for example, I have a profile for a largish pan -af (for 6
channel ogg) called ogg6 and, say, a filter chain for low-quality
video called lv. I can pass mplayer -profile ogg6,lv and it'll
activate the filters found in both. I also have a mythtv profile which
reads:

[mythv]
fs=1
zoom=1
quiet=1

(in keeping with the most commonly passed options when used with mythvideo).

Prior to using the wrapper my standard command line for play in
mythvideo was: 'mplayer -profile mythtv' and now it is  'mpwrapper.sh
-p mythtv'. Multiple profiles may be passed as either multiple
issuances of  '-p [profilename]' or comma separated as in '-p
mythtv,ogg6'

Some profiles may desire not to implement scaling. Those are capable
of being specified but you need to do so in the bash script itself (a
variable array at the top is there).

2) I took the liberty of defining that, with content > display
resolutions it should be assumed that this is not something that needs
any additional filtering so a -vf-clr statement prefixes the
downscale.

4) There's no error handling other than an exit, I took the easy way
with getopts so options must be given first (before the filename), and
I'd love to use the DISPLAY variable and xdpyinfo to grab the screen
resolution but my xdpyinfo isn't interested in working properly
(always displays max possible res -- I blame nvidia binary) so I
didn't bother finishing it, and I can't seem to count to four without
missing a step. ;-) What does this mean? I'm not a bash guru, genius,
acolyte, or even apprentice. I'm just a guy who had a need and taught
himself enough to get by.

If you have 'l33t haXor' skills, more power to you and feel free to
chop it up and spit a diff patch back at me. I have no delusions of
grandeur regarding my skills as a scripter but I also hope that
criticizm comes constructively. 'You suck.' isn't helpful and just
makes you out to be an ass. 'You suck but here's a patch that'll clean
it up...'  is, on the other hand, very welcome. ;-)

For everyone else, I hope this can be of some use. I wish I could
figure out how mplayer was getting the display resolution itself -- it
does it properly on my machines (where xdpyinfo fails) and I'd love to
use that method to set up the scale variables (and keep assignment of
the variables 'in-house' so to speak). It's just a wrapper and I'm not
going to be doing much in the way of 'support' so use at your own risk
but if you find yourself dissatisfied with your video quality and you
have a mixed bag of aspect ratios (and no desire to manually change
configs or profiles with each media file of an alternate aspect ratio)
give it a go.

So, without further ado... you'll find it attached.

~BK


More information about the mythtv-users mailing list