mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-09-22 14:39:58 +08:00
parent
5916891bbf
commit
217bd2bde6
@ -57,13 +57,19 @@ def _get_input_args(input_node):
|
|||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def _format_input_stream_name(stream_name_map, edge):
|
def _format_input_stream_name(stream_name_map, edge, is_final_arg=False):
|
||||||
prefix = stream_name_map[edge.upstream_node, edge.upstream_label]
|
prefix = stream_name_map[edge.upstream_node, edge.upstream_label]
|
||||||
if not edge.upstream_selector:
|
if not edge.upstream_selector:
|
||||||
suffix = ''
|
suffix = ''
|
||||||
else:
|
else:
|
||||||
suffix = ':{}'.format(edge.upstream_selector)
|
suffix = ':{}'.format(edge.upstream_selector)
|
||||||
return '[{}{}]'.format(prefix, suffix)
|
if is_final_arg and isinstance(edge.upstream_node, InputNode):
|
||||||
|
## Special case: `-map` args should not have brackets for input
|
||||||
|
## nodes.
|
||||||
|
fmt = '{}{}'
|
||||||
|
else:
|
||||||
|
fmt = '[{}{}]'
|
||||||
|
return fmt.format(prefix, suffix)
|
||||||
|
|
||||||
|
|
||||||
def _format_output_stream_name(stream_name_map, edge):
|
def _format_output_stream_name(stream_name_map, edge):
|
||||||
@ -113,8 +119,8 @@ def _get_output_args(node, stream_name_map):
|
|||||||
|
|
||||||
for edge in node.incoming_edges:
|
for edge in node.incoming_edges:
|
||||||
# edge = node.incoming_edges[0]
|
# edge = node.incoming_edges[0]
|
||||||
stream_name = _format_input_stream_name(stream_name_map, edge)
|
stream_name = _format_input_stream_name(stream_name_map, edge, is_final_arg=True)
|
||||||
if stream_name != '[0]' or len(node.incoming_edges) > 1:
|
if stream_name != '0' or len(node.incoming_edges) > 1:
|
||||||
args += ['-map', stream_name]
|
args += ['-map', stream_name]
|
||||||
|
|
||||||
kwargs = copy.copy(node.kwargs)
|
kwargs = copy.copy(node.kwargs)
|
||||||
|
@ -165,8 +165,8 @@ def test_combined_output():
|
|||||||
assert out.get_args() == [
|
assert out.get_args() == [
|
||||||
'-i', TEST_INPUT_FILE1,
|
'-i', TEST_INPUT_FILE1,
|
||||||
'-i', TEST_OVERLAY_FILE,
|
'-i', TEST_OVERLAY_FILE,
|
||||||
'-map', '[0]',
|
'-map', '0',
|
||||||
'-map', '[1]',
|
'-map', '1',
|
||||||
TEST_OUTPUT_FILE1
|
TEST_OUTPUT_FILE1
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -186,6 +186,7 @@ def test_filter_with_selector():
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_item_with_bad_selectors():
|
def test_get_item_with_bad_selectors():
|
||||||
input = ffmpeg.input(TEST_INPUT_FILE1)
|
input = ffmpeg.input(TEST_INPUT_FILE1)
|
||||||
|
|
||||||
@ -532,18 +533,50 @@ def test_multi_passthrough():
|
|||||||
'-i', 'in1.mp4',
|
'-i', 'in1.mp4',
|
||||||
'-i', 'in2.mp4',
|
'-i', 'in2.mp4',
|
||||||
'out1.mp4',
|
'out1.mp4',
|
||||||
'-map', '[1]', # FIXME: this should not be here (see #23)
|
'-map', '1',
|
||||||
'out2.mp4'
|
'out2.mp4'
|
||||||
]
|
]
|
||||||
assert ffmpeg.get_args([out1, out2]) == [
|
assert ffmpeg.get_args([out1, out2]) == [
|
||||||
'-i', 'in2.mp4',
|
'-i', 'in2.mp4',
|
||||||
'-i', 'in1.mp4',
|
'-i', 'in1.mp4',
|
||||||
'out2.mp4',
|
'out2.mp4',
|
||||||
'-map', '[1]', # FIXME: this should not be here (see #23)
|
'-map', '1',
|
||||||
'out1.mp4'
|
'out1.mp4'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_passthrough_selectors():
|
||||||
|
i1 = ffmpeg.input(TEST_INPUT_FILE1)
|
||||||
|
args = (
|
||||||
|
ffmpeg
|
||||||
|
.output(i1['1'], i1['2'], TEST_OUTPUT_FILE1)
|
||||||
|
.get_args()
|
||||||
|
)
|
||||||
|
assert args == [
|
||||||
|
'-i', TEST_INPUT_FILE1,
|
||||||
|
'-map', '0:1',
|
||||||
|
'-map', '0:2',
|
||||||
|
TEST_OUTPUT_FILE1,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_mixed_passthrough_selectors():
|
||||||
|
i1 = ffmpeg.input(TEST_INPUT_FILE1)
|
||||||
|
args = (
|
||||||
|
ffmpeg
|
||||||
|
.output(i1['1'].hflip(), i1['2'], TEST_OUTPUT_FILE1)
|
||||||
|
.get_args()
|
||||||
|
)
|
||||||
|
assert args == [
|
||||||
|
'-i', TEST_INPUT_FILE1,
|
||||||
|
'-filter_complex',
|
||||||
|
'[0:1]hflip[s0]',
|
||||||
|
'-map', '[s0]',
|
||||||
|
'-map', '0:2',
|
||||||
|
TEST_OUTPUT_FILE1,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_pipe():
|
def test_pipe():
|
||||||
width = 32
|
width = 32
|
||||||
height = 32
|
height = 32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user