From ec007f2cc2f839693de1400902bdcba4fea0b62e Mon Sep 17 00:00:00 2001 From: William McBrine Date: Mon, 20 Apr 2009 09:30:41 -0400 Subject: [PATCH] Common ffmpeg_path(). --- config.py | 4 ++-- plugins/music/music.py | 7 ++----- plugins/video/transcode.py | 9 +++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/config.py b/config.py index f5e5b8a..35f4ee5 100644 --- a/config.py +++ b/config.py @@ -192,8 +192,8 @@ def getPixelAR(ref): pass return (False, 1.0)[ref] -def get(section, key): - return config.get(section, key) +def ffmpeg_path(): + return config.get('Server', 'ffmpeg') def getFFmpegWait(): if config.has_option('Server', 'ffmpeg_wait'): diff --git a/plugins/music/music.py b/plugins/music/music.py index 08bc15e..2fcadca 100644 --- a/plugins/music/music.py +++ b/plugins/music/music.py @@ -22,9 +22,6 @@ from plugins.video.transcode import kill SCRIPTDIR = os.path.dirname(__file__) -def ffmpeg_path(): - return config.get('Server', 'ffmpeg') - CLASS_NAME = 'Music' PLAYLISTS = ('.m3u', '.m3u8', '.ram', '.pls', '.b4s', '.wpl', '.asx', @@ -121,7 +118,7 @@ class Music(Plugin): if needs_transcode: if mswindows: fname = fname.encode('iso8859-1') - cmd = [ffmpeg_path(), '-i', fname, '-ab', + cmd = [config.ffmpeg_path(), '-i', fname, '-ab', '320k', '-ar', '44100', '-f', 'mp3', '-'] if seek: cmd[-1:] = ['-ss', '%.3f' % (seek / 1000.0), '-'] @@ -232,7 +229,7 @@ class Music(Plugin): fname = unicode(f.name, 'utf-8') if mswindows: fname = fname.encode('iso8859-1') - cmd = [ffmpeg_path(), '-i', fname] + cmd = [config.ffmpeg_path(), '-i', fname] ffmpeg = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE) diff --git a/plugins/video/transcode.py b/plugins/video/transcode.py index eaf8b8a..16cd652 100644 --- a/plugins/video/transcode.py +++ b/plugins/video/transcode.py @@ -20,9 +20,6 @@ info_cache = lrucache.LRUCache(1000) GOOD_MPEG_FPS = ['23.98', '24.00', '25.00', '29.97', '30.00', '50.00', '59.94', '60.00'] -def ffmpeg_path(): - return config.get('Server', 'ffmpeg') - # XXX BIG HACK # subprocess is broken for me on windows so super hack def patchSubprocess(): @@ -74,7 +71,7 @@ def transcode(isQuery, inFile, outFile, tsn=''): cmd_string = config.getFFmpegTemplate(tsn) % settings - cmd = [ffmpeg_path(), '-i', inFile] + cmd_string.split() + cmd = [config.ffmpeg_path(), '-i', inFile] + cmd_string.split() logging.debug('transcoding to tivo model ' + tsn[:3] + ' using ffmpeg command:') logging.debug(' '.join(cmd)) @@ -560,7 +557,7 @@ def video_info(inFile, cache=True): logger.debug('VALID, ends in .tivo. %s' % inFile) return vInfo - cmd = [ffmpeg_path(), '-i', inFile] + cmd = [config.ffmpeg_path(), '-i', inFile] # Windows and other OS buffer 4096 and ffmpeg can output more than that. err_tmp = tempfile.TemporaryFile() ffmpeg = subprocess.Popen(cmd, stderr=err_tmp, stdout=subprocess.PIPE, @@ -766,7 +763,7 @@ def video_info(inFile, cache=True): def audio_check(inFile, tsn): cmd_string = ('-y -vcodec mpeg2video -r 29.97 -b 1000k -acodec copy ' + select_audiolang(inFile, tsn) + ' -t 00:00:01 -f vob -') - cmd = [ffmpeg_path(), '-i', inFile] + cmd_string.split() + cmd = [config.ffmpeg_path(), '-i', inFile] + cmd_string.split() ffmpeg = subprocess.Popen(cmd, stdout=subprocess.PIPE) fd, testname = tempfile.mkstemp() testfile = os.fdopen(fd, 'wb') -- 2.11.4.GIT