use metadata from ffmpeg2theora if available
This commit is contained in:
parent
2f129c4766
commit
25c203e981
1 changed files with 14 additions and 8 deletions
22
ox/file.py
22
ox/file.py
|
@ -178,14 +178,20 @@ def avinfo(filename, cached=True):
|
||||||
v['display_aspect_ratio'] = '%d:%d' % (v['width'], v['height'])
|
v['display_aspect_ratio'] = '%d:%d' % (v['width'], v['height'])
|
||||||
v['pixel_aspect_ratio'] = '1:1'
|
v['pixel_aspect_ratio'] = '1:1'
|
||||||
if len(info.get('audio', [])) > 1:
|
if len(info.get('audio', [])) > 1:
|
||||||
ffmpeg = cmd('ffmpeg')
|
if 'metadata' in info['audio'][0]:
|
||||||
p = subprocess.Popen([ffmpeg, '-i', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
for stream in info['audio']:
|
||||||
stdout, stderr = p.communicate()
|
language = stream.get('metadata', {}).get('language')
|
||||||
languages = [re.compile('\((.+?)\):').findall(l) for l in stderr.split('\n') if 'Stream' in l and 'Audio' in l]
|
if language and language != 'und':
|
||||||
for i, stream in enumerate(info['audio']):
|
stream['language'] = language[0]
|
||||||
language = languages[i]
|
else:
|
||||||
if language and language[0] != 'und':
|
ffmpeg = cmd('ffmpeg')
|
||||||
stream['language'] = language[0]
|
p = subprocess.Popen([ffmpeg, '-i', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
|
languages = [re.compile('\((.+?)\):').findall(l) for l in stderr.split('\n') if 'Stream' in l and 'Audio' in l]
|
||||||
|
for i, stream in enumerate(info['audio']):
|
||||||
|
language = languages[i]
|
||||||
|
if language and language[0] != 'und':
|
||||||
|
stream['language'] = language[0]
|
||||||
return info
|
return info
|
||||||
|
|
||||||
return {'path': filename, 'size': 0}
|
return {'path': filename, 'size': 0}
|
||||||
|
|
Loading…
Reference in a new issue