8000 Support video_size output tuple by kkroening · Pull Request #88 · kkroening/ffmpeg-python · GitHub
[go: up one dir, main page]

Skip to content

Support video_size output tuple #88

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 1 commit into from
Jun 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
Diff view
Diff view
8 changes: 6 additions & 2 deletions ffmpeg/_run.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from __future__ import unicode_literals

from .dag import get_outgoing_edges, topo_sort
from ._utils import basestring
from builtins import str
from functools import reduce
from past.builtins import basestring
import collections
import copy
import operator
import subprocess
Expand Down Expand Up @@ -123,6 +122,11 @@ def _get_output_args(node, stream_name_map):
fmt = kwargs.pop('format', None)
if fmt:
args += ['-f', fmt]
if 'video_size' in kwargs:
video_size = kwargs.pop('video_size')
if not isinstance(video_size, basestring) and isinstance(video_size, collections.Iterable):
video_size = '{}x{}'.format(video_size[0], video_size[1])
args += ['-video_size', video_size]
args += _convert_kwargs_to_cmd_line_args(kwargs)
args += [filename]
return args
Expand Down
11 changes: 11 additions & 0 deletions ffmpeg/tests/test_ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@ def test_filter_asplit():
]


@pytest.mark.parametrize('video_size', [(320, 240), '320x240'])
def test__output__video_size(video_size):
args = (
ffmpeg
.input('in')
.output('out', video_size=video_size)
.get_args()
)
assert args == ['-i', 'in', '-video_size', '320x240', 'out']


def test_filter_normal_arg_escape():
"""Test string escaping of normal filter args (e.g. ``font`` param of ``drawtext`` filter)."""
def _get_drawtext_font_repr(font):
Expand Down
0