Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg to capture screenshot from a video file in a fine time unit

Tags:

ffmpeg

I use ffmpeg to capture screenshot from video. Here is the command code:

ffmpeg -i /my_video_file_dir/video.flv -y -f image2 -ss 8 -sameq -t 0.001 
-s 320*240 /image_dir/screenshot.jpg

And I want to capture the screenshot at a fine time unit 8.344 for example

But it does not output screenshot image by the above command

In my test, -ss 1,1.5,2,2.5 ... works fine and others not such as 1.1,1.11

Does andbody know why it happens and how can I capture screenshot at a x.xxx time

like image 629
hyperion Avatar asked Sep 30 '10 03:09

hyperion


People also ask

How do I set video duration in FFmpeg?

Getting the Duration To get the duration with ffprobe , add the -show_entries flag and set its value to format=duration . This tells ffprobe to only return the duration. To convert the above value into minutes and seconds, round it to an integer and divide it by 60.

What is FFmpeg timestamp?

The ffmpeg -timestamp option takes a date, which it stores in the output file. It is not related to the timecode and does not cause any text to be rendered.


1 Answers

Try this instead:

ffmpeg -ss 00:00:01.01 -i /my_video_file_dir/video.flv -y -f image2 \
   -vcodec mjpeg -vframes 1 /image_dir/screenshot.jpg

Note that very small increments will not normally result in different images, due to lower frame rates of most videos. 0.001s increments only work with videos of 1000fps framerates :) 0.03 increments should work with a 30fps video, etc.

like image 96
yuttadhammo Avatar answered Sep 20 '22 21:09

yuttadhammo