8000 Update examples readme · Constructionware/ffmpeg-python@5af85c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5af85c8

Browse files
authored
Update examples readme
1 parent bf87179 commit 5af85c8

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

examples/README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,58 @@
11
# Examples
22

3-
## [Get video info](https://github.com/kkroening/ffmpeg-python/blob/master/examples/video_info.py)
3+
## [Get video info](https://github.com/kkroening/ffmpeg-python/blob/master/examples/video_info.py#L15)
44

55
```python
66
probe = ffmpeg.probe(args.in_filename)
77
video_stream = next((stream for stream in probe['streams'] if stream['codec_type'] == 'video'), None)
88
width = int(video_stream['width'])
99
height = int(video_stream['height'])
1010
```
11+
12+
## [Convert video to numpy array](https://github.com/kkroening/ffmpeg-python/blob/master/examples/ffmpeg-numpy.ipynb)
13+
14+
```python
15+
out, _ = (
16+
ffmpeg
17+
.input('in.mp4')
18+
.output('pipe:', format='rawvideo', pix_fmt='rgb24')
19+
.run(capture_stdout=True)
20+
)
21+
video = (
22+
np
23+
.frombuffer(out, np.uint8)
24+
.reshape([-1, height, width, 3])
25+
)
26+
```
27+
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+
39+
## [Read single video frame as jpeg through pipe](https://github.com/kkroening/ffmpeg-python/blob/master/examples/read_frame_as_jpeg.py#L16)
40+
```python
41+
out, _ = (
42+
ffmpeg
43+
.input(in_filename)
44+
.filter_('select', 'gte(n,{})'.format(frame_num))
45+
.output('pipe:', vframes=1, format='image2', vcodec='mjpeg')
46+
.run(capture_output=True)
47+
)
48+
```
49+
50+
## [Convert sound to raw PCM audio](https://github.com/kkroening/ffmpeg-python/blob/master/examples/transcribe.py#L23)
51+
```python
52+
out, _ = (ffmpeg
53+
.input(in_filename, **input_kwargs)
54+
.output('-', format='s16le', acodec='pcm_s16le', ac=1, ar='16k')
55+
.overwrite_output()
56+
.run(capture_stdout=True)
57+
)
58+
```

0 commit comments

Comments
 (0)
0