diff --git a/ffmpeg/_utils.py b/ffmpeg/_utils.py index d41f2fd..92d7611 100644 --- a/ffmpeg/_utils.py +++ b/ffmpeg/_utils.py @@ -3,6 +3,8 @@ from builtins import str from past.builtins import basestring import hashlib import sys +import collections + if sys.version_info.major == 2: # noinspection PyUnresolvedReferences,PyShadowingBuiltins @@ -91,6 +93,12 @@ def convert_kwargs_to_cmd_line_args(kwargs): args = [] for k in sorted(kwargs.keys()): v = kwargs[k] + if isinstance(v, collections.Iterable) and not isinstance(v, str): + for value in v: + args.append('-{}'.format(k)) + if value is not None: + args.append('{}'.format(value)) + continue args.append('-{}'.format(k)) if v is not None: args.append('{}'.format(v)) diff --git a/ffmpeg/tests/test_ffmpeg.py b/ffmpeg/tests/test_ffmpeg.py index 279a323..0d600f2 100644 --- a/ffmpeg/tests/test_ffmpeg.py +++ b/ffmpeg/tests/test_ffmpeg.py @@ -9,6 +9,7 @@ import random import re import subprocess + try: import mock # python 2 except ImportError: @@ -114,6 +115,10 @@ def test_stream_repr(): dummy_out.label, dummy_out.node.short_hash ) +def test_repeated_args(): + out_file = ffmpeg.input('dummy.mp4').output('dummy2.mp4', streamid=['0:0x101', '1:0x102']) + assert out_file.get_args() == ['-i', 'dummy.mp4', '-streamid', '0:0x101', '-streamid', '1:0x102', 'dummy2.mp4'] + def test__get_args__simple(): out_file = ffmpeg.input('dummy.mp4').output('dummy2.mp4')