parse language from audio track if video has multiple audio tracks
This commit is contained in:
parent
bc9c3c8944
commit
2f129c4766
1 changed files with 9 additions and 0 deletions
|
@ -177,6 +177,15 @@ def avinfo(filename, cached=True):
|
|||
if not 'display_aspect_ratio' 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:
|
||||
ffmpeg = cmd('ffmpeg')
|
||||
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 {'path': filename, 'size': 0}
|
||||
|
|
Loading…
Reference in a new issue