diff options
-rw-r--r-- | options.py | 23 | ||||
-rw-r--r-- | output.py | 24 | ||||
-rw-r--r-- | vidslice.py | 2 |
3 files changed, 30 insertions, 19 deletions
@@ -13,6 +13,12 @@ EDIT_BOX_COL = 2 NEW_COL = 3 +class FFmpegOptions: + def __init__(self, input, output): + self.input = input + self.output = output + + class Property: def __init__(self, parent, name, *, label=None, orig=None, edit=None, new_class=None, new=None): self.handlers = [] @@ -238,19 +244,20 @@ class OptionsPanel(wx.Panel): self.enforce_constraints() def ffmpeg_opts(self): - opts = [] + input_opts = [] + output_opts = [] if self.start_time.is_edit(): - opts += ['-ss', str(self.start_time.get_final())] + input_opts += ['-ss', str(self.start_time.get_final())] elif self.end_time.is_edit() and self.duration.is_edit(): new_end = float(self.end_time.get_final()) new_duration = float(self.duration.get_final()) new_start = new_end - new_duration - opts += ['-ss', str(new_start)] + input_opts += ['-ss', str(new_start)] if self.end_time.is_edit(): - opts += ['-to', str(self.end_time.get_final())] + output_opts += ['-to', str(self.end_time.get_final())] if self.duration.is_edit(): - opts += ['-t', str(self.duration.get_final())] + output_opts += ['-t', str(self.duration.get_final())] if self.width.is_edit() or self.height.is_edit(): width = str(self.width.get_final()) @@ -259,9 +266,9 @@ class OptionsPanel(wx.Panel): width = "-1" if not self.height.is_edit(): height = "-1" - opts += ['-vf', 'scale=' + width + ':' + height] + output_opts += ['-vf', 'scale=' + width + ':' + height] if self.framerate.is_edit(): - opts += ['-r', str(self.framerate.get_final())] + output_opts += ['-r', str(self.framerate.get_final())] - return opts + return FFmpegOptions(input_opts, output_opts) @@ -4,9 +4,11 @@ import threading import wx +from options import FFmpegOptions + class OutputPanel(wx.Panel): - def __init__(self, *args, get_ffmpeg_args=lambda: [], **kw): + def __init__(self, *args, get_ffmpeg_args=lambda: FFmpegOptions([], []), **kw): super(OutputPanel, self).__init__(*args, **kw) self.update_listeners = [] self.input_path = None @@ -74,29 +76,31 @@ class OutputPanel(wx.Panel): self.logs.Clear() self.run_panel.Disable() real_args = self.get_ffmpeg_args() + input_args = real_args.input + output_args = real_args.output output_path = self.file_text.GetValue() (folder, name) = os.path.split(output_path) (name, ext) = os.path.splitext(name) if self.silence.GetValue(): - real_args += ['-an'] + output_args += ['-an'] if ext == '.gif': filter_before = '[0:v] ' filter_after = 'split [a][b];[a] palettegen [p];[b][p] paletteuse' filter_during = '' - if '-vf' in real_args: - for i in range(len(real_args) - 1): - [a, b] = real_args[i:i + 2] + if '-vf' in output_args: + for i in range(len(output_args) - 1): + [a, b] = output_args[i:i + 2] if a == '-vf': filter_during = b + ',' - real_args[i:i + 2] = [] + output_args[i:i + 2] = [] break - real_args += ['-filter_complex', filter_before + filter_during + filter_after] + output_args += ['-filter_complex', filter_before + filter_during + filter_after] if self.deepfry.GetValue(): if ext == '.mp3': - real_args += ['-q:a', '9'] + output_args += ['-q:a', '9'] else: - real_args += ['-q:a', '0.1', '-crf', '51'] - args = ['ffmpeg', '-hide_banner', '-y', '-i', self.input_path] + real_args + [output_path] + output_args += ['-q:a', '0.1', '-crf', '51'] + args = ['ffmpeg', '-hide_banner', '-y'] + input_args + ['-i', self.input_path] + output_args + [output_path] print(args) def run(): diff --git a/vidslice.py b/vidslice.py index 36fb1fd..6852ab9 100644 --- a/vidslice.py +++ b/vidslice.py @@ -9,7 +9,7 @@ from options import OptionsPanel from output import OutputPanel from sources import SourcesPanel, update_ytdl -VERSION = "1.3" +VERSION = "1.4" def check_update(parent): |