Creating gif from jpeg images with ffmpeg
To set the frame rate (in frames per second) you want -r
. From the official documentation:
-r [: stream_specifier] fps (input / output, for stream)
Set the frame rate (value, fraction, or abbreviation).
As an input parameter, ignore any timestamps stored in the file, and instead create timestamps assuming constant fps. This is not the same as the -framerate option used for some input formats such as image2 or v4l2 (it was the same in previous versions of FFmpeg). When in doubt, use -framerate instead of the -r input parameter.
As an output option, duplicate or drop input frames to achieve constant output fps.
For example, setting 30 fps:
ffmpeg -f image2 -i thumb/%001d.jpg -vf scale=480x240 -r 30 out.gif
Note. The argument -r
must appear after the input file if you want to apply it to the output
source to share
I am using this code:
<?php
exec('ffmpeg -ss '.$date.' -i video.mp4 -vf scale=320x180 thumb/'.$i.'.png');
?>
I am using a loop to generate multiple $ i images in the $ date variable and there are loop numbers and $ date generates the time at which the image to be generated. The problem is that sometimes black images are generated. How to fix it?
source to share