|
9 | 9 | from fastflix.language import t |
10 | 10 | from fastflix.models.encode import ModifySettings |
11 | 11 | from fastflix.models.fastflix_app import FastFlixApp |
12 | | -from fastflix.shared import message |
| 12 | +from fastflix.shared import message, yes_no_message |
13 | 13 | from fastflix.widgets.background_tasks import AudioNoramlize |
14 | 14 | from fastflix.resources import loading_movie, get_icon |
15 | 15 |
|
@@ -40,17 +40,21 @@ def __init__(self, parent, main, app: FastFlixApp): |
40 | 40 | grid.addWidget(self.audio_normalize, 2, 0, 1, 1) |
41 | 41 | grid.addWidget(self.extract_label, 2, 2, 1, 1) |
42 | 42 |
|
| 43 | + self.audio_format_combo = QtWidgets.QComboBox() |
| 44 | + self.audio_format_combo.addItems(self.app.fastflix.config.sane_audio_selection) |
| 45 | + grid.addWidget(self.audio_format_combo, 2, 1, 1, 1) |
| 46 | + |
43 | 47 | add_audio_track = QtWidgets.QPushButton(t("Add Audio Track")) |
44 | 48 | add_audio_track.clicked.connect(self.select_audio_file) |
45 | 49 | self.add_audio_track_file_path = QtWidgets.QLineEdit() |
46 | 50 | grid.addWidget(add_audio_track, 3, 0, 1, 1) |
47 | | - grid.addWidget(self.add_audio_track_file_path, 3, 2, 1, 1) |
| 51 | + grid.addWidget(self.add_audio_track_file_path, 3, 1, 1, 2) |
48 | 52 |
|
49 | 53 | add_sub_track = QtWidgets.QPushButton(t("Add Text Based Subtitle Track")) |
50 | 54 | add_sub_track.clicked.connect(self.select_subtitle_file) |
51 | 55 | self.add_sub_track_file_path = QtWidgets.QLineEdit() |
52 | 56 | grid.addWidget(add_sub_track, 4, 0, 1, 1) |
53 | | - grid.addWidget(self.add_sub_track_file_path, 4, 2, 1, 1) |
| 57 | + grid.addWidget(self.add_sub_track_file_path, 4, 1, 1, 2) |
54 | 58 |
|
55 | 59 | grid.addWidget(QtWidgets.QWidget(), 6, 0, 6, 1) |
56 | 60 | grid.addLayout(self._add_custom(disable_both_passes=True), 11, 0, 1, 6) |
@@ -85,7 +89,26 @@ def select_subtitle_file(self): |
85 | 89 | self.main.build_commands() |
86 | 90 |
|
87 | 91 | def select_run_audio_normalize(self): |
88 | | - self.norm_thread = AudioNoramlize(self.app, self.main, self.signal) |
| 92 | + try: |
| 93 | + in_path = Path(self.app.fastflix.current_video.source) |
| 94 | + out_path = Path(self.app.fastflix.current_video.video_settings.output_path) |
| 95 | + assert in_path.exists() |
| 96 | + assert out_path.parent.exists() |
| 97 | + except Exception: |
| 98 | + message(t("Please make sure the source and output files are specified")) |
| 99 | + return |
| 100 | + |
| 101 | + audio_type = self.audio_format_combo.currentText() |
| 102 | + resp = yes_no_message( |
| 103 | + t("This will run the audio normalization process on all streams of") |
| 104 | + + f"\n{in_path}\n" |
| 105 | + + t("and create an output file with audio format ") |
| 106 | + + f"{audio_type}\n@ {out_path}\n", |
| 107 | + title="Audio Normalization", |
| 108 | + ) |
| 109 | + if not resp: |
| 110 | + return |
| 111 | + self.norm_thread = AudioNoramlize(self.app, self.main, audio_type, self.signal) |
89 | 112 | self.norm_thread.start() |
90 | 113 | self.movie.start() |
91 | 114 | self.extract_label.show() |
|
0 commit comments