8000 #30: add `global_args` operator by kkroening · Pull Request #83 · kkroening/ffmpeg-python · GitHub
[go: up one dir, main page]

Skip to content
8000

#30: add global_args operator #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
Next Next commit
#30: add global_args operator
  • Loading branch information
kkroening committed May 9, 2018
commit 3e68bc8c9a518f1570998454e87484cded33c844
9 changes: 8 additions & 1 deletion ffmpeg/_ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@ def input(filename, **kwargs):
return InputNode(input.__name__, kwargs=kwargs).stream()


@output_operator()
def global_args(stream, *args):
"""Add extra global command-line argument(s), e.g. ``-progress``.
"""
return GlobalNode(stream, global_args.__name__, args).stream()


@output_operator()
def overwrite_output(stream):
"""Overwrite output files without asking (ffmpeg ``-y`` option)

Official documentation: `Main options <https://ffmpeg.org/ffmpeg.html#Main-options>`__
"""
return GlobalNode(stream, overwrite_output.__name__).stream()
return GlobalNode(stream, overwrite_output.__name__, ['-y']).stream()


@output_operator()
Expand Down
6 changes: 1 addition & 5 deletions ffmpeg/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from ._ffmpeg import (
input,
output,
overwrite_output,
)
from .nodes import (
get_stream_spec_nodes,
Expand Down Expand Up @@ -92,10 +91,7 @@ def _get_filter_arg(filter_nodes, outgoing_edge_maps, stream_name_map):


def _get_global_args(node):
if node.name == overwrite_output.__name__:
return ['-y']
else:
raise ValueError('Unsupported global node: {}'.format(node))
return list(node.args)


def _get_output_args(node, stream_name_map):
9858 Expand Down
5 changes: 5 additions & 0 deletions ffmpeg/tests/test_ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ def test_get_args_simple():
assert out_file.get_args() == ['-i', 'dummy.mp4', 'dummy2.mp4']


def test_global_args():
out_file = ffmpeg.input('dummy.mp4').output('dummy2.mp4').global_args('-progress', 'someurl')
assert out_file.get_args() == ['-i', 'dummy.mp4', 'dummy2.mp4', '-progress', 'someurl']


def _get_complex_filter_example():
split = (ffmpeg
.input(TEST_INPUT_FILE1)
Expand Down
0