8000 Update README.md · Powercoder64/ffmpeg-python@c533687 · GitHub
[go: up one dir, main page]

Skip to content

Commit c533687

Browse files
authored
Update README.md
1 parent b1d167c commit c533687

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

examples/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,59 @@ out.run()
123123

124124
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/doc/jupyter-demo.gif" alt="jupyter demo" width="75%" />
125125

126+
## [Tensorflow Streaming](https://github.com/kkroening/ffmpeg-python/blob/master/examples/tensorflow_stream.py)
127+
128+
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/tensorflow-stream.png" alt="tensorflow streaming; challenge mode: combine this with the webcam example below" width="55%" />
129+
130+
- Decode input video with ffmpeg
131+
- Process video with tensorflow using "deep dream" example
132+
- Encode output video with ffmpeg
133+
134+
```python
135+
args1 = (
136+
ffmpeg
137+
.input(in_filename)
138+
.output('pipe:', format='rawvideo', pix_fmt='rgb24', vframes=8)
139+
.compile()
140+
)
141+
process1 = subprocess.Popen(args1, stdout=subprocess.PIPE)
142+
143+
args2 = (
144+
ffmpeg
145+
.input('pipe:', format='rawvideo', pix_fmt='rgb24', s='{}x{}'.format(width, height))
146+
.output(out_filename, pix_fmt='yuv420p')
147+
.overwrite_output()
148+
.compile()
149+
)
150+
process2 = subprocess.Popen(args2, stdin=subprocess.PIPE)
151+
152+
while True:
153+
in_bytes = process1.stdout.read(width * height * 3)
154+
in_frame (
155+
np
156+
.frombuffer(in_bytes, np.uint8)
157+
.reshape([height, width, 3])
158+
)
159+
160+
# See examples/tensorflow_stream.py:
161+
frame = deep_dream.process_frame(frame)
162+
163+
process2.stdin.write(
164+
frame
165+
.astype(np.uint8)
166+
.tobytes()
167+
)
168+
```
169+
170+
<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/dream.png" alt="deep dream streaming" width="40%" />
171+
172+
## [FaceTime webcam input](https://github.com/kkroening/ffmpeg-python/blob/master/examples/facetime.py)
173+
174+
```python
175+
(
176+
ffmpeg
177+
.input('FaceTime', format='avfoundation', pix_fmt='uyvy422', framerate=30)
178+
.output('out.mp4', pix_fmt='yuv420p', vframes=100)
179+
.run()
180+
)
181+
```

0 commit comments

Comments
 (0)
0