Make input/output cmd-line args deterministically sorted

This commit is contained in:
Karl Kroening 2017-06-14 02:25:58 -06:00
parent f4025b464f
commit 525b1bf452
3 changed files with 14 additions and 11 deletions

View File

@ -23,6 +23,16 @@ def _get_stream_name(name):
return '[{}]'.format(name) return '[{}]'.format(name)
def _convert_kwargs_to_cmd_line_args(kwargs):
args = []
for k in sorted(kwargs.keys()):
v = kwargs[k]
args.append('-{}'.format(k))
if v:
args.append('{}'.format(v))
return args
def _get_input_args(input_node): def _get_input_args(input_node):
if input_node._name == input.__name__: if input_node._name == input.__name__:
kwargs = copy.copy(input_node._kwargs) kwargs = copy.copy(input_node._kwargs)
@ -34,10 +44,7 @@ def _get_input_args(input_node):
args += ['-f', fmt] args += ['-f', fmt]
if video_size: if video_size:
args += ['-video_size', '{}x{}'.format(video_size[0], video_size[1])] args += ['-video_size', '{}x{}'.format(video_size[0], video_size[1])]
for k, v in kwargs.items(): args += _convert_kwargs_to_cmd_line_args(kwargs)
args.append('-{}'.format(k))
if v:
args.append('{}'.format(v))
args += ['-i', filename] args += ['-i', filename]
else: else:
assert False, 'Unsupported input node: {}'.format(input_node) assert False, 'Unsupported input node: {}'.format(input_node)
@ -95,13 +102,9 @@ def _get_output_args(node, stream_name_map):
kwargs = copy.copy(node._kwargs) kwargs = copy.copy(node._kwargs)
filename = kwargs.pop('filename') filename = kwargs.pop('filename')
fmt = kwargs.pop('format', None) fmt = kwargs.pop('format', None)
if fmt: if fmt:
args += ['-f', fmt] args += ['-f', fmt]
for k, v in kwargs.items(): args += _convert_kwargs_to_cmd_line_args(kwargs)
args.append('-{}'.format(k))
if v:
args.append('{}'.format(v))
args += [filename] args += [filename]
else: else:
assert False, 'Unsupported output node: {}'.format(node) assert False, 'Unsupported output node: {}'.format(node)

View File

@ -187,8 +187,8 @@ def test_pipe():
assert args == [ assert args == [
'-f', 'rawvideo', '-f', 'rawvideo',
'-video_size', '{}x{}'.format(width, height), '-video_size', '{}x{}'.format(width, height),
'-pixel_format', 'rgb24',
'-framerate', '10', '-framerate', '10',
'-pixel_format', 'rgb24',
'-i', 'pipe:0', '-i', 'pipe:0',
'-filter_complex', '-filter_complex',
'[0]trim=start_frame=2[v0]', '[0]trim=start_frame=2[v0]',

View File

@ -7,7 +7,7 @@
envlist = py27, py33, py34, py35, py36, pypy envlist = py27, py33, py34, py35, py36, pypy
[testenv] [testenv]
commands = py.test commands = py.test -vv
deps = deps =
future future
pytest pytest