use ffmpeg2theora from Firefogg if possible

This commit is contained in:
j 2010-08-05 01:45:37 +02:00
parent 6821b93478
commit 9cf7c84558
2 changed files with 16 additions and 3 deletions

View file

@ -28,6 +28,7 @@ from twisted.web.resource import Resource, IResource
from twisted.web.static import File from twisted.web.static import File
from zope.interface import implements from zope.interface import implements
FFMPEG2THEORA = 'ffmpeg2theora'
STATUS_NEW=0 STATUS_NEW=0
STATUS_EXTRACTING=1 STATUS_EXTRACTING=1
@ -41,6 +42,7 @@ VIDEO_PROFILES = [
'96p', '96p',
] ]
class AspectRatio(fractions.Fraction): class AspectRatio(fractions.Fraction):
def __new__(cls, numerator, denominator=None): def __new__(cls, numerator, denominator=None):
if not denominator: if not denominator:
@ -63,7 +65,7 @@ class AspectRatio(fractions.Fraction):
def avinfo(filename): def avinfo(filename):
if os.path.getsize(filename): if os.path.getsize(filename):
p = subprocess.Popen(['ffmpeg2theora', '--info', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen([FFMPEG2THEORA, '--info', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
info, error = p.communicate() info, error = p.communicate()
#remove metadata, can be broken #remove metadata, can be broken
reg = re.compile('"metadata": {.*?},', re.DOTALL) reg = re.compile('"metadata": {.*?},', re.DOTALL)
@ -720,7 +722,8 @@ if __name__ == '__main__':
db = 'dev.sqlite' db = 'dev.sqlite'
db = sys.argv[1] db = sys.argv[1]
if os.path.exists(sys.argv[2]):
FFMPEG2THEORA = sys.argv[2]
port = 2620 port = 2620
interface = '127.0.0.1' interface = '127.0.0.1'
interface = '10.26.20.10' interface = '10.26.20.10'

View file

@ -46,6 +46,16 @@ function OxFF() {
} }
this.username = ox.get('username'); this.username = ox.get('username');
this.password = ox.get('password'); this.password = ox.get('password');
AddonManager.getAddonByID('firefogg@firefogg.org', function(addon) {
if (addon.hasResource('bin')) {
var resource = addon.getResourceURI('bin');
var file = resource.QueryInterface(Ci.nsIFileURL).file.QueryInterface(Ci.nsILocalFile);
file.append('ffmpeg2theora');
_this._ffmpeg2theora = file.path;
}
});
} }
OxFF.prototype = { OxFF.prototype = {
@ -311,7 +321,7 @@ OxFF.prototype = {
} catch (e) {} } catch (e) {}
_this._daemon = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); _this._daemon = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
_this._daemon.init(file); _this._daemon.init(file);
var args = [ox.getDBFile().path]; var args = [ox.getDBFile().path, _this._ffmpeg2theora];
_this._daemon.runw(false, args, args.length); _this._daemon.runw(false, args, args.length);
} }
AddonManager.getAddonByID(this.extensionID, function(addon) { AddonManager.getAddonByID(this.extensionID, function(addon) {