Skip to content

Commit

Permalink
Release version 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
luziferius committed Nov 28, 2019
1 parent 5513504 commit 03dad38
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
Version 0.1.2 (17.11.2019)

- Gracefully handle missing input files
- Enable @-notation in the argument parser to load arguments from files
- Move first pass encoder logs to the completed temporary directory, so that completed first passes can be skipped.


Version 0.1.1 (16.11.2019)

- Replaced -2/--two-pass with -1/--single-pass. Two-Pass encoding is the new default.
- Per default, use 8 concurrent encodes instead of 2
- Removed tile usage from the default encoder parameters, due to possible frame curruptions
- Removed threading support from the default encoder parameters,
because multiple encoder instances scale more consistently.


Version 0.1.0 (12.11.2019)

- Initial version.
Expand Down
10 changes: 8 additions & 2 deletions av1transcoder/argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ def generate_argument_parser() -> ArgumentParser:
"The output files will only contain video tracks. You have to add back other tracks yourself, " \
"like audio or subtitles, and mux them into the container of your choice. " \
"Files with multiple video tracks are untested and probably won’t work. Filenames that contain esoteric " \
"characters like newlines will probably break the ffmpeg concat demuxer and will likely cause failures."
parser = ArgumentParser(description=description, epilog=epilog)
"characters like newlines will probably break the ffmpeg concat demuxer and will likely cause failures. " \
"\nLong arguments can be abbreviated, as long as the abbreviation is unambiguous. Don’t use this feature " \
"in scripts, because new argument switches might break previously valid abbreviations. Arguments can " \
"be loaded from files using the @-Notation. Use \"@/path/to/file\" to load arguments from the specified " \
"file. The file must contain one argument per line. It may be useful to load a set of common arguments" \
" from a file instead of typing them out on the command line, " \
"when you can re-use the same set of arguments multiple times."
parser = ArgumentParser(description=description, fromfile_prefix_chars="@", epilog=epilog)
parser.add_argument(
"input_files", action="store", type=Path, metavar="input_file", nargs="+",
help="Input video files. All given video files will be transcoded to AV1."
Expand Down
2 changes: 1 addition & 1 deletion av1transcoder/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__version__ = "0.1.1"
__version__ = "0.1.2"


PROGRAMNAME = "av1transcoder"
Expand Down
6 changes: 4 additions & 2 deletions av1transcoder/input_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,11 @@ def read_input_files(arguments: Namespace) -> List[InputFile]:
logger.info("Extracting file data for all input files.")
result: List[InputFile] = list()
for input_file in arguments.input_files:
if not input_file.exists():
logger.warning(f'The given input file "{input_file}" does not exist. Skipping.')
continue
logger.debug(f"Extracting file data for input file: {input_file}")
input_file_path = Path(input_file)
in_file = InputFile(input_file_path, arguments)
in_file = InputFile(input_file, arguments)
in_file.collect_file_data()
if in_file.has_video_data():
logger.debug(f'Input file "{input_file}" contains video streams.'
Expand Down
24 changes: 21 additions & 3 deletions av1transcoder/scene_transcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import itertools
from concurrent.futures import ThreadPoolExecutor
import os
import pathlib
import shutil

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

@property
def two_pass_log_file_prefix(self) -> pathlib.Path:
return self.completed_dir/f"scene_{self.scene.scene_number}"


class AV1LibAomSinglePassEncoderCommandLine(AbstractEncoderCommandLine):
"""
Expand Down Expand Up @@ -117,7 +122,7 @@ def _add_command_line_arguments(self, arguments: Namespace):
self.command_line += [
"-pass", "1",
# TODO: Verify that this works with arbitrary paths
"-passlogfile", str(self.in_progress_dir/f"scene_{self.scene.scene_number}"),
"-passlogfile", str(self.two_pass_log_file_prefix),
"-f", "matroska",
os.devnull
]
Expand Down Expand Up @@ -154,7 +159,7 @@ def _add_command_line_arguments(self, arguments: Namespace):
self.command_line += [
"-pass", "2",
# TODO: Verify that this works with arbitrary paths
"-passlogfile", str(self.in_progress_dir/f"scene_{self.scene.scene_number}"),
"-passlogfile", str(self.two_pass_log_file_prefix),
str(self.in_progress_dir / scene_name)
]
command_line_str = f"[{', '.join(self.command_line)}]"
Expand Down Expand Up @@ -203,6 +208,7 @@ def _transcode_two_pass(arguments: Namespace, input_file: InputFile, scene: Scen
if pass1.handle_directory_creation():
logger.debug(f'Starting first pass for file "{input_file.input_file}".')
pass1.run()
_move_first_pass_log_to_finished_directory(pass1)
pass2 = AV1LibAomTwoPass2EncoderCommandLine(arguments, input_file, scene)
if pass2.handle_directory_creation() and pass1.finished:
logger.debug(f'Starting second pass for file "{input_file.input_file}".')
Expand All @@ -214,7 +220,19 @@ def _move_scene_to_finished_directory(cli: AbstractEncoderCommandLine):
if cli.finished and cli.dump_mode != "only":
encoded_scene = cli.in_progress_dir / f"scene_{cli.scene.scene_number}.mkv"
shutil.move(str(encoded_scene), str(cli.completed_dir))
logger.debug(f'Encoded scene "{encoded_scene}" finished. Moved to the completed directory "{cli.completed_dir}"')
logger.debug(f'Encoded scene "{encoded_scene}" finished. '
f'Moved to the completed directory "{cli.completed_dir}"')


def _move_first_pass_log_to_finished_directory(cli: AV1LibAomTwoPass1EncoderCommandLine):
if cli.finished and cli.dump_mode != "only":
# May have produced multiple logs, if the file contains multiple video tracks.
logs = cli.in_progress_dir.glob(f"{cli.two_pass_log_file_prefix.name}*.log")

for log_file in logs:
shutil.move(str(log_file), cli.completed_dir)
logger.debug(f'Moved {len(logs)} log file{"s" if len(logs) >= 1 else ""} '
f'for scene {cli.scene.scene_number} to the completed directory "{cli.completed_dir}".')


def _cleanup(arguments: Namespace, input_file: InputFile):
Expand Down

0 comments on commit 03dad38

Please sign in to comment.