Capture screenshot / frame of video file

Is there a way to capture a single frame of a video file in python?
this can also be done using the command line. im using handbrakecli to convert the video,
but I also need screenshots.

Thank you

+4
source share
1 answer

You should check PyFFmpeg first.

PyFFmpeg - a wrapper around FFmpeg's libavcodec, libavformat and libavutil libraries, the main purpose of which is to provide access to individual frames of video files of various formats (including encoding MPEG and DIVX video). It also provides access to audio data.

You can also use ffmpeg , so call it using subprocess . A simple search will give you the command you need to extract the frame from the video file. Just call this command using subprocess and this should do it.

 >>> import subprocess >>> import shlex # to split the command that follows >>> command = 'ffmpeg -i sample.avi' # your command goes here >>> subprocess.call(shlex.split(command)) 

A similar procedure applies to handbrakecli or what you can use. Just call the appropriate command.

+6
source

Source: https://habr.com/ru/post/1335282/


All Articles