fonction de conversion audio

This commit is contained in:
Antoine Van Elstraete 2021-06-20 01:44:48 +02:00
parent b049d8a6a0
commit 32411273a5

View File

@ -40,6 +40,7 @@ def get_infos(file):
a_stream_infos = { a_stream_infos = {
'index': a_stream['index'], 'index': a_stream['index'],
'channels': a_stream['channels'], 'channels': a_stream['channels'],
'channel_layout': a_stream['channel_layout'],
'language': a_stream['tags']['language'], 'language': a_stream['tags']['language'],
'title': a_stream['tags']['title']} 'title': a_stream['tags']['title']}
a_infos.append(a_stream_infos) a_infos.append(a_stream_infos)
@ -121,6 +122,15 @@ def stabilization(file):
subprocess.getoutput(cmd_stab) subprocess.getoutput(cmd_stab)
def convert_audio(file, track, volume_adj, channels, channel_layout, language, title):
bitrate = 64*channels
codec = 'libopus'
metadatas = f'-metadata language="{language}" -metadata title="{title}"'
command = f'ffmpeg -i {file} -map 0:{track} -vn -sn -c:a {codec} -b:a {bitrate} -mapping_family 1 -filter:a volume={volume_adj}dB,aformat=channel_layouts={channel_layout} -y {file}_audio_{track}.mka'
logging.debug{command}
if __name__ == '__main__': if __name__ == '__main__':
import argparse import argparse
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -136,6 +146,6 @@ if __name__ == '__main__':
interlaced = is_interlaced(args.f_input, infos) interlaced = is_interlaced(args.f_input, infos)
cropsize = cropping(args.f_input, infos) cropsize = cropping(args.f_input, infos)
volumes = volume_audio(args.f_input, infos) volumes = volume_audio(args.f_input, infos)
if args.stab: if args.stab:
stabilization(args.f_input) stabilization(args.f_input)
for