Browse Source

make ffcuesplitters ffmeg_arguments() function return arguments in way that is a lot more usable to me

master
Constantin Fürst 2 years ago
parent
commit
2beaa1d0f2
  1. 62
      ffcuesplitter/ffmpeg.py

62
ffcuesplitter/ffmpeg.py

@ -87,43 +87,45 @@ class FFMpeg:
dict(arguments:[...], seconds:[...])
"""
self.arguments = []
self.seconds = []
meters = {'tqdm': '-progress pipe:1 -nostats -nostdin', 'standard': ''}
for track in self.audiotracks:
codec, suffix = self.codec_setup(track["FILE"])
metadata = {'ARTIST': track.get('PERFORMER', ''),
'ALBUM': track.get('ALBUM', ''),
'TITLE': track.get('TITLE', ''),
'TRACK': (str(track['TRACK_NUM']) + '/' +
str(len(self.audiotracks))),
'DISCNUMBER': track.get('DISCNUMBER', ''),
'GENRE': track.get('GENRE', ''),
'DATE': track.get('DATE', ''),
'COMMENT': track.get('COMMENT', ''),
'DISCID': track.get('DISCID', ''),
}
cmd = f'"{self.kwargs["ffmpeg_cmd"]}" '
cmd += f' -loglevel {self.kwargs["ffmpeg_loglevel"]}'
cmd += f" {meters[self.kwargs['progress_meter']]}"
track_arguments = []
metadata = {
'ARTIST': track.get('PERFORMER', ''),
'ALBUM': track.get('ALBUM', ''),
'TITLE': track.get('TITLE', ''),
'TRACK': (str(track['TRACK_NUM']) + '/' + str(len(self.audiotracks))),
'DISCNUMBER': track.get('DISCNUMBER', ''),
'GENRE': track.get('GENRE', ''),
'DATE': track.get('DATE', ''),
'COMMENT': track.get('COMMENT', ''),
'DISCID': track.get('DISCID', ''),
}
fpath = os.path.join(self.kwargs["dirname"], track["FILE"])
cmd += f' -i "{fpath}"'
cmd += f" -ss {round(track['START'] / 44100, 6)}" # ff to secs
track_arguments.append('-i')
track_arguments.append(f"\"{fpath}\"")
track_arguments.append("-ss")
track_arguments.append(f"{round(track['START'] / 44100, 6)}")
if 'END' in track:
cmd += f" -to {round(track['END'] / 44100, 6)}" # ff to secs
track_arguments.append("-to")
track_arguments.append(f" {round(track['END'] / 44100, 6)}")
for key, val in metadata.items():
cmd += f' -metadata {key}="{val}"'
cmd += f' {codec}'
cmd += f" {self.kwargs['ffmpeg_add_params']}"
cmd += ' -y'
track_arguments.append("-metadata")
track_arguments.append(f'{key}="{val}"')
num = str(track['TRACK_NUM']).rjust(2, '0')
name = f'{num} - {track["TITLE"]}.{suffix}'
cmd += f' "{os.path.join(self.kwargs["tempdir"], name)}"'
self.arguments.append(cmd)
self.seconds.append(track['DURATION'])
name = f'{num} - {track["TITLE"]}'
track_arguments.append(name)
self.arguments.append(track_arguments)
return self.arguments
return {'arguments': self.arguments, 'seconds': self.seconds}
# --------------------------------------------------------------#
def processing(self, arg, secs):

Loading…
Cancel
Save