| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,8 @@ ffmpeg.run(stream) | |||
| 23 | 23 | Or if you prefer a fluent interface: | |
| 24 | 24 | ```python | |
| 25 | 25 | import ffmpeg | |
| 26 | - (ffmpeg | ||
| 26 | + ( | ||
| 27 | + ffmpeg | ||
| 27 | 28 | .input('input.mp4') | |
| 28 | 29 | .hflip() | |
| 29 | 30 | .output('output.mp4') | |
@@ -54,7 +55,8 @@ import ffmpeg | |||
| 54 | 55 | ||
| 55 | 56 | in_file = ffmpeg.input('input.mp4') | |
| 56 | 57 | overlay_file = ffmpeg.input('overlay.png') | |
| 57 | - (ffmpeg | ||
| 58 | + ( | ||
| 59 | + ffmpeg | ||
| 58 | 60 | .concat( | |
| 59 | 61 | in_file.trim(start_frame=10, end_frame=20), | |
| 60 | 62 | in_file.trim(start_frame=30, end_frame=40), | |
@@ -117,7 +119,7 @@ Alternatively, standard python help is available, such as at the python REPL pro | |||
| 117 | 119 | ||
| 118 | 120 | ## Custom Filters | |
| 119 | 121 | ||
| 120 | - Don't see the filter you're looking for? `ffmpeg-python` includes , but it's easy to use any arbitrary ffmpeg filter: | ||
| 122 | + Don't see the filter you're looking for? `ffmpeg-python` includes shorthand notation for some of the most commonly used filters (such as `concat`), but it's easy to use any arbitrary ffmpeg filter: | ||
| 121 | 123 | ```python | |
| 122 | 124 | stream = ffmpeg.input('dummy.mp4') | |
| 123 | 125 | stream = ffmpeg.filter_(stream, 'fps', fps=25, round='up') | |
@@ -127,7 +129,8 @@ ffmpeg.run(stream) | |||
| 127 | 129 | ||
| 128 | 130 | Or fluently: | |
| 129 | 131 | ```python | |
| 130 | - (ffmpeg | ||
| 132 | + ( | ||
| 133 | + ffmpeg | ||
| 131 | 134 | .input('dummy.mp4') | |
| 132 | 135 | .filter_('fps', fps=25, round='up') | |
| 133 | 136 | .output('dummy2.mp4') | |
@@ -137,7 +140,8 @@ Or fluently: | |||
| 137 | 140 | ||
| 138 | 141 | Arguments with special names such as `-qscale:v` can be specified as a keyword-args dictionary as follows: | |
| 139 | 142 | ```python | |
| 140 | - (ffmpeg | ||
| 143 | + ( | ||
| 144 | + ffmpeg | ||
| 141 | 145 | .input('dummy.mp4') | |
| 142 | 146 | .output('dummy2.mp4', **{'qscale:v': 3}) | |
| 143 | 147 | .run() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | # Examples | |
| 2 | 2 | ||
| 3 | - ## [Get video info](https://github.com/kkroening/ffmpeg-python/blob/master/examples/video_info.py#L15) | ||
| 3 | + ## [Get video info (ffprobe)](https://github.com/kkroening/ffmpeg-python/blob/master/examples/video_info.py#L15) | ||
| 4 | 4 | ||
| 5 | 5 | ```python | |
| 6 | 6 | probe = ffmpeg.probe(args.in_filename) | |
@@ -23,24 +23,6 @@ height = int(video_stream['height']) | |||
| 23 | 23 | ) | |
| 24 | 24 | ``` | |
| 25 | 25 | ||
| 26 | - ## Process audio and video simultaneously | ||
| 27 | - | ||
| 28 | - <img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/av-pipeline.png" alt="av-pipeline graph" width="80%" /> | ||
| 29 | - | ||
| 30 | - ```python | ||
| 31 | - in1 = ffmpeg.input('in1.mp4') | ||
| 32 | - in2 = ffmpeg.input('in2.mp4') | ||
| 33 | - v1 = in1['v'].hflip() | ||
| 34 | - a1 = in1['a'] | ||
| 35 | - v2 = in2['v'].filter_('reverse').filter_('hue', s=0) | ||
| 36 | - a2 = in2['a'].filter_('areverse').filter_('aphaser') | ||
| 37 | - joined = ffmpeg.concat(v1, a1, v2, a2, v=1, a=1).node | ||
| 38 | - v3 = joined[0] | ||
| 39 | - a3 = joined[1].filter_('volume', 0.8) | ||
| 40 | - out = ffmpeg.output(v3, a3, 'out.mp4') | ||
| 41 | - out.run() | ||
| 42 | - ``` | ||
| 43 | - | ||
| 44 | 26 | ## [Convert video to numpy array](https://github.com/kkroening/ffmpeg-python/blob/master/examples/ffmpeg-numpy.ipynb) | |
| 45 | 27 | ||
| 46 | 28 | <img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/ffmpeg-numpy.png" alt="ffmpeg-numpy graph" width="20%" /> | |
@@ -86,6 +68,24 @@ out, _ = (ffmpeg | |||
| 86 | 68 | ) | |
| 87 | 69 | ``` | |
| 88 | 70 | ||
| 71 | + ## Audio/video pipeline | ||
| 72 | + | ||
| 73 | + <img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/av-pipeline.png" alt="av-pipeline graph" width="80%" /> | ||
| 74 | + | ||
| 75 | + ```python | ||
| 76 | + in1 = ffmpeg.input('in1.mp4') | ||
| 77 | + in2 = ffmpeg.input('in2.mp4') | ||
| 78 | + v1 = in1['v'].hflip() | ||
| 79 | + a1 = in1['a'] | ||
| 80 | + v2 = in2['v'].filter_('reverse').filter_('hue', s=0) | ||
| 81 | + a2 = in2['a'].filter_('areverse').filter_('aphaser') | ||
| 82 | + joined = ffmpeg.concat(v1, a1, v2, a2, v=1, a=1).node | ||
| 83 | + v3 = joined[0] | ||
| 84 | + a3 = joined[1].filter_('volume', 0.8) | ||
| 85 | + out = ffmpeg.output(v3, a3, 'out.mp4') | ||
| 86 | + out.run() | ||
| 87 | + ``` | ||
| 88 | + | ||
| 89 | 89 | ## [Jupyter Frame Viewer](https://github.com/kkroening/ffmpeg-python/blob/master/examples/ffmpeg-numpy.ipynb) | |
| 90 | 90 | ||
| 91 | 91 | <img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/doc/jupyter-screenshot.png" alt="jupyter screenshot" width="75%" /> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments