|
|
|
@ -37,7 +37,7 @@ from pathlib import Path, PurePath |
|
|
|
|
|
|
|
|
|
__all__ = "AdvancedAVError", "AdvancedAV", "SimpleAV", "MultiAV" |
|
|
|
|
|
|
|
|
|
version_info = 2, 99, 6 |
|
|
|
|
version_info = 2, 99, 7 |
|
|
|
|
|
|
|
|
|
# Constants |
|
|
|
|
DEFAULT_CONTAINER = "matroska" |
|
|
|
@ -198,6 +198,8 @@ class ObjectWithOptions: |
|
|
|
|
""" |
|
|
|
|
__slots__ = () |
|
|
|
|
|
|
|
|
|
local_option_names = () |
|
|
|
|
|
|
|
|
|
def __init__(self, *, options=None, **more): |
|
|
|
|
super().__init__(**more) |
|
|
|
|
self.options = options or {} |
|
|
|
@ -231,6 +233,13 @@ class ObjectWithOptions: |
|
|
|
|
self.options.update(options) |
|
|
|
|
return self |
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
def ffmpeg_options(self): |
|
|
|
|
if self.local_option_names: |
|
|
|
|
return {k: v for k, v in self.options.items() if k not in self.local_option_names} |
|
|
|
|
else: |
|
|
|
|
return self.options |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ObjectWithMetadata: |
|
|
|
|
__slots__ = () |
|
|
|
@ -665,7 +674,7 @@ class InputFile(File): |
|
|
|
|
|
|
|
|
|
def generate_args(self) -> Iterator: |
|
|
|
|
# Input options |
|
|
|
|
yield from FFmpeg.argv_options(self.options) |
|
|
|
|
yield from FFmpeg.argv_options(self.ffmpeg_options) |
|
|
|
|
|
|
|
|
|
# Add Input |
|
|
|
|
yield "-i" |
|
|
|
@ -776,6 +785,8 @@ class OutputFile(File, ObjectWithMetadata): |
|
|
|
|
""" |
|
|
|
|
__slots__ = "task", "container", "_mapped_sources", "metadata" |
|
|
|
|
|
|
|
|
|
local_option_names = ("reorder_streams",) + File.local_option_names |
|
|
|
|
|
|
|
|
|
stream_factory = staticmethod(output_stream_factory) |
|
|
|
|
|
|
|
|
|
def __init__(self, task: "Task", name: str, container=DEFAULT_CONTAINER, |
|
|
|
@ -783,6 +794,7 @@ class OutputFile(File, ObjectWithMetadata): |
|
|
|
|
super().__init__(name, options=options, metadata=metadata) |
|
|
|
|
|
|
|
|
|
self.options.setdefault("c", "copy") |
|
|
|
|
self.options.setdefault("reorder_streams", True) |
|
|
|
|
|
|
|
|
|
self.task = task |
|
|
|
|
|
|
|
|
@ -795,9 +807,10 @@ class OutputFile(File, ObjectWithMetadata): |
|
|
|
|
def generate_args(self) -> Iterator: |
|
|
|
|
# Global Metadata & Additional Options |
|
|
|
|
yield from FFmpeg.argv_metadata(self.metadata) |
|
|
|
|
yield from FFmpeg.argv_options(self.options) |
|
|
|
|
yield from FFmpeg.argv_options(self.ffmpeg_options) |
|
|
|
|
|
|
|
|
|
# Map Streams, sorted by type |
|
|
|
|
if self.options["reorder_streams"]: |
|
|
|
|
self.reorder_streams() |
|
|
|
|
|
|
|
|
|
for stream in self.streams: |
|
|
|
@ -809,7 +822,7 @@ class OutputFile(File, ObjectWithMetadata): |
|
|
|
|
yield stream.codec |
|
|
|
|
|
|
|
|
|
yield from FFmpeg.argv_metadata(stream.metadata, stream.stream_spec) |
|
|
|
|
yield from FFmpeg.argv_options(stream.options, stream.stream_spec) |
|
|
|
|
yield from FFmpeg.argv_options(stream.ffmpeg_options, stream.stream_spec) |
|
|
|
|
|
|
|
|
|
# Container |
|
|
|
|
if self.container is not None: |
|
|
|
|