8000 Support video_size output tuple · Powercoder64/ffmpeg-python@c21e8c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit c21e8c1

Browse files
committed
Support video_size output tuple
1 parent 593cd3e commit c21e8c1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

ffmpeg/_run.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from __future__ import unicode_literals
2-
32
from .dag import get_outgoing_edges, topo_sort
43
from ._utils import basestring
54
from builtins import str
65
from functools import reduce
7-
from past.builtins import basestring
6+
import collections
87
import copy
98
import operator
109
import subprocess
@@ -123,6 +122,11 @@ def _get_output_args(node, stream_name_map):
123122
fmt = kwargs.pop('format', None)
124123
if fmt:
125124
args += ['-f', fmt]
125+
if 'video_size' in kwargs:
126+
video_size = kwargs.pop('video_size')
127+
if not isinstance(video_size, basestring) and isinstance(video_size, collections.Iterable):
128+
video_size = '{}x{}'.format(video_size[0], video_size[1])
129+
args += ['-video_size', video_size]
126130
args += _convert_kwargs_to_cmd_line_args(kwargs)
127131
args += [filename]
128132
return args

ffmpeg/tests/test_ffmpeg.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,17 @@ def test_filter_asplit():
237237
]
238238

239239

240+
@pytest.mark.parametrize('video_size', [(320, 240), '320x240'])
241+
def test__output__video_size(video_size):
242+
args = (
243+
ffmpeg
244+
.input('in')
245+
.output('out', video_size=video_size)
246+
.get_args()
247+
)
248+
assert args == ['-i', 'in', '-video_size', '320x240', 'out']
249+
250+
240251
def test_filter_normal_arg_escape():
241252
"""Test string escaping of normal filter args (e.g. ``font`` param of ``drawtext`` filter)."""
242253
def _get_drawtext_font_repr(font):

0 commit comments

Comments
 (0)
0