mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-04-05 12:48:09 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
06d4a6fa09
14
README.md
14
README.md
@ -23,7 +23,8 @@ ffmpeg.run(stream)
|
||||
Or if you prefer a fluent interface:
|
||||
```python
|
||||
import ffmpeg
|
||||
(ffmpeg
|
||||
(
|
||||
ffmpeg
|
||||
.input('input.mp4')
|
||||
.hflip()
|
||||
.output('output.mp4')
|
||||
@ -54,7 +55,8 @@ import ffmpeg
|
||||
|
||||
in_file = ffmpeg.input('input.mp4')
|
||||
overlay_file = ffmpeg.input('overlay.png')
|
||||
(ffmpeg
|
||||
(
|
||||
ffmpeg
|
||||
.concat(
|
||||
in_file.trim(start_frame=10, end_frame=20),
|
||||
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
|
||||
|
||||
## Custom Filters
|
||||
|
||||
Don't see the filter you're looking for? `ffmpeg-python` includes , but it's easy to use any arbitrary ffmpeg filter:
|
||||
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:
|
||||
```python
|
||||
stream = ffmpeg.input('dummy.mp4')
|
||||
stream = ffmpeg.filter_(stream, 'fps', fps=25, round='up')
|
||||
@ -127,7 +129,8 @@ ffmpeg.run(stream)
|
||||
|
||||
Or fluently:
|
||||
```python
|
||||
(ffmpeg
|
||||
(
|
||||
ffmpeg
|
||||
.input('dummy.mp4')
|
||||
.filter_('fps', fps=25, round='up')
|
||||
.output('dummy2.mp4')
|
||||
@ -137,7 +140,8 @@ Or fluently:
|
||||
|
||||
Arguments with special names such as `-qscale:v` can be specified as a keyword-args dictionary as follows:
|
||||
```python
|
||||
(ffmpeg
|
||||
(
|
||||
ffmpeg
|
||||
.input('dummy.mp4')
|
||||
.output('dummy2.mp4', **{'qscale:v': 3})
|
||||
.run()
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Examples
|
||||
|
||||
## [Get video info](https://github.com/kkroening/ffmpeg-python/blob/master/examples/video_info.py#L15)
|
||||
## [Get video info (ffprobe)](https://github.com/kkroening/ffmpeg-python/blob/master/examples/video_info.py#L15)
|
||||
|
||||
```python
|
||||
probe = ffmpeg.probe(args.in_filename)
|
||||
@ -23,24 +23,6 @@ height = int(video_stream['height'])
|
||||
)
|
||||
```
|
||||
|
||||
## Process audio and video simultaneously
|
||||
|
||||
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/av-pipeline.png" alt="av-pipeline graph" width="80%" />
|
||||
|
||||
```python
|
||||
in1 = ffmpeg.input('in1.mp4')
|
||||
in2 = ffmpeg.input('in2.mp4')
|
||||
v1 = in1['v'].hflip()
|
||||
a1 = in1['a']
|
||||
v2 = in2['v'].filter_('reverse').filter_('hue', s=0)
|
||||
a2 = in2['a'].filter_('areverse').filter_('aphaser')
|
||||
joined = ffmpeg.concat(v1, a1, v2, a2, v=1, a=1).node
|
||||
v3 = joined[0]
|
||||
a3 = joined[1].filter_('volume', 0.8)
|
||||
out = ffmpeg.output(v3, a3, 'out.mp4')
|
||||
out.run()
|
||||
```
|
||||
|
||||
## [Convert video to numpy array](https://github.com/kkroening/ffmpeg-python/blob/master/examples/ffmpeg-numpy.ipynb)
|
||||
|
||||
<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
|
||||
)
|
||||
```
|
||||
|
||||
## Audio/video pipeline
|
||||
|
||||
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/av-pipeline.png" alt="av-pipeline graph" width="80%" />
|
||||
|
||||
```python
|
||||
in1 = ffmpeg.input('in1.mp4')
|
||||
in2 = ffmpeg.input('in2.mp4')
|
||||
v1 = in1['v'].hflip()
|
||||
a1 = in1['a']
|
||||
v2 = in2['v'].filter_('reverse').filter_('hue', s=0)
|
||||
a2 = in2['a'].filter_('areverse').filter_('aphaser')
|
||||
joined = ffmpeg.concat(v1, a1, v2, a2, v=1, a=1).node
|
||||
v3 = joined[0]
|
||||
a3 = joined[1].filter_('volume', 0.8)
|
||||
out = ffmpeg.output(v3, a3, 'out.mp4')
|
||||
out.run()
|
||||
```
|
||||
|
||||
## [Jupyter Frame Viewer](https://github.com/kkroening/ffmpeg-python/blob/master/examples/ffmpeg-numpy.ipynb)
|
||||
|
||||
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/doc/jupyter-screenshot.png" alt="jupyter screenshot" width="75%" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user