unknown audio

click
Javanaut 2 years ago
parent 3e793ce2b1
commit 71456e74c2

@ -48,7 +48,7 @@ def generateOutputTokens(f, q=''):
if q: if q:
fTokens = f.split('.') fTokens = f.split('.')
paddedFilename = '.'.join(fTokens[:-1]) + f" q{q}" + '.' + fTokens[-1] paddedFilename = '.'.join(fTokens[:-1]) + f" q{q}" + '.' + fTokens[-1]
return ['-f', 'webm', paddedFilename] return ['-f', 'webm', paddedFilename]
else: else:
return ['-f', 'webm', f] return ['-f', 'webm', f]
@ -116,7 +116,10 @@ audioStreams = [s for s in streamData if s['codec_type'] == 'audio']
subtitleStreams = [s for s in streamData if s['codec_type'] == 'subtitle'] subtitleStreams = [s for s in streamData if s['codec_type'] == 'subtitle']
for aStream in audioStreams: for aStream in audioStreams:
print(f"audio stream: {aStream['channel_layout']}") if 'channel_layout' in aStream.keys():
print(f"audio stream: {aStream['channel_layout']}") #channel_layout
else:
print(f"unknown audio stream with {aStream['channels']} channels") #channel_layout
commandTokens = ['ffmpeg', '-y', '-i', inputFilename] commandTokens = ['ffmpeg', '-y', '-i', inputFilename]
@ -133,29 +136,42 @@ for s in range(len(subtitleStreams)):
audioTokens = [] audioTokens = []
audioStreamIndex = 0 audioStreamIndex = 0
for aStream in audioStreams: for aStream in audioStreams:
channelLayout = aStream['channel_layout']
channels = aStream['channels']
if channelLayout == '6.1':
audioTokens += [f"-c:a:{audioStreamIndex}", if 'channel_layout' in aStream.keys():
'libopus',
f"-filter:a:{audioStreamIndex}", channelLayout = aStream['channel_layout']
'channelmap=channel_layout=6.1',
f"-b:a:{audioStreamIndex}", if channelLayout == '6.1':
dtsBandwidth] audioTokens += [f"-c:a:{audioStreamIndex}",
'libopus',
if channelLayout == '5.1(side)': f"-filter:a:{audioStreamIndex}",
audioTokens += [f"-c:a:{audioStreamIndex}", 'channelmap=channel_layout=6.1',
'libopus', f"-b:a:{audioStreamIndex}",
f"-filter:a:{audioStreamIndex}", dtsBandwidth]
"channelmap=FL-FL|FR-FR|FC-FC|LFE-LFE|SL-BL|SR-BR:5.1",
f"-b:a:{audioStreamIndex}", if channelLayout == '5.1(side)':
ac3Bandwidth] audioTokens += [f"-c:a:{audioStreamIndex}",
'libopus',
if channelLayout == 'stereo': f"-filter:a:{audioStreamIndex}",
audioTokens += [f"-c:a:{audioStreamIndex}", "channelmap=FL-FL|FR-FR|FC-FC|LFE-LFE|SL-BL|SR-BR:5.1",
'libopus', f"-b:a:{audioStreamIndex}",
f"-b:a:{audioStreamIndex}", ac3Bandwidth]
stereoBandwidth]
if channelLayout == 'stereo':
audioTokens += [f"-c:a:{audioStreamIndex}",
'libopus',
f"-b:a:{audioStreamIndex}",
stereoBandwidth]
else:
if channels == 6:
audioTokens += [f"-c:a:{audioStreamIndex}",
'libopus',
f"-b:a:{audioStreamIndex}",
ac3Bandwidth]
audioStreamIndex += 1 audioStreamIndex += 1

Loading…
Cancel
Save