now working
This commit is contained in:
Clinton Hall 2013-03-11 23:34:17 -07:00
commit b51c746f15

View file

@ -9,17 +9,17 @@ Logger = logging.getLogger()
def Transcode_file(filePath): def Transcode_file(filePath):
if os.name == 'nt': if os.name == 'nt':
ffmpeg = os.path.join(os.path.dirname(sys.argv[0]), 'ffmpeg\bin\ffmpeg.exe') # note, will need to package in this dir. ffmpeg = os.path.join(os.path.dirname(sys.argv[0]), 'ffmpeg\\bin\\ffmpeg.exe') # note, will need to package in this dir.
if not os.path.isfile(ffmpeg): # problem if not os.path.isfile(ffmpeg): # problem
Logger.error("ffmpeg not found. ffmpeg needs to be located at: %s", ffmpeg) Logger.error("ffmpeg not found. ffmpeg needs to be located at: %s", ffmpeg)
Logger.info("Cannot transcode file %s", filepath) Logger.info("Cannot transcode file %s", filePath)
return 1 # failure return 1 # failure
else: else:
if call(['which', ffmpeg]): if call(['which', ffmpeg]):
res = call([os.path.join(os.path.dirname(sys.argv[0]),'getffmpeg.sh')]) res = call([os.path.join(os.path.dirname(sys.argv[0]),'getffmpeg.sh')])
if res or call(['which', ffmpeg]): # did not install or ffmpeg still not found. if res or call(['which', ffmpeg]): # did not install or ffmpeg still not found.
Logger.error("Failed to install ffmpeg. Please install manually") Logger.error("Failed to install ffmpeg. Please install manually")
Logger.info("Cannot transcode file %s", filepath) Logger.info("Cannot transcode file %s", filePath)
return 1 # failure return 1 # failure
else: else:
ffmpeg = 'ffmpeg' ffmpeg = 'ffmpeg'
@ -34,16 +34,16 @@ def Transcode_file(filePath):
config.read(configFilename) config.read(configFilename)
duplicate = config.get("Transcoder", "duplicate") duplicate = int(config.get("Transcoder", "duplicate"))
ignoreExtensions = (config.get("Transcoder", "ignoreExtensions")).split(',') ignoreExtensions = (config.get("Transcoder", "ignoreExtensions")).split(',')
outputVideoExtension = config.get("Transcoder", "outputVideoExtension") outputVideoExtension = config.get("Transcoder", "outputVideoExtension")
outputVideoCodec = config.get("Transcoder", "outputVideoCodec") outputVideoCodec = config.get("Transcoder", "outputVideoCodec")
outputVideoFramrate = config.get("Transcoder", "outputVideoFramrate") outputVideoFramerate = config.get("Transcoder", "outputVideoFramerate")
outputVideoBitrate = config.get("Transcoder", "outputVideoBitrate") outputVideoBitrate = config.get("Transcoder", "outputVideoBitrate")
outputAudioCodec = config.get("Transcoder", "outputAudioCodec") outputAudioCodec = config.get("Transcoder", "outputAudioCodec")
outputAudioBitrate = config.get("Transcoder", "outputAudioBitrate") outputAudioBitrate = config.get("Transcoder", "outputAudioBitrate")
name, ext = os.path.splitext(file) name, ext = os.path.splitext(filePath)
if ext in ignoreExtensions: if ext in ignoreExtensions:
Logger.info("No need to transcode video type %s", ext) Logger.info("No need to transcode video type %s", ext)
return 0 # exit Transcoder. return 0 # exit Transcoder.
@ -55,7 +55,7 @@ def Transcode_file(filePath):
if outputVideoCodec: if outputVideoCodec:
command.append('-c:v') command.append('-c:v')
command.append(outputVideoCodec) command.append(outputVideoCodec)
if outputVideoFramrate: if outputVideoFramerate:
command.append('-r') command.append('-r')
command.append(outputVideoFramerate) command.append(outputVideoFramerate)
if outputVideoBitrate: if outputVideoBitrate:
@ -82,7 +82,3 @@ def Transcode_file(filePath):
else: else:
Logger.error("Transcoding of video %s to %s failed", filePath, newfilePath) Logger.error("Transcoding of video %s to %s failed", filePath, newfilePath)
return result return result