开发者

capture screenshot/frame of a video file

is开发者_开发技巧 there a way to capture a single frame of a video file in python?

it could also be done by command line. im using handbrakecli to convert the videos,

but i would need some screenshots of it too.

thank you


You should first check out PyFFmpeg.

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

It is also possible using ffmpeg, so call that using subprocess. A simple search will give you the command required to extract a frame from a video file. Just call that command using subprocess and that 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))

The similar procedure applies to handbrakecli or whatever you might use. Just call the appropriate command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜