8000 Merge pull request #98 from kkroening/example-graphs · virustyle/ffmpeg-python@4ec72e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4ec72e0

Browse files
authored
Merge pull request kkroening#98 from kkroening/example-graphs
Add example graphs
2 parents 7c872c5 + 4a39baf commit 4ec72e0

File tree

6 files changed

+40
-26
lines changed

6 files changed

+40
-26
lines changed

examples/README.md

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,42 @@ width = int(video_stream['width'])
99
height = int(video_stream['height'])
1010
```
1111

12+
## [Generate thumbnail for video](https://github.com/kkroening/ffmpeg-python/blob/master/examples/get_video_thumbnail.py#L21)
13+
14+
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/get_video_thumbnail.png" alt="get-video-thumbnail graph" width="30%" />
15+
16+
```python
17+
(
18+
ffmpeg
19+
.input(in_filename, ss=time)
20+
.filter_('scale', width, -1)
21+
.output(out_filename, vframes=1)
22+
.run()
23+
)
24+
```
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+
1244
## [Convert video to numpy array](https://github.com/kkroening/ffmpeg-python/blob/master/examples/ffmpeg-numpy.ipynb)
1345

46+
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/ffmpeg-numpy.png" alt="ffmpeg-numpy graph" width="20%" />
47+
1448
```python
1549
out, _ = (
1650
ffmpeg
@@ -25,18 +59,10 @@ video = (
2559
)
2660
```
2761

28-
## [Generate thumbnail for video](https://github.com/kkroening/ffmpeg-python/blob/master/examples/get_video_thumbnail.py#L21)
29-
```python
30-
(
31-
ffmpeg
32-
.input(in_filename, ss=time)
33-
.filter_('scale', width, -1)
34-
.output(out_filename, vframes=1)
35-
.run()
36-
)
37-
```
38-
3962
## [Read single video frame as jpeg through pipe](https://github.com/kkroening/ffmpeg-python/blob/master/examples/read_frame_as_jpeg.py#L16)
63+
64+
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/read_frame_as_jpeg.png" alt="read-frame-as-jpeg graph" width="30%" />
65+
4066
```python
4167
out, _ = (
4268
ffmpeg
@@ -48,6 +74,9 @@ out, _ = (
4874
```
4975

5076
## [Convert sound to raw PCM audio](https://github.com/kkroening/ffmpeg-python/blob/master/examples/transcribe.py#L23)
77+
78+
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/transcribe.png" alt="transcribe graph" width="30%" />
79+
5180
```python
5281
out, _ = (ffmpeg
5382
.input(in_filename, **input_kwargs)
@@ -57,21 +86,6 @@ out, _ = (ffmpeg
5786
)
5887
```
5988

60-
## Process audio and video simultaneously
61-
```python
62-
in1 = ffmpeg.input('in1.mp4')
63-
in2 = ffmpeg.input('in2.mp4')
64-
v1 = in1['v'].hflip()
65-
a1 = in1['a']
66-
v2 = in2['v'].filter_('reverse').filter_('hue', s=0)
67-
a2 = in2['a'].filter_('areverse').filter_('aphaser')
68-
joined = ffmpeg.concat(v1, a1, v2, a2, v=1, a=1).node
69-
v3 = joined[0]
70-
a3 = joined[1].filter_('volume', 0.8)
71-
out = ffmpeg.output(v3, a3, 'out.mp4')
72-
out.run()
73-
```
74-
7589
## [Jupyter Frame Viewer](https://github.com/kkroening/ffmpeg-python/blob/master/examples/ffmpeg-numpy.ipynb)
7690

7791
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/doc/jupyter-screenshot.png" alt="jupyter screenshot" width="75%" />

examples/graphs/av-pipeline.png

32.2 KB
Loading

examples/graphs/ffmpeg-numpy.png

3.37 KB
Loading
5.29 KB
Loading
4.85 KB
Loading

examples/graphs/transcribe.png

14.6 KB
Loading

0 commit comments

Comments
 (0)
0