Skip to content

Commit 03dad38

Browse files
committed
Release version 0.1.2
1 parent 5513504 commit 03dad38

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

CHANGES

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
Version 0.1.2 (17.11.2019)
2+
3+
- Gracefully handle missing input files
4+
- Enable @-notation in the argument parser to load arguments from files
5+
- Move first pass encoder logs to the completed temporary directory, so that completed first passes can be skipped.
6+
7+
18
Version 0.1.1 (16.11.2019)
9+
210
- Replaced -2/--two-pass with -1/--single-pass. Two-Pass encoding is the new default.
311
- Per default, use 8 concurrent encodes instead of 2
412
- Removed tile usage from the default encoder parameters, due to possible frame curruptions
513
- Removed threading support from the default encoder parameters,
614
because multiple encoder instances scale more consistently.
715

16+
817
Version 0.1.0 (12.11.2019)
918

1019
- Initial version.

av1transcoder/argument_parser.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,14 @@ def generate_argument_parser() -> ArgumentParser:
6666
"The output files will only contain video tracks. You have to add back other tracks yourself, " \
6767
"like audio or subtitles, and mux them into the container of your choice. " \
6868
"Files with multiple video tracks are untested and probably won’t work. Filenames that contain esoteric " \
69-
"characters like newlines will probably break the ffmpeg concat demuxer and will likely cause failures."
70-
parser = ArgumentParser(description=description, epilog=epilog)
69+
"characters like newlines will probably break the ffmpeg concat demuxer and will likely cause failures. " \
70+
"\nLong arguments can be abbreviated, as long as the abbreviation is unambiguous. Don’t use this feature " \
71+
"in scripts, because new argument switches might break previously valid abbreviations. Arguments can " \
72+
"be loaded from files using the @-Notation. Use \"@/path/to/file\" to load arguments from the specified " \
73+
"file. The file must contain one argument per line. It may be useful to load a set of common arguments" \
74+
" from a file instead of typing them out on the command line, " \
75+
"when you can re-use the same set of arguments multiple times."
76+
parser = ArgumentParser(description=description, fromfile_prefix_chars="@", epilog=epilog)
7177
parser.add_argument(
7278
"input_files", action="store", type=Path, metavar="input_file", nargs="+",
7379
help="Input video files. All given video files will be transcoded to AV1."

av1transcoder/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# You should have received a copy of the GNU General Public License
1414
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515

16-
__version__ = "0.1.1"
16+
__version__ = "0.1.2"
1717

1818

1919
PROGRAMNAME = "av1transcoder"

av1transcoder/input_file.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,11 @@ def read_input_files(arguments: Namespace) -> List[InputFile]:
315315
logger.info("Extracting file data for all input files.")
316316
result: List[InputFile] = list()
317317
for input_file in arguments.input_files:
318+
if not input_file.exists():
319+
logger.warning(f'The given input file "{input_file}" does not exist. Skipping.')
320+
continue
318321
logger.debug(f"Extracting file data for input file: {input_file}")
319-
input_file_path = Path(input_file)
320-
in_file = InputFile(input_file_path, arguments)
322+
in_file = InputFile(input_file, arguments)
321323
in_file.collect_file_data()
322324
if in_file.has_video_data():
323325
logger.debug(f'Input file "{input_file}" contains video streams.'

av1transcoder/scene_transcode.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import itertools
2323
from concurrent.futures import ThreadPoolExecutor
2424
import os
25+
import pathlib
2526
import shutil
2627

2728
from av1transcoder.argument_parser import Namespace
@@ -63,6 +64,10 @@ def _add_common_encoder_options(self, arguments: Namespace):
6364
# Add the custom encoder parameters, filtering out empty elements
6465
self.command_line += [param for param in arguments.encoder_parameters.split(" ") if param]
6566

67+
@property
68+
def two_pass_log_file_prefix(self) -> pathlib.Path:
69+
return self.completed_dir/f"scene_{self.scene.scene_number}"
70+
6671

6772
class AV1LibAomSinglePassEncoderCommandLine(AbstractEncoderCommandLine):
6873
"""
@@ -117,7 +122,7 @@ def _add_command_line_arguments(self, arguments: Namespace):
117122
self.command_line += [
118123
"-pass", "1",
119124
# TODO: Verify that this works with arbitrary paths
120-
"-passlogfile", str(self.in_progress_dir/f"scene_{self.scene.scene_number}"),
125+
"-passlogfile", str(self.two_pass_log_file_prefix),
121126
"-f", "matroska",
122127
os.devnull
123128
]
@@ -154,7 +159,7 @@ def _add_command_line_arguments(self, arguments: Namespace):
154159
self.command_line += [
155160
"-pass", "2",
156161
# TODO: Verify that this works with arbitrary paths
157-
"-passlogfile", str(self.in_progress_dir/f"scene_{self.scene.scene_number}"),
162+
"-passlogfile", str(self.two_pass_log_file_prefix),
158163
str(self.in_progress_dir / scene_name)
159164
]
160165
command_line_str = f"[{', '.join(self.command_line)}]"
@@ -203,6 +208,7 @@ def _transcode_two_pass(arguments: Namespace, input_file: InputFile, scene: Scen
203208
if pass1.handle_directory_creation():
204209
logger.debug(f'Starting first pass for file "{input_file.input_file}".')
205210
pass1.run()
211+
_move_first_pass_log_to_finished_directory(pass1)
206212
pass2 = AV1LibAomTwoPass2EncoderCommandLine(arguments, input_file, scene)
207213
if pass2.handle_directory_creation() and pass1.finished:
208214
logger.debug(f'Starting second pass for file "{input_file.input_file}".')
@@ -214,7 +220,19 @@ def _move_scene_to_finished_directory(cli: AbstractEncoderCommandLine):
214220
if cli.finished and cli.dump_mode != "only":
215221
encoded_scene = cli.in_progress_dir / f"scene_{cli.scene.scene_number}.mkv"
216222
shutil.move(str(encoded_scene), str(cli.completed_dir))
217-
logger.debug(f'Encoded scene "{encoded_scene}" finished. Moved to the completed directory "{cli.completed_dir}"')
223+
logger.debug(f'Encoded scene "{encoded_scene}" finished. '
224+
f'Moved to the completed directory "{cli.completed_dir}"')
225+
226+
227+
def _move_first_pass_log_to_finished_directory(cli: AV1LibAomTwoPass1EncoderCommandLine):
228+
if cli.finished and cli.dump_mode != "only":
229+
# May have produced multiple logs, if the file contains multiple video tracks.
230+
logs = cli.in_progress_dir.glob(f"{cli.two_pass_log_file_prefix.name}*.log")
231+
232+
for log_file in logs:
233+
shutil.move(str(log_file), cli.completed_dir)
234+
logger.debug(f'Moved {len(logs)} log file{"s" if len(logs) >= 1 else ""} '
235+
f'for scene {cli.scene.scene_number} to the completed directory "{cli.completed_dir}".')
218236

219237

220238
def _cleanup(arguments: Namespace, input_file: InputFile):

0 commit comments

Comments
 (0)