Question

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

Was it helpful?

Solution

try,

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top