| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,18 +13,18 @@ Flip a video horizontally: | |||
| 13 | 13 | ``` | |
| 14 | 14 | import ffmpeg | |
| 15 | 15 | ffmpeg \ | |
| 16 | - .file_input('input.mp4') \ | ||
| 16 | + .input('input.mp4') \ | ||
| 17 | 17 | .hflip() \ | |
| 18 | - .file_output('output.mp4') \ | ||
| 18 | + .output('output.mp4') \ | ||
| 19 | 19 | .run() | |
| 20 | 20 | ``` | |
| 21 | 21 | ||
| 22 | 22 | Or if you prefer a non-fluent interface: | |
| 23 | 23 | ``` | |
| 24 | 24 | import ffmpeg | |
| 25 | - in = ffmpeg.file_input('input.mp4') | ||
| 25 | + in = ffmpeg.input('input.mp4') | ||
| 26 | 26 | flipped = ffmpeg.hflip(in) | |
| 27 | - out = ffmpeg.file_output(flipped) | ||
| 27 | + out = ffmpeg.output(flipped) | ||
| 28 | 28 | ffmpeg.run(out) | |
| 29 | 29 | ``` | |
| 30 | 30 | ||
@@ -54,16 +54,16 @@ If you're like me and find Python to be powerful and readable, it's easy with `f | |||
| 54 | 54 | ``` | |
| 55 | 55 | import ffmpeg | |
| 56 | 56 | ||
| 57 | - in_file = ffmpeg.file_input('input.mp4') | ||
| 58 | - overlay_file = ffmpeg.file_input('overlay.png') | ||
| 57 | + in_file = ffmpeg.input('input.mp4') | ||
| 58 | + overlay_file = ffmpeg.input('overlay.png') | ||
| 59 | 59 | ffmpeg \ | |
| 60 | 60 | .concat( | |
| 61 | 61 | in_file.trim(10, 20), | |
| 62 | 62 | in_file.trim(30, 40), | |
| 63 | 63 | ) \ | |
| 64 | 64 | .overlay(overlay_file.hflip()) \ | |
| 65 | 65 | .drawbox(50, 50, 120, 120, color='red', thickness=5) \ | |
| 66 | - .file_output(TEST_OUTPUT_FILE) \ | ||
| 66 | + .output(TEST_OUTPUT_FILE) \ | ||
| 67 | 67 | .run() | |
| 68 | 68 | ``` | |
| 69 | 69 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,6 @@ ffmpeg-python: Python bindings for FFmpeg | |||
| 2 | 2 | ========================================= | |
| 3 | 3 | ||
| 4 | 4 | :Github: https://github.com/kkroening/ffmpeg-python | |
| 5 | - ----------------------------------------------------------- | ||
| 6 | 5 | ||
| 7 | 6 | .. toctree:: | |
| 8 | 7 | :maxdepth: 2 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -90,12 +90,6 @@ <h2 id="F">F</h2> | |||
| 90 | 90 | <table style="width: 100%" class="indextable genindextable"><tr> | |
| 91 | 91 | <td style="width: 33%; vertical-align: top;"><ul> | |
| 92 | 92 | <li><a href="index.html#module-ffmpeg">ffmpeg (module)</a> | |
| 93 | - </li> | ||
| 94 | - </ul></td> | ||
| 95 | - <td style="width: 33%; vertical-align: top;"><ul> | ||
| 96 | - <li><a href="index.html#ffmpeg.file_input">file_input() (in module ffmpeg)</a> | ||
| 97 | - </li> | ||
| 98 | - <li><a href="index.html#ffmpeg.file_output">file_output() (in module ffmpeg)</a> | ||
| 99 | 93 | </li> | |
| 100 | 94 | </ul></td> | |
| 101 | 95 | </tr></table> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,7 +56,6 @@ <h1>ffmpeg-python: Python bindings for FFmpeg<a class="headerlink" href="#ffmpeg | |||
| 56 | 56 | </tr> | |
| 57 | 57 | </tbody> | |
| 58 | 58 | </table> | |
| 59 | - <hr class="docutils" /> | ||
| 60 | 59 | <div class="toctree-wrapper compound"> | |
| 61 | 60 | </div> | |
| 62 | 61 | <span class="target" id="module-ffmpeg"></span><dl class="function"> | |
@@ -284,24 +283,11 @@ <h1>ffmpeg-python: Python bindings for FFmpeg<a class="headerlink" href="#ffmpeg | |||
| 284 | 283 | <p>Official documentation: <a class="reference external" href="https://ffmpeg.org/ffmpeg-filters.html#zoompan">zoompan</a></p> | |
| 285 | 284 | </dd></dl> | |
| 286 | 285 | ||
| 287 | - <dl class="function"> | ||
| 288 | - <dt id="ffmpeg.file_input"> | ||
| 289 | - <code class="descclassname">ffmpeg.</code><code class="descname">file_input</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="headerlink" href="#ffmpeg.file_input" title="Permalink to this definition">¶</a></dt> | ||
| 290 | - <dd><p>Input file URL (ffmpeg <code class="docutils literal"><span class="pre">-i</span></code> option)</p> | ||
| 291 | - <p>Official documentation: <a class="reference external" href="https://ffmpeg.org/ffmpeg.html#Main-options">Main options</a></p> | ||
| 292 | - </dd></dl> | ||
| 293 | - | ||
| 294 | - <dl class="function"> | ||
| 295 | - <dt id="ffmpeg.file_output"> | ||
| 296 | - <code class="descclassname">ffmpeg.</code><code class="descname">file_output</code><span class="sig-paren">(</span><em>parent_node</em>, <em>filename</em><span class="sig-paren">)</span><a class="headerlink" href="#ffmpeg.file_output" title="Permalink to this definition">¶</a></dt> | ||
| 297 | - <dd><p>Output file URL</p> | ||
| 298 | - <p>Official documentation: <a class="reference external" href="https://ffmpeg.org/ffmpeg.html#Synopsis">Synopsis</a></p> | ||
| 299 | - </dd></dl> | ||
| 300 | - | ||
| 301 | 286 | <dl class="function"> | |
| 302 | 287 | <dt id="ffmpeg.input"> | |
| 303 | 288 | <code class="descclassname">ffmpeg.</code><code class="descname">input</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="headerlink" href="#ffmpeg.input" title="Permalink to this definition">¶</a></dt> | |
| 304 | - <dd><p>Shorthand for <code class="docutils literal"><span class="pre">file_input</span></code></p> | ||
| 289 | + <dd><p>Input file URL (ffmpeg <code class="docutils literal"><span class="pre">-i</span></code> option)</p> | ||
| 290 | + <p>Official documentation: <a class="reference external" href="https://ffmpeg.org/ffmpeg.html#Main-options">Main options</a></p> | ||
| 305 | 291 | </dd></dl> | |
| 306 | 292 | ||
| 307 | 293 | <dl class="function"> | |
@@ -312,7 +298,8 @@ <h1>ffmpeg-python: Python bindings for FFmpeg<a class="headerlink" href="#ffmpeg | |||
| 312 | 298 | <dl class="function"> | |
| 313 | 299 | <dt id="ffmpeg.output"> | |
| 314 | 300 | <code class="descclassname">ffmpeg.</code><code class="descname">output</code><span class="sig-paren">(</span><em>parent_node</em>, <em>filename</em><span class="sig-paren">)</span><a class="headerlink" href="#ffmpeg.output" title="Permalink to this definition">¶</a></dt> | |
| 315 | - <dd><p>Shorthand for <code class="docutils literal"><span class="pre">file_output</span></code></p> | ||
| 301 | + <dd><p>Output file URL</p> | ||
| 302 | + <p>Official documentation: <a class="reference external" href="https://ffmpeg.org/ffmpeg.html#Synopsis">Synopsis</a></p> | ||
| 316 | 303 | </dd></dl> | |
| 317 | 304 | ||
| 318 | 305 | <dl class="function"> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,6 @@ ffmpeg-python: Python bindings for FFmpeg | |||
| 2 | 2 | ========================================= | |
| 3 | 3 | ||
| 4 | 4 | :Github: https://github.com/kkroening/ffmpeg-python | |
| 5 | - ----------------------------------------------------------- | ||
| 6 | 5 | ||
| 7 | 6 | .. toctree:: | |
| 8 | 7 | :maxdepth: 2 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,17 +7,12 @@ | |||
| 7 | 7 | ) | |
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | - def file_input(filename): | ||
| 10 | + def input(filename): | ||
| 11 | 11 | """Input file URL (ffmpeg ``-i`` option) | |
| 12 | 12 | ||
| 13 | 13 | Official documentation: `Main options <https://ffmpeg.org/ffmpeg.html#Main-options>`__ | |
| 14 | 14 | """ | |
| 15 | - return InputNode(file_input.__name__, filename=filename) | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - def input(filename): | ||
| 19 | - """Shorthand for ``file_input``""" | ||
| 20 | - return file_input(filename) | ||
| 15 | + return InputNode(input.__name__, filename=filename) | ||
| 21 | 16 | ||
| 22 | 17 | ||
| 23 | 18 | @operator(node_classes={OutputNode, GlobalNode}) | |
@@ -35,24 +30,16 @@ def merge_outputs(*parent_nodes): | |||
| 35 | 30 | ||
| 36 | 31 | ||
| 37 | 32 | @operator(node_classes={InputNode, FilterNode}) | |
| 38 | - def file_output(parent_node, filename): | ||
| 33 | + def output(parent_node, filename): | ||
| 39 | 34 | """Output file URL | |
| 40 | 35 | ||
| 41 | 36 | Official documentation: `Synopsis <https://ffmpeg.org/ffmpeg.html#Synopsis>`__ | |
| 42 | 37 | """ | |
| 43 | - return OutputNode([parent_node], file_output.__name__, filename=filename) | ||
| 44 | - | ||
| 45 | - | ||
| 46 | - @operator(node_classes={InputNode, FilterNode}) | ||
| 47 | - def output(parent_node, filename): | ||
| 48 | - """Shorthand for ``file_output``""" | ||
| 49 | - return file_output(parent_node, filename) | ||
| 38 | + return OutputNode([parent_node], output.__name__, filename=filename) | ||
| 50 | 39 | ||
| 51 | 40 | ||
| 52 | 41 | ||
| 53 | 42 | __all__ = [ | |
| 54 | - 'file_input', | ||
| 55 | - 'file_output', | ||
| 56 | 43 | 'input', | |
| 57 | 44 | 'merge_outputs', | |
| 58 | 45 | 'output', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,9 +2,9 @@ | |||
| 2 | 2 | import subprocess as _subprocess | |
| 3 | 3 | ||
| 4 | 4 | from ._ffmpeg import ( | |
| 5 | - file_input, | ||
| 6 | - file_output, | ||
| 5 | + input, | ||
| 7 | 6 | merge_outputs, | |
| 7 | + output, | ||
| 8 | 8 | overwrite_output, | |
| 9 | 9 | ) | |
| 10 | 10 | from .nodes import ( | |
@@ -19,7 +19,7 @@ def _get_stream_name(name): | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | def _get_input_args(input_node): | |
| 22 | - if input_node._name == file_input.__name__: | ||
| 22 | + if input_node._name == input.__name__: | ||
| 23 | 23 | args = ['-i', input_node._kwargs['filename']] | |
| 24 | 24 | else: | |
| 25 | 25 | assert False, 'Unsupported input node: {}'.format(input_node) | |
@@ -73,7 +73,7 @@ def _get_output_args(node, stream_name_map): | |||
| 73 | 73 | stream_name = stream_name_map[node._parents[0]] | |
| 74 | 74 | if stream_name != '[0]': | |
| 75 | 75 | args += ['-map', stream_name] | |
| 76 | - if node._name == file_output.__name__: | ||
| 76 | + if node._name == output.__name__: | ||
| 77 | 77 | args += [node._kwargs['filename']] | |
| 78 | 78 | else: | |
| 79 | 79 | assert False, 'Unsupported output node: {}'.format(node) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,9 +15,9 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | def test_fluent_equality(): | |
| 18 | - base1 = ffmpeg.file_input('dummy1.mp4') | ||
| 19 | - base2 = ffmpeg.file_input('dummy1.mp4') | ||
| 20 | - base3 = ffmpeg.file_input('dummy2.mp4') | ||
| 18 | + base1 = ffmpeg.input('dummy1.mp4') | ||
| 19 | + base2 = ffmpeg.input('dummy1.mp4') | ||
| 20 | + base3 = ffmpeg.input('dummy2.mp4') | ||
| 21 | 21 | t1 = base1.trim(start_frame=10, end_frame=20) | |
| 22 | 22 | t2 = base1.trim(start_frame=10, end_frame=20) | |
| 23 | 23 | t3 = base1.trim(start_frame=10, end_frame=30) | |
@@ -30,7 +30,7 @@ def test_fluent_equality(): | |||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | 32 | def test_fluent_concat(): | |
| 33 | - base = ffmpeg.file_input('dummy.mp4') | ||
| 33 | + base = ffmpeg.input('dummy.mp4') | ||
| 34 | 34 | trimmed1 = base.trim(start_frame=10, end_frame=20) | |
| 35 | 35 | trimmed2 = base.trim(start_frame=30, end_frame=40) | |
| 36 | 36 | trimmed3 = base.trim(start_frame=50, end_frame=60) | |
@@ -46,53 +46,53 @@ def test_fluent_concat(): | |||
| 46 | 46 | ||
| 47 | 47 | def test_fluent_output(): | |
| 48 | 48 | ffmpeg \ | |
| 49 | - .file_input('dummy.mp4') \ | ||
| 49 | + .input('dummy.mp4') \ | ||
| 50 | 50 | .trim(start_frame=10, end_frame=20) \ | |
| 51 | - .file_output('dummy2.mp4') | ||
| 51 | + .output('dummy2.mp4') | ||
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | 54 | def test_fluent_complex_filter(): | |
| 55 | - in_file = ffmpeg.file_input('dummy.mp4') | ||
| 55 | + in_file = ffmpeg.input('dummy.mp4') | ||
| 56 | 56 | return ffmpeg \ | |
| 57 | 57 | .concat( | |
| 58 | 58 | in_file.trim(start_frame=10, end_frame=20), | |
| 59 | 59 | in_file.trim(start_frame=30, end_frame=40), | |
| 60 | 60 | in_file.trim(start_frame=50, end_frame=60) | |
| 61 | 61 | ) \ | |
| 62 | - .file_output('dummy2.mp4') | ||
| 62 | + .output('dummy2.mp4') | ||
| 63 | 63 | ||
| 64 | 64 | ||
| 65 | 65 | def test_repr(): | |
| 66 | - in_file = ffmpeg.file_input('dummy.mp4') | ||
| 66 | + in_file = ffmpeg.input('dummy.mp4') | ||
| 67 | 67 | trim1 = ffmpeg.trim(in_file, start_frame=10, end_frame=20) | |
| 68 | 68 | trim2 = ffmpeg.trim(in_file, start_frame=30, end_frame=40) | |
| 69 | 69 | trim3 = ffmpeg.trim(in_file, start_frame=50, end_frame=60) | |
| 70 | 70 | concatted = ffmpeg.concat(trim1, trim2, trim3) | |
| 71 | - output = ffmpeg.file_output(concatted, 'dummy2.mp4') | ||
| 72 | - assert repr(in_file) == "file_input(filename='dummy.mp4')" | ||
| 71 | + output = ffmpeg.output(concatted, 'dummy2.mp4') | ||
| 72 | + assert repr(in_file) == "input(filename='dummy.mp4')" | ||
| 73 | 73 | assert repr(trim1) == "trim(end_frame=20,start_frame=10)" | |
| 74 | 74 | assert repr(trim2) == "trim(end_frame=40,start_frame=30)" | |
| 75 | 75 | assert repr(trim3) == "trim(end_frame=60,start_frame=50)" | |
| 76 | 76 | assert repr(concatted) == "concat(n=3)" | |
| 77 | - assert repr(output) == "file_output(filename='dummy2.mp4')" | ||
| 77 | + assert repr(output) == "output(filename='dummy2.mp4')" | ||
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | 80 | def test_get_args_simple(): | |
| 81 | - out_file = ffmpeg.file_input('dummy.mp4').file_output('dummy2.mp4') | ||
| 81 | + out_file = ffmpeg.input('dummy.mp4').output('dummy2.mp4') | ||
| 82 | 82 | assert out_file.get_args() == ['-i', 'dummy.mp4', 'dummy2.mp4'] | |
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | 85 | def _get_complex_filter_example(): | |
| 86 | - in_file = ffmpeg.file_input(TEST_INPUT_FILE) | ||
| 87 | - overlay_file = ffmpeg.file_input(TEST_OVERLAY_FILE) | ||
| 86 | + in_file = ffmpeg.input(TEST_INPUT_FILE) | ||
| 87 | + overlay_file = ffmpeg.input(TEST_OVERLAY_FILE) | ||
| 88 | 88 | return ffmpeg \ | |
| 89 | 89 | .concat( | |
| 90 | 90 | in_file.trim(start_frame=10, end_frame=20), | |
| 91 | 91 | in_file.trim(start_frame=30, end_frame=40), | |
| 92 | 92 | ) \ | |
| 93 | 93 | .overlay(overlay_file.hflip()) \ | |
| 94 | 94 | .drawbox(50, 50, 120, 120, color='red', thickness=5) \ | |
| 95 | - .file_output(TEST_OUTPUT_FILE) \ | ||
| 95 | + .output(TEST_OUTPUT_FILE) \ | ||
| 96 | 96 | .overwrite_output() | |
| 97 | 97 | ||
| 98 | 98 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments