| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,13 +57,19 @@ def _get_input_args(input_node): | |||
| 57 | 57 | return args | |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | - def _format_input_stream_name(stream_name_map, edge): | ||
| 60 | + def _format_input_stream_name(stream_name_map, edge, is_final_arg=False): | ||
| 61 | 61 | prefix = stream_name_map[edge.upstream_node, edge.upstream_label] | |
| 62 | 62 | if not edge.upstream_selector: | |
| 63 | 63 | suffix = '' | |
| 64 | 64 | else: | |
| 65 | 65 | suffix = ':{}'.format(edge.upstream_selector) | |
| 66 | - return '[{}{}]'.format(prefix, suffix) | ||
| 66 | + if is_final_arg and isinstance(edge.upstream_node, InputNode): | ||
| 67 | + ## Special case: `-map` args should not have brackets for input | ||
| 68 | + ## nodes. | ||
| 69 | + fmt = '{}{}' | ||
| 70 | + else: | ||
| 71 | + fmt = '[{}{}]' | ||
| 72 | + return fmt.format(prefix, suffix) | ||
| 67 | 73 | ||
| 68 | 74 | ||
| 69 | 75 | def _format_output_stream_name(stream_name_map, edge): | |
@@ -113,8 +119,8 @@ def _get_output_args(node, stream_name_map): | |||
| 113 | 119 | ||
| 114 | 120 | for edge in node.incoming_edges: | |
| 115 | 121 | # edge = node.incoming_edges[0] | |
| 116 | - stream_name = _format_input_stream_name(stream_name_map, edge) | ||
| 117 | - if stream_name != '[0]' or len(node.incoming_edges) > 1: | ||
| 122 | + stream_name = _format_input_stream_name(stream_name_map, edge, is_final_arg=True) | ||
| 123 | + if stream_name != '0' or len(node.incoming_edges) > 1: | ||
| 118 | 124 | args += ['-map', stream_name] | |
| 119 | 125 | ||
| 120 | 126 | kwargs = copy.copy(node.kwargs) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -165,8 +165,8 @@ def test_combined_output(): | |||
| 165 | 165 | assert out.get_args() == [ | |
| 166 | 166 | '-i', TEST_INPUT_FILE1, | |
| 167 | 167 | '-i', TEST_OVERLAY_FILE, | |
| 168 | - '-map', '[0]', | ||
| 169 | - '-map', '[1]', | ||
| 168 | + '-map', '0', | ||
| 169 | + '-map', '1', | ||
| 170 | 170 | TEST_OUTPUT_FILE1 | |
| 171 | 171 | ] | |
| 172 | 172 | ||
@@ -186,6 +186,7 @@ def test_filter_with_selector(): | |||
| 186 | 186 | ] | |
| 187 | 187 | ||
| 188 | 188 | ||
| 189 | + | ||
| 189 | 190 | def test_get_item_with_bad_selectors(): | |
| 190 | 191 | input = ffmpeg.input(TEST_INPUT_FILE1) | |
| 191 | 192 | ||
@@ -532,18 +533,50 @@ def test_multi_passthrough(): | |||
| 532 | 533 | '-i', 'in1.mp4', | |
| 533 | 534 | '-i', 'in2.mp4', | |
| 534 | 535 | 'out1.mp4', | |
| 535 | - '-map', '[1]', # FIXME: this should not be here (see #23) | ||
| 536 | + '-map', '1', | ||
| 536 | 537 | 'out2.mp4' | |
| 537 | 538 | ] | |
| 538 | 539 | assert ffmpeg.get_args([out1, out2]) == [ | |
| 539 | 540 | '-i', 'in2.mp4', | |
| 540 | 541 | '-i', 'in1.mp4', | |
| 541 | 542 | 'out2.mp4', | |
| 542 | - '-map', '[1]', # FIXME: this should not be here (see #23) | ||
| 543 | + '-map', '1', | ||
| 543 | 544 | 'out1.mp4' | |
| 544 | 545 | ] | |
| 545 | 546 | ||
| 546 | 547 | ||
| 548 | + def test_passthrough_selectors(): | ||
| 549 | + i1 = ffmpeg.input(TEST_INPUT_FILE1) | ||
| 550 | + args = ( | ||
| 551 | + ffmpeg | ||
| 552 | + .output(i1['1'], i1['2'], TEST_OUTPUT_FILE1) | ||
| 553 | + .get_args() | ||
| 554 | + ) | ||
| 555 | + assert args == [ | ||
| 556 | + '-i', TEST_INPUT_FILE1, | ||
| 557 | + '-map', '0:1', | ||
| 558 | + '-map', '0:2', | ||
| 559 | + TEST_OUTPUT_FILE1, | ||
| 560 | + ] | ||
| 561 | + | ||
| 562 | + | ||
| 563 | + def test_mixed_passthrough_selectors(): | ||
| 564 | + i1 = ffmpeg.input(TEST_INPUT_FILE1) | ||
| 565 | + args = ( | ||
| 566 | + ffmpeg | ||
| 567 | + .output(i1['1'].hflip(), i1['2'], TEST_OUTPUT_FILE1) | ||
| 568 | + .get_args() | ||
| 569 | + ) | ||
| 570 | + assert args == [ | ||
| 571 | + '-i', TEST_INPUT_FILE1, | ||
| 572 | + '-filter_complex', | ||
| 573 | + '[0:1]hflip[s0]', | ||
| 574 | + '-map', '[s0]', | ||
| 575 | + '-map', '0:2', | ||
| 576 | + TEST_OUTPUT_FILE1, | ||
| 577 | + ] | ||
| 578 | + | ||
| 579 | + | ||
| 547 | 580 | def test_pipe(): | |
| 548 | 581 | width = 32 | |
| 549 | 582 | height = 32 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments