Author: duncan
Date: Mon Nov 5 02:29:08 2007
New Revision: 10076
Log:
[ 1825484 ] Plugin that forces the aspect ratio in mplayer
Plug-in from Gorka Olaizola added
Added:
branches/rel-1/freevo/src/video/plugins/mplayer_autoaspect.py (contents,
props changed)
Modified:
branches/rel-1/freevo/src/video/videoitem.py
Added: branches/rel-1/freevo/src/video/plugins/mplayer_autoaspect.py
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/video/plugins/mplayer_autoaspect.py Mon Nov
5 02:29:08 2007
@@ -0,0 +1,79 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# Forces the aspect ratio to the detected one.
+# -----------------------------------------------------------------------
+# $Id
+#
+# Notes: Forces the aspect ratio to the detected one by Freevo.
+#
+# Changelog
+#
+# 1.0
+#
+# Initial release
+#
+# Todo
+#
+# Add a menu to select an aspect ratio manually
+#
+# Activate by adding the following to local_conf.py:
+#
+# | plugin.activate('video.mplayer_autoaspect')
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with self program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
+
+import config
+import plugin
+import event as em
+
+class PluginInterface(plugin.ItemPlugin):
+ """
+ Forces the aspect ratio to the detected one by Freevo.
+ To activate add this to your local_conf.py:
+
+ | plugin.activate('video.mplayer_autoaspect')
+ """
+
+ def __init__(self):
+ """ Initialise the mplayer_autoaspect PluginInterface """
+ plugin.ItemPlugin.__init__(self)
+ self.plugin_name = 'mplayer_autoaspect'
+
+ self.args_def = config.MPLAYER_ARGS_DEF
+ self.player = None
+
+
+ def actions(self, item):
+ """ Perform the action add -aspect to the mplayer command line """
+ config.MPLAYER_ARGS_DEF = self.args_def
+
+ for p in plugin.getbyname(plugin.VIDEO_PLAYER, True):
+ if config.VIDEO_PREFERED_PLAYER == p.name:
+ self.player = p
+
+ if item.type == 'video' and self.player.name == 'mplayer':
+ ratio = item['mplayer_aspect']
+ if ratio:
+ config.MPLAYER_ARGS_DEF = self.args_def + ' -aspect ' + ratio
+ _debug_('Setting movie aspect to: %s' % ratio)
+
+ return []
Modified: branches/rel-1/freevo/src/video/videoitem.py
==============================================================================
--- branches/rel-1/freevo/src/video/videoitem.py (original)
+++ branches/rel-1/freevo/src/video/videoitem.py Mon Nov 5 02:29:08 2007
@@ -56,7 +56,7 @@
self.autovars = []
Item.__init__(self, parent)
self.type = 'video'
-
+
self.variants = [] # if this item has variants
self.subitems = [] # more than one file/track to play
self.current_subitem = None
@@ -83,8 +83,8 @@
self.set_url(url, info=parse)
if info:
self.info.set_variables(info)
-
-
+
+
# deinterlacing and related things
video_deinterlace = config.VIDEO_DEINTERLACE != None and
config.VIDEO_DEINTERLACE or False
self['deinterlace'] = video_deinterlace
@@ -94,7 +94,7 @@
video_field_dominance = config.VIDEO_FIELD_DOMINANCE != None and
config.VIDEO_FIELD_DOMINANCE or False
self['field-dominance'] = video_field_dominance
-
+
# find image for tv show and build new title
if config.VIDEO_SHOW_REGEXP_MATCH(self.name) and not self.network_play
and \
config.VIDEO_SHOW_DATA_DIR:
@@ -202,7 +202,7 @@
self.possible_player.sort(lambda l, o: -cmp(l[0], o[0]))
if len(self.possible_player) > 0:
self.player_rating, self.player = self.possible_player[0]
-
+
def id(self):
@@ -242,6 +242,19 @@
if aspect:
return aspect
+ if key == 'mplayer_aspect':
+ aspect = None
+ if self.info['aspect']:
+ aspect = str(self.info['aspect'])
+ aspect[:aspect.find(' ')].replace('/', ':')
+ else:
+ if self.info['width'] and self.info['height']:
+ ratio = float(self.info['width']) / self.info['height']
+ aspect = "%f" % ratio
+
+ if aspect:
+ return aspect
+
if key == 'runtime':
if self.info['runtime']:
@@ -302,7 +315,7 @@
"""
if not self.possible_player:
return []
-
+
if self.url.startswith('dvd://') and self.url[-1] == '/':
if self.player_rating >= 20:
items = [ (self.play, _('Play DVD')),
@@ -376,7 +389,7 @@
"""
self.play(menuw=menuw, arg='-cache 65536')
-
+
def play_alternate(self, arg=None, menuw=None):
"""
play and use maximum cache with mplayer
@@ -445,11 +458,11 @@
"""
if not self.possible_player:
return
-
+
# execute commands if defined
if config.VIDEO_PRE_PLAY:
os.system(config.VIDEO_PRE_PLAY)
-
+
# FIXME: There could be more than two players available
if alternateplayer:
self.possible_player.reverse()
@@ -629,7 +642,7 @@
i.name = Unicode(_('Play Title %d') % (titlenum+1))
items.append(i)
-
+
moviemenu = menu.Menu(self.name, items, umount_all = 1,
fxd_file=self.skin_fxd)
moviemenu.item_types = 'video'
self.menuw.pushmenu(moviemenu)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog