以相等的时间/间隔从视频创建多个缩略图 [英] Create multiple thumbnails from a video at equal times / intervals

查看:133
本文介绍了以相等的时间/间隔从视频创建多个缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用ffmpeg在同一时间从一个视频创建多个缩略图(例如12). 例如,如果视频是60秒-我需要每5秒提取一张屏幕截图.

I need to create multiple thumbnails (ex. 12) from a video at equal times using ffmpeg. So for example if the video is 60 seconds - I need to extract a screenshot every 5 seconds.

我使用以下命令在5秒内获得帧.

Im using the following command to get the frame in the 5ths second.

ffmpeg -ss 5 -i video.webm -frames:v 1 -s 120x90 thumbnail.jpeg

是否可以通过一个命令获取多个缩略图?

Is there a way to get multiple thumbnails with one command?

推荐答案

获取持续时间(可选)

使用ffprobe 获取持续时间.这是一个可选步骤,但是如果您要编写脚本或自动执行下一个命令,将很有帮助.

Get duration (optional)

Get duration using ffprobe. This is an optional step but is helpful if you will be scripting or automating the next commands.

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4

示例结果:

60.000000

每5秒钟输出一帧

使用选择过滤器:

ffmpeg -i input.mp4 -vf "select='not(mod(t,5))',setpts=N/FRAME_RATE/TB" output_%04d.jpg

ffmpeg -i input.mp4 -vf "select='not(mod(t,5))'" -vsync vfr output_%04d.jpg

  • 文件将被命名为output_0001.jpgoutput_0002.jpgoutput_0003.jpg等.请参见图像混合器文档以获取更多信息和选项.

    • Files will be named output_0001.jpg, output_0002.jpg, output_0003.jpg, etc. See image muxer documentation for more info and options.

      要调整JPEG质量,请参见如何从具有ffmpeg的视频中提取高质量的JPEG图像?

      To adjust JPEG quality see How can I extract a good quality JPEG image from a video with ffmpeg?

      这将从60秒的持续时间输入中输出12帧:

      This will output 12 frames from a 60 second duration input:

      ffmpeg -i input.mp4 -vf "select='not(mod(t,60/12))'" -vsync vfr output_%04d.jpg
      

      您必须手动输入输入的持续时间(在上例中显示为60).请在下面立即查看自动方法.

      You must manually enter the duration of the input (shown as 60 in the example above). See an automatic method immediately below.

      重击示例:

      input=input.mp4; ffmpeg -i "$input" -vf "select='not(mod(t,$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $input)/12))'" -vsync vfr output_%04d.jpg
      

      带有刻度过滤器

      使用 scale 过滤器的示例:

      With scale filter

      Example using the scale filter:

      ffmpeg -i input.mp4 -vf "select='not(mod(t,60/12))',scale=120:-1" -vsync vfr output_%04d.jpg
      

      这篇关于以相等的时间/间隔从视频创建多个缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆