convertie l'audio. factorisation.
This commit is contained in:
parent
32411273a5
commit
724aaf6bcd
@ -14,6 +14,7 @@ def get_infos(file):
|
|||||||
-> http://ffmpeg.org/ffprobe.html
|
-> http://ffmpeg.org/ffprobe.html
|
||||||
'''
|
'''
|
||||||
v_infos = {
|
v_infos = {
|
||||||
|
'index': None,
|
||||||
'height': None,
|
'height': None,
|
||||||
'width': None,
|
'width': None,
|
||||||
'color_primaries': None,
|
'color_primaries': None,
|
||||||
@ -123,12 +124,13 @@ def stabilization(file):
|
|||||||
|
|
||||||
|
|
||||||
def convert_audio(file, track, volume_adj, channels, channel_layout, language, title):
|
def convert_audio(file, track, volume_adj, channels, channel_layout, language, title):
|
||||||
bitrate = 64*channels
|
bitrate = f'{64*channels}k'
|
||||||
codec = 'libopus'
|
codec = 'libopus'
|
||||||
metadatas = f'-metadata language="{language}" -metadata title="{title}"'
|
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'
|
command = f'ffmpeg -loglevel error -i {file} -map 0:{track} -vn -sn -c:a {codec} -b:a {bitrate} -mapping_family 1 -filter:a volume={volume_adj},aformat=channel_layouts={channel_layout} -y {file}_audio_{track}.mka'
|
||||||
logging.debug{command}
|
logging.debug(command)
|
||||||
|
result = subprocess.getoutput(command)
|
||||||
|
logging.info(result)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -142,10 +144,12 @@ if __name__ == '__main__':
|
|||||||
logging.basicConfig(format='[%(asctime)s]\n%(message)s', level=logging.DEBUG, datefmt='%d/%m/%Y %H:%M:%S')
|
logging.basicConfig(format='[%(asctime)s]\n%(message)s', level=logging.DEBUG, datefmt='%d/%m/%Y %H:%M:%S')
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(format='[%(asctime)s]\n%(message)s', level=logging.INFO, datefmt='%d/%m/%Y %H:%M:%S')
|
logging.basicConfig(format='[%(asctime)s]\n%(message)s', level=logging.INFO, datefmt='%d/%m/%Y %H:%M:%S')
|
||||||
infos = get_infos(args.f_input)
|
file = args.f_input
|
||||||
interlaced = is_interlaced(args.f_input, infos)
|
infos = get_infos(file)
|
||||||
cropsize = cropping(args.f_input, infos)
|
interlaced = is_interlaced(file, infos)
|
||||||
volumes = volume_audio(args.f_input, infos)
|
cropsize = cropping(file, infos)
|
||||||
|
volumes = volume_audio(file, infos)
|
||||||
if args.stab:
|
if args.stab:
|
||||||
stabilization(args.f_input)
|
stabilization(file)
|
||||||
for
|
for track in infos['audio']:
|
||||||
|
convert_audio(file, track['index'], volumes[track['index']], track['channels'], track['channel_layout'], track['language'], track['title'])
|
||||||
|
Loading…
Reference in New Issue
Block a user