diff --git a/Transcoder.py b/Transcoder.py index 61651b7f..3e78babe 100644 --- a/Transcoder.py +++ b/Transcoder.py @@ -7,6 +7,23 @@ from subprocess import call Logger = logging.getLogger() def Transcode_file(filePath): + + 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. + if not os.path.isfile(ffmpeg): # problem + Logger.error("ffmpeg not found. ffmpeg needs to be located at: %s", ffmpeg) + Logger.info("Cannot transcode file %s", filepath) + return 1 # failure + else + if call(['which', ffmpeg]): + 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. + Logger.error("Failed to install ffmpeg. Please install manually") + Logger.info("Cannot transcode file %s", filepath) + return 1 # failure + else: + ffmpeg = 'ffmpeg' + config = ConfigParser.ConfigParser() configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg") Logger.info("Loading config from %s", configFilename) @@ -18,7 +35,6 @@ def Transcode_file(filePath): config.read(configFilename) duplicate = config.get("Transcoder", "duplicate") - ffmpeg = os.path.normpath(config.get("Transcoder", "ffmpeg")) ignoreExtensions = (config.get("Transcoder", "ignoreExtensions")).split(',') outputVideoExtension = config.get("Transcoder", "outputVideoExtension") outputVideoCodec = config.get("Transcoder", "outputVideoCodec")