Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aleksandergurin/71b8db332c89efb4aa84d3ef313af44c to your computer and use it in GitHub Desktop.
Save aleksandergurin/71b8db332c89efb4aa84d3ef313af44c to your computer and use it in GitHub Desktop.
import av
def extract_first_frame():
it = iter(av.open('../video.mp4').decode(video=0))
video_frame = next(it).reformat(width=640, height=480, format='rgb24') # av.video.frame.VideoFrame instance
# From VideoFrame you can obtain PIL.Image, numpy array etc.
rgb24_image = video_frame.to_image() # PIL.Image instance
rgb24_image.show() # show image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment