8000 #30: add `global_args` operator · dreamCodeMan/ffmpeg-python@3e68bc8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e68bc8

Browse files
committed
kkroening#30: add global_args operator
1 parent 7077eaa commit 3e68bc8

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

ffmpeg/_ffmpeg.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,20 @@ def input(filename, **kwargs):
2626
return InputNode(input.__name__, kwargs=kwargs).stream()
2727

2828

29+
@output_operator()
30+
def global_args(stream, *args):
31+
"""Add extra global command-line argument(s), e.g. ``-progress``.
32+
"""
33+
return GlobalNode(stream, global_args.__name__, args).stream()
34+
35+
2936
@output_operator()
3037
def overwrite_output(stream):
3138
"""Overwrite output files without asking (ffmpeg ``-y`` option)
3239
3340
Official documentation: `Main options <https://ffmpeg.org/ffmpeg.html#Main-options>`__
3441
"""
35-
return GlobalNode(stream, overwrite_output.__name__).stream()
42+
return GlobalNode(stream, overwrite_output.__name__, ['-y']).stream()
3643

3744

3845
@output_operator()

ffmpeg/_run.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from ._ffmpeg import (
1111
input,
1212
output,
13-
overwrite_output,
1413
)
1514
from .nodes import (
1615
get_stream_spec_nodes,
@@ -92,10 +91,7 @@ def _get_filter_arg(filter_nodes, outgoing_edge_maps, stream_name_map):
9291

9392

9493
def _get_global_args(node):
95-
if node.name == overwrite_output.__name__:
96-
return ['-y']
97-
else:
98-
raise ValueError('Unsupported global node: {}'.format(node))
94+
return list(node.args)
9995

10096

10197
def _get_output_args(node, stream_name_map):

ffmpeg/tests/test_ffmpeg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ def test_get_args_simple():
105105
assert out_file.get_args() == ['-i', 'dummy.mp4', 'dummy2.mp4']
106106

107107

108+
def test_global_args():
109+
out_file = ffmpeg.input('dummy.mp4').output('dummy2.mp4').global_args('-progress', 'someurl')
110+
assert out_file.get_args() == ['-i', 'dummy.mp4', 'dummy2.mp4', '-progress', 'someurl']
111+
112+
108113
def _get_complex_filter_example():
109114
split = (ffmpeg
110115
.input(TEST_INPUT_FILE1)

0 commit comments

Comments
 (0)
0