don't fall back to ffmpeg2theora
This commit is contained in:
parent
75cfe74877
commit
3574be2975
1 changed files with 2 additions and 43 deletions
45
ox/file.py
45
ox/file.py
|
@ -159,51 +159,10 @@ def avinfo(filename, cached=True):
|
||||||
if os.path.getsize(filename):
|
if os.path.getsize(filename):
|
||||||
if find_executable('ffprobe'):
|
if find_executable('ffprobe'):
|
||||||
return ffprobe(filename)
|
return ffprobe(filename)
|
||||||
ffmpeg2theora = cmd('ffmpeg2theora')
|
raise EnvironmentError('could to find ffprobe. please install ffmpeg')
|
||||||
p = subprocess.Popen([ffmpeg2theora], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
stdout, error = p.communicate()
|
|
||||||
stdout = stdout.decode('utf-8')
|
|
||||||
version = stdout.split('\n')[0].split(' - ')[0].split(' ')[-1]
|
|
||||||
if version < '0.27':
|
|
||||||
raise EnvironmentError('version of ffmpeg2theora needs to be 0.27 or later, found %s' % version)
|
|
||||||
p = subprocess.Popen([ffmpeg2theora, '--info', filename],
|
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
stdout, error = p.communicate()
|
|
||||||
stdout = stdout.decode('utf-8')
|
|
||||||
try:
|
|
||||||
info = json.loads(stdout)
|
|
||||||
except:
|
|
||||||
# remove metadata, can be broken
|
|
||||||
reg = re.compile('"metadata": {.*?},', re.DOTALL)
|
|
||||||
stdout = re.sub(reg, '', stdout)
|
|
||||||
info = json.loads(stdout)
|
|
||||||
if 'video' in info:
|
|
||||||
for v in info['video']:
|
|
||||||
if 'display_aspect_ratio' not in v and 'width' in v:
|
|
||||||
v['display_aspect_ratio'] = '%d:%d' % (v['width'], v['height'])
|
|
||||||
v['pixel_aspect_ratio'] = '1:1'
|
|
||||||
if len(info.get('audio', [])) > 1:
|
|
||||||
if 'metadata' in info['audio'][0]:
|
|
||||||
for stream in info['audio']:
|
|
||||||
language = stream.get('metadata', {}).get('language')
|
|
||||||
if language and language != 'und':
|
|
||||||
stream['language'] = language[0]
|
|
||||||
else:
|
|
||||||
ffmpeg = cmd('ffmpeg')
|
|
||||||
p = subprocess.Popen([ffmpeg, '-i', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
stdout, stderr = p.communicate()
|
|
||||||
stderr = stderr.decode('utf-8')
|
|
||||||
languages = [re.compile('\((.+?)\):').findall(l) for l in stderr.split('\n') if 'Stream' in l and 'Audio' in l]
|
|
||||||
if len(languages) == len(info['audio']):
|
|
||||||
for i, stream in enumerate(info['audio']):
|
|
||||||
language = languages[i]
|
|
||||||
if language and language[0] != 'und':
|
|
||||||
stream['language'] = language[0]
|
|
||||||
fix_coverart(info)
|
|
||||||
return info
|
|
||||||
|
|
||||||
return {'path': filename, 'size': 0}
|
return {'path': filename, 'size': 0}
|
||||||
|
|
||||||
|
|
||||||
def ffprobe(filename):
|
def ffprobe(filename):
|
||||||
p = subprocess.Popen([
|
p = subprocess.Popen([
|
||||||
cmd('ffprobe'),
|
cmd('ffprobe'),
|
||||||
|
|
Loading…
Reference in a new issue