override sys path with ffmpeg path. Fixes #518

This commit is contained in:
clinton-hall 2014-08-04 12:51:19 +09:30
commit acfc150c19

View file

@ -587,54 +587,48 @@ def initialize(section=None):
logger.warning("Failed to locate ffmpeg.exe, transcoding disabled!") logger.warning("Failed to locate ffmpeg.exe, transcoding disabled!")
logger.warning("Install ffmpeg with x264 support to enable this feature ...") logger.warning("Install ffmpeg with x264 support to enable this feature ...")
if not (os.path.isfile(FFPROBE)) and CHECK_MEDIA: # problem if not (os.path.isfile(FFPROBE)):
FFPROBE = None FFPROBE = None
logger.warning("Failed to locate ffprobe.exe, video corruption detection disabled!") if CHECK_MEDIA:
logger.warning("Install ffmpeg with x264 support to enable this feature ...") logger.warning("Failed to locate ffprobe.exe, video corruption detection disabled!")
logger.warning("Install ffmpeg with x264 support to enable this feature ...")
else: else:
try: if os.path.isfile(os.path.join(FFMPEG_PATH, 'ffmpeg')) or os.access(os.path.join(FFMPEG_PATH, 'ffmpeg'), os.X_OK):
FFMPEG = subprocess.Popen(['which', 'ffmpeg'], stdout=subprocess.PIPE).communicate()[0].strip() FFMPEG = os.path.join(FFMPEG_PATH, 'ffmpeg')
FFPROBE = subprocess.Popen(['which', 'ffprobe'], stdout=subprocess.PIPE).communicate()[0].strip() elif os.path.isfile(os.path.join(FFMPEG_PATH, 'avconv')) or os.access(os.path.join(FFMPEG_PATH, 'avconv'), os.X_OK):
except: FFMPEG = os.path.join(FFMPEG_PATH, 'avconv')
if os.path.isfile(os.path.join(FFMPEG_PATH, 'ffmpeg')): else:
FFMPEG = os.path.join(FFMPEG_PATH, 'ffmpeg')
if os.path.isfile(os.path.join(FFMPEG_PATH, 'ffprobe')):
FFPROBE = os.path.join(FFMPEG_PATH, 'ffprobe')
if not FFMPEG and not FFPROBE:
try: try:
FFMPEG = subprocess.Popen(['which', 'avconv'], stdout=subprocess.PIPE).communicate()[0].strip() FFMPEG = subprocess.Popen(['which', 'ffmpeg'], stdout=subprocess.PIPE).communicate()[0].strip()
FFPROBE = subprocess.Popen(['which', 'avprobe'], stdout=subprocess.PIPE).communicate()[0].strip() except: pass
except: if not FFMPEG:
if os.path.isfile(os.path.join(FFMPEG_PATH, 'avconv')): try:
FFMPEG = os.path.join(FFMPEG_PATH, 'avconv') FFMPEG = subprocess.Popen(['which', 'avconv'], stdout=subprocess.PIPE).communicate()[0].strip()
if os.path.isfile(os.path.join(FFMPEG_PATH, 'avprobe')): except: pass
FFPROBE = os.path.join(FFMPEG_PATH, 'avprobe')
if not FFMPEG: if not FFMPEG:
if os.access(os.path.join(FFMPEG_PATH, 'ffmpeg'), os.X_OK): FFMPEG = None
FFMPEG = os.path.join(FFMPEG_PATH, 'ffmpeg') logger.warning("Failed to locate ffmpeg, transcoding disabled!")
elif os.access(os.path.join(FFMPEG_PATH, 'avconv'), os.X_OK): logger.warning("Install ffmpeg with x264 support to enable this feature ...")
FFMPEG = os.path.join(FFMPEG_PATH, 'avconv')
else:
FFMPEG = None
logger.warning("Failed to locate ffmpeg, transcoding disabled!")
logger.warning("Install ffmpeg with x264 support to enable this feature ...")
if not FFPROBE and CHECK_MEDIA: if os.path.isfile(os.path.join(FFMPEG_PATH, 'ffprobe')) or os.access(os.path.join(FFMPEG_PATH, 'ffprobe'), os.X_OK):
if os.access(os.path.join(FFMPEG_PATH, 'ffprobe'), os.X_OK): FFPROBE = os.path.join(FFMPEG_PATH, 'ffprobe')
FFPROBE = os.path.join(FFMPEG_PATH, 'ffprobe') elif os.path.isfile(os.path.join(FFMPEG_PATH, 'avprobe')) or os.access(os.path.join(FFMPEG_PATH, 'avprobe'), os.X_OK):
elif os.access(os.path.join(FFMPEG_PATH, 'avprobe'), os.X_OK): FFPROBE = os.path.join(FFMPEG_PATH, 'avprobe')
FFPROBE = os.path.join(FFMPEG_PATH, 'avprobe') else:
else: try:
FFPROBE = None FFPROBE = subprocess.Popen(['which', 'ffprobe'], stdout=subprocess.PIPE).communicate()[0].strip()
except: pass
if not FFPROBE:
try:
FFPROBE = subprocess.Popen(['which', 'avprobe'], stdout=subprocess.PIPE).communicate()[0].strip()
except: pass
if not FFPROBE:
FFPROBE = None
if CHECK_MEDIA:
logger.warning("Failed to locate ffprobe, video corruption detection disabled!") logger.warning("Failed to locate ffprobe, video corruption detection disabled!")
logger.warning("Install ffmpeg with x264 support to enable this feature ...") logger.warning("Install ffmpeg with x264 support to enable this feature ...")
if not CHECK_MEDIA: # allow users to bypass this.
FFPROBE = None
# check for script-defied section and if None set to allow sections # check for script-defied section and if None set to allow sections
SECTIONS = CFG[tuple(x for x in CFG if CFG[x].sections and CFG[x].isenabled()) if not section else (section,)] SECTIONS = CFG[tuple(x for x in CFG if CFG[x].sections and CFG[x].isenabled()) if not section else (section,)]
map(CATEGORIES.extend,([subsection.sections for section,subsection in SECTIONS.items()])) map(CATEGORIES.extend,([subsection.sections for section,subsection in SECTIONS.items()]))