added an edit box for the activation_bytes(used for encrypted files) and made some labels
This commit is contained in:
139
main.py
139
main.py
@@ -11,10 +11,15 @@ VIDEO_FORMATS = ["mp4", "mkv", "mov", "webm"]
|
||||
|
||||
class ConverterFrame(wx.Frame):
|
||||
def __init__(self):
|
||||
super().__init__(parent=None, title="Audio/Video Converter", size=(720, 460))
|
||||
super().__init__(parent=None, title="Audio/Video Converter", size=(640, 380))
|
||||
panel = wx.Panel(self)
|
||||
label_color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT)
|
||||
|
||||
self.input_picker = wx.FilePickerCtrl(panel, message="Select input file")
|
||||
self.input_picker = wx.FilePickerCtrl(
|
||||
panel,
|
||||
message="Select input file",
|
||||
style=wx.FLP_OPEN | wx.FLP_FILE_MUST_EXIST | wx.FLP_USE_TEXTCTRL,
|
||||
)
|
||||
self.mode_choice = wx.Choice(panel, choices=["Audio", "Video"])
|
||||
self.mode_choice.SetSelection(0)
|
||||
self.format_choice = wx.Choice(panel, choices=AUDIO_FORMATS)
|
||||
@@ -22,24 +27,24 @@ class ConverterFrame(wx.Frame):
|
||||
self.output_picker = wx.FilePickerCtrl(
|
||||
panel,
|
||||
message="Select output file",
|
||||
style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT,
|
||||
style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL,
|
||||
)
|
||||
self.audio_bitrate = wx.TextCtrl(panel, value="", size=(120, -1))
|
||||
self.video_bitrate = wx.TextCtrl(panel, value="", size=(120, -1))
|
||||
self.copy_streams = wx.CheckBox(panel, label="Copy streams (fast, no re-encode)")
|
||||
self.start_btn = wx.Button(panel, label="Convert")
|
||||
self.activation_bytes = wx.TextCtrl(panel, value="", size=(120, -1))
|
||||
self.copy_streams = wx.CheckBox(panel, label="Co&py streams (fast, no re-encode)")
|
||||
self.copy_streams.SetForegroundColour(label_color)
|
||||
self.start_btn = wx.Button(panel, label="&Convert")
|
||||
self.log_ctrl = wx.TextCtrl(panel, style=wx.TE_MULTILINE | wx.TE_READONLY)
|
||||
self.status = wx.StaticText(panel, label="Ready")
|
||||
self.status.SetForegroundColour(label_color)
|
||||
|
||||
self.media = wx.media.MediaCtrl(panel, style=wx.SIMPLE_BORDER)
|
||||
self.play_btn = wx.Button(panel, label="Play/Pause")
|
||||
self.stop_btn = wx.Button(panel, label="Stop")
|
||||
self.play_btn = wx.Button(panel, label="&Play/Pause")
|
||||
self.stop_btn = wx.Button(panel, label="S&top")
|
||||
self.position_slider = wx.Slider(panel, minValue=0, maxValue=1000, style=wx.SL_HORIZONTAL)
|
||||
self.time_label = wx.StaticText(panel, label="00:00 / 00:00")
|
||||
self.hotkeys_label = wx.StaticText(
|
||||
panel,
|
||||
label="Hotkeys: Space Play/Pause, Ctrl+S Stop, Ctrl+Enter Convert, Alt+Left/Right Seek",
|
||||
)
|
||||
self.time_label.SetForegroundColour(label_color)
|
||||
self.media_length_ms = 0
|
||||
self.dragging_slider = False
|
||||
self.pending_play = False
|
||||
@@ -49,47 +54,49 @@ class ConverterFrame(wx.Frame):
|
||||
|
||||
self.audio_bitrate.SetHint("e.g. 192k")
|
||||
self.video_bitrate.SetHint("e.g. 2000k")
|
||||
self.activation_bytes.SetHint("e.g. 1")
|
||||
self.audio_bitrate.SetName("Audio bitrate")
|
||||
self.video_bitrate.SetName("Video bitrate")
|
||||
self.activation_bytes.SetName("Activation bytes")
|
||||
self.configure_file_picker_accessibility(self.input_picker, "Input file")
|
||||
self.mode_choice.SetName("Conversion mode")
|
||||
self.format_choice.SetName("Output format")
|
||||
self.configure_file_picker_accessibility(self.output_picker, "Output file")
|
||||
self.copy_streams.SetName("Copy streams")
|
||||
self.start_btn.SetName("Convert")
|
||||
self.play_btn.SetName("Play or pause")
|
||||
self.stop_btn.SetName("Stop playback")
|
||||
self.input_picker.SetHelpText("Input file")
|
||||
self.mode_choice.SetHelpText("Conversion mode")
|
||||
self.format_choice.SetHelpText("Output format")
|
||||
self.output_picker.SetHelpText("Output file")
|
||||
self.audio_bitrate.SetHelpText("Audio bitrate")
|
||||
self.video_bitrate.SetHelpText("Video bitrate")
|
||||
self.activation_bytes.SetHelpText("Activation bytes")
|
||||
self.copy_streams.SetHelpText("Copy streams")
|
||||
self.start_btn.SetHelpText("Convert")
|
||||
self.play_btn.SetHelpText("Play or pause")
|
||||
self.stop_btn.SetHelpText("Stop playback")
|
||||
self.media.SetMinSize((200, 36))
|
||||
if hasattr(self.media, "SetVolume"):
|
||||
self.media.SetVolume(1.0)
|
||||
|
||||
form = wx.FlexGridSizer(cols=3, hgap=8, vgap=8)
|
||||
form.Add(wx.StaticText(panel, label="Input"), 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
form.Add(self.input_picker, 1, wx.EXPAND)
|
||||
form.Add((1, 1))
|
||||
|
||||
form.Add(wx.StaticText(panel, label="Mode"), 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
form.Add(self.mode_choice, 0)
|
||||
form.Add((1, 1))
|
||||
|
||||
form.Add(wx.StaticText(panel, label="Format"), 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
form.Add(self.format_choice, 0)
|
||||
form.Add((1, 1))
|
||||
|
||||
form.Add(wx.StaticText(panel, label="Output"), 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
form.Add(self.output_picker, 1, wx.EXPAND)
|
||||
form.Add((1, 1))
|
||||
|
||||
form.Add(wx.StaticText(panel, label="Audio bitrate"), 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
form.Add(self.audio_bitrate, 0)
|
||||
form.Add(wx.StaticText(panel, label="Optional"), 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
|
||||
form.Add(wx.StaticText(panel, label="Video bitrate"), 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
form.Add(self.video_bitrate, 0)
|
||||
form.Add(wx.StaticText(panel, label="Optional"), 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
|
||||
form.Add(wx.StaticText(panel, label=""), 0)
|
||||
form.Add(self.copy_streams, 0)
|
||||
form.Add((1, 1))
|
||||
|
||||
form.AddGrowableCol(1, 1)
|
||||
form = wx.BoxSizer(wx.VERTICAL)
|
||||
self.add_labeled_control(panel, form, "&Input file", self.input_picker, "Input file")
|
||||
self.add_labeled_control(panel, form, "&Mode", self.mode_choice, "Conversion mode")
|
||||
self.add_labeled_control(panel, form, "F&ormat", self.format_choice, "Output format")
|
||||
self.add_labeled_control(panel, form, "O&utput file", self.output_picker, "Output file")
|
||||
self.add_labeled_control(panel, form, "Audio &bitrate", self.audio_bitrate, "Audio bitrate")
|
||||
self.add_labeled_control(panel, form, "Video b&itrate", self.video_bitrate, "Video bitrate")
|
||||
self.add_labeled_control(panel, form, "A&ctivation bytes", self.activation_bytes, "Activation bytes")
|
||||
form.Add(self.copy_streams, 0, wx.EXPAND | wx.BOTTOM, 6)
|
||||
|
||||
main = wx.BoxSizer(wx.VERTICAL)
|
||||
main.Add(form, 0, wx.EXPAND | wx.ALL, 12)
|
||||
main.Add(self.start_btn, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 12)
|
||||
main.Add(self.build_player(panel), 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 12)
|
||||
main.Add(self.log_ctrl, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 12)
|
||||
main.Add(self.status, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 12)
|
||||
main.Add(form, 0, wx.EXPAND | wx.ALL, 10)
|
||||
main.Add(self.start_btn, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)
|
||||
main.Add(self.build_player(panel), 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)
|
||||
main.Add(self.log_ctrl, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 10)
|
||||
main.Add(self.status, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)
|
||||
|
||||
panel.SetSizer(main)
|
||||
|
||||
@@ -149,14 +156,44 @@ class ConverterFrame(wx.Frame):
|
||||
controls.Add(self.stop_btn, 0, wx.RIGHT, 8)
|
||||
controls.Add(self.time_label, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||
|
||||
player.Add(wx.StaticText(panel, label="Audio Player"), 0, wx.BOTTOM, 4)
|
||||
player.Add(self.media, 0, wx.EXPAND | wx.BOTTOM, 6)
|
||||
player.Add(self.position_slider, 0, wx.EXPAND | wx.BOTTOM, 6)
|
||||
player.Add(controls, 0, wx.EXPAND | wx.BOTTOM, 4)
|
||||
player.Add(self.hotkeys_label, 0)
|
||||
|
||||
return player
|
||||
|
||||
def add_labeled_control(self, panel, parent_sizer, label, control, accessible_name=None):
|
||||
label_ctrl = wx.StaticText(panel, label=label)
|
||||
label_ctrl.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
|
||||
clean_label = label.replace("&", "")
|
||||
if accessible_name is None:
|
||||
accessible_name = clean_label
|
||||
# Keep a stable, human-readable name/description for assistive technologies.
|
||||
control.SetName(accessible_name)
|
||||
control.SetHelpText(accessible_name)
|
||||
label_ctrl.SetName(clean_label)
|
||||
# Keep label and field adjacent in tab order for native AT label lookup.
|
||||
if hasattr(label_ctrl, "MoveBeforeInTabOrder"):
|
||||
label_ctrl.MoveBeforeInTabOrder(control)
|
||||
field_sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
field_sizer.Add(label_ctrl, 0, wx.BOTTOM, 2)
|
||||
field_sizer.Add(control, 0, wx.EXPAND)
|
||||
parent_sizer.Add(field_sizer, 0, wx.EXPAND | wx.BOTTOM, 6)
|
||||
|
||||
def configure_file_picker_accessibility(self, picker, label):
|
||||
picker.SetName(label)
|
||||
picker.SetHelpText(label)
|
||||
|
||||
text_ctrl = picker.GetTextCtrl()
|
||||
if text_ctrl:
|
||||
text_ctrl.SetName(f"{label} path")
|
||||
text_ctrl.SetHelpText(label)
|
||||
|
||||
button = picker.GetPickerCtrl()
|
||||
if button:
|
||||
button.SetName(f"Browse {label}")
|
||||
button.SetHelpText(f"Browse {label}")
|
||||
|
||||
def setup_hotkeys(self):
|
||||
self.ID_PLAYPAUSE = wx.NewIdRef()
|
||||
self.ID_STOP = wx.NewIdRef()
|
||||
@@ -313,9 +350,13 @@ class ConverterFrame(wx.Frame):
|
||||
mode = self.mode_choice.GetStringSelection()
|
||||
a_bitrate = self.audio_bitrate.GetValue().strip()
|
||||
v_bitrate = self.video_bitrate.GetValue().strip()
|
||||
activation_bytes = self.activation_bytes.GetValue().strip()
|
||||
copy = self.copy_streams.GetValue()
|
||||
|
||||
cmd = ["ffmpeg", "-y", "-i", in_path]
|
||||
cmd = ["ffmpeg", "-y"]
|
||||
if activation_bytes:
|
||||
cmd += ["-activation_bytes", activation_bytes]
|
||||
cmd += ["-i", in_path]
|
||||
|
||||
if mode == "Audio":
|
||||
cmd.append("-vn")
|
||||
|
||||
Reference in New Issue
Block a user