Python: How to get some images from a video in Python3?
<p>How can I extract frames from a video file using Python3?</p>

<p>For example, I want to get 16 picture from a video and combine them into a 4x4 grid.</p>

<p>I don't want 16 separate images at the end, I want one image containing 16 frames from the video.</p>

<p>----Edit----</p>

<pre><code>import av

container = av.open('/home/uguraba/Downloads/equals/equals.mp4')
video = next(s for s in container.streams)
for packet in container.demux(video):
    for frame in packet.decode():
        if frame.index %3000==0:
            frame.to_image().save('/home/uguraba/Downloads/equals/frame-%04d.jpg' % frame.index)
</code></pre>

<p>By using this script i can get frames. There will be lots of frames saved. Can i take specific frames like 5000-7500-10000 ?</p>

<p>Also my question is how can i see the total frame number ?</p>