Replies: 4 comments
-
I think you can do it more simple: import av
count = 0
container = av.open('test_clips/test.mp4', 'r')
for packet in container.demux():
if packet.stream.type == 'video':
for frame in packet.decode():
if count % 25 == 0:
frame.to_image().save('%04d.png' % count)
count += 1 |
Beta Was this translation helpful? Give feedback.
-
@jb-alvarado unless I'm misreading the code, it seems to select every frame divisible by |
Beta Was this translation helpful? Give feedback.
-
When you want to have images as output you can use two methods:
When you want a video output the second method is better, but you have to look here in the issues and examples for a proper way to use filters in PyAV. My knowledge about PyAV is not so deep. Here I have try one time to change the fps, but as I remember there was some issues, and of course the queue and pipe to ffplay is not necessary. |
Beta Was this translation helpful? Give feedback.
-
Thanks @jb-alvarado for a quick response. Unfortunately there are no examples for using filters. I've also asked a question in the |
Beta Was this translation helpful? Give feedback.
-
In FFmpeg wiki: https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video
we use cmd:
fmpeg -i input.flv -ss 00:00:14.435 -vframes 1 out.png
We get one picture in Specified time
ffmpeg -i input.flv -vf fps=1 out%d.png
then get lots of images. One picture per second.
How to use PyAV to achived the same goal ? Does anybody make a demo? Thanks.
BTW: by use cmd:
ffmpeg -i input.flv-r 1 -y -f image2 -s 240*320 pc%3d.jpg
use '-r' arg seems to be the same purpose, Which method is more efficient ?
Beta Was this translation helpful? Give feedback.
All reactions