ffmpeg 1 image with many frames

2019-03-04 06:26发布

问题:

Is that possible to create thumbnails of video using ffmpeg in this format:

I need to output a single image with vertical shots every 10 seconds.

I know only how to create one image with one frame:

 <?php 

$ffmpeg = '/usr/local/bin/ffmpeg';

$video = '1.mp4';

$image = '1.png';

$interval = 1;

$size = '300x210';

$cmd = "$ffmpeg -i $video -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1";       
$return = `$cmd`;

?>

回答1:

You can do this with one ffmpeg command.

Example

ffmpeg -i alone_in_the_wilderness.mp4 -filter_complex \
"select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)',yadif,scale=240:-1,tile=1x3" \
-vframes 1 -t 30 -q:v 4 strip.jpg

Example with borders

tile=1x3:margin=10:padding=10

Also see

  • select, yadif, scale, tile filters documentation
  • Combine multiple images to form a strip of images ffmpeg
  • FFmpeg output screenshot gallery


回答2:

You can get a single image with one frame every 10 seconds with ffmpeg (e.g. 1.png, 2.png, 3.png) in a for loop and then merge the images horizontally using imagemagick:

convert 1.png 2.png 3.png -append vertical.png



标签: ffmpeg