开发者

How to take pictures of the video through mplayer or ffmpeg to php?

How to take pictures of the video through开发者_如何学Python mplayer or ffmpeg to php?


try,

exec("ffmpeg -i $video_file_path -an -y -f mjpeg -ss 00:02:00 -vframes 1 $image_path")


Assuming ffmpeg is installed on your server, you can use the following code to output the frame at exactly 2 minutes to a JPEG file:

function vidtojpeg($video_filename, $dimensions) {
    exec("ffmpeg -i $video_filename -an -ss 00:01:59 -t 00:00:01 -r 1 -y -s $dimensions video%d.jpg");
}

In this function, the $video_filename parameter is self-explanatory. The $dimensions parameter accepts width and height of the outputted images in this format: WIDTHxHEIGHT. For example: 320x480 would be an acceptable parameter.


Converting the video to frames and getting the required frames based on timings can help. Try this : ffmpeg -i video.flv -r 25 -vcodec png -pix_fmt rgb32 %d.png

You can manipulate the formats and bitrate(-r) for getting the required frame in proper format.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜