8000 Make input/output cmd-line args deterministically sorted · dreamCodeMan/ffmpeg-python@525b1bf · GitHub
[go: up one dir, main page]

Skip to content

Commit 525b1bf

Browse files
committed
Make input/output cmd-line args deterministically sorted
1 parent f4025b4 commit 525b1bf

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

ffmpeg/_run.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ def _get_stream_name(name):
2323
return '[{}]'.format(name)
2424

2525

26+
def _convert_kwargs_to_cmd_line_args(kwargs):
27+
args = []
28+
for k in sorted(kwargs.keys()):
29+
v = kwargs[k]
30+
args.append('-{}'.format(k))
31+
if v:
32+
args.append('{}'.format(v))
33+
return args
34+
35+
2636
def _get_input_args(input_node):
2737
if input_node._name == input.__name__:
2838
kwargs = copy.copy(input_node._kwargs)
@@ -34,10 +44,7 @@ def _get_input_args(input_node):
3444
args += ['-f', fmt]
3545
if video_size:
3646
args += ['-video_size', '{}x{}'.format(video_size[0], video_size[1])]
37-
for k, v in kwargs.items():
38-
args.append('-{}'.format(k))
39-
if v:
40-
args.append('{}'.format(v))
47+
args += _convert_kwargs_to_cmd_line_args(kwargs)
4148
args += ['-i', filename]
4249
else:
4350
assert False, 'Unsupported input node: {}'.format(input_node)
@@ -95,13 +102,9 @@ def _get_output_args(node, stream_name_map):
95102
kwargs = copy.copy(node._kwargs)
96103
filename = kwargs.pop('filename')
97104
fmt = kwargs.pop('format', None)
98-
99105
if fmt:
100106
args += ['-f', fmt]
101-
for k, v in kwargs.items():
102-
args.append('-{}'.format(k))
103-
if v:
104-
args.append('{}'.format(v))
107+
args += _convert_kwargs_to_cmd_line_args(kwargs)
105108
args += [filename]
106109
else:
107110
assert False, 'Unsupported output node: {}'.format(node)

ffmpeg/tests/test_ffmpeg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ def test_pipe():
187187
assert args == [
188188
'-f', 'rawvideo',
189189
'-video_size', '{}x{}'.format(width, height),
190-
'-pixel_format', 'rgb24',
191190
'-framerate', '10',
191+
'-pixel_format', 'rgb24',
192192
'-i', 'pipe:0',
193193
'-filter_complex',
194194
'[0]trim=start_frame=2[v0]',

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
envlist = py27, py33, py34, py35, py36, pypy
88

99
[testenv]
10-
commands = py.test
10+
commands = py.test -vv
1111
deps =
1212
future
1313
pytest

0 commit comments

Comments
 (0)
0