如何在给定时间使用 ffmpeg 为视频提取 1 个屏幕截图? [英] How to extract 1 screenshot for a video with ffmpeg at a given time?

查看:33
本文介绍了如何在给定时间使用 ffmpeg 为视频提取 1 个屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多教程和内容展示了如何使用 ffmpeg 从视频中提取多个屏幕截图.你设置-r,你甚至可以开始一定数量的.

There are many tutorials and stuff showing how to extract multiple screenshots from a video using ffmpeg. You set -r and you can even start a certain amount in.

但我只想要 1 个屏幕截图,比如 01:23:45 in.或者 1 个屏幕截图在 86% in.

But I just want 1 screenshot at, say 01:23:45 in. Or 1 screenshot at 86% in.

使用 ffmpegthumbnailer 这一切都是可能的,但这是我不想依赖的另一个依赖项在.我希望能够用 ffmpeg 做到这一点.

This is all possible with ffmpegthumbnailer but it's another dependency I don't want to depend on. I want to be able to do it with ffmpeg.

推荐答案

使用 -ss 选项:

ffmpeg -ss 01:23:45 -i input -vframes 1 -q:v 2 output.jpg

  • 对于 JPEG 输出,使用 -q:v 来控制输出质量.全范围是 1-31 的线性标度,其中较低的值导致较高的质量.2-5 是一个不错的尝试范围.

    • For JPEG output use -q:v to control output quality. Full range is a linear scale of 1-31 where a lower value results in a higher quality. 2-5 is a good range to try.

      选择过滤器为更复杂的需求提供了一种替代方法例如仅选择某些帧类型,或每 100 个选择 1 个等.

      The select filter provides an alternative method for more complex needs such as selecting only certain frame types, or 1 per 100, etc.

      在输入之前放置 -ss 会更快.请参阅 FFmpeg Wiki:Seekingffmpeg cli 工具文档:

      Placing -ss before the input will be faster. See FFmpeg Wiki: Seeking and this excerpt from the ffmpeg cli tool documentation:

      -ss 位置(输入/输出)

      当用作输入选项时(在 -i 之前),在这个输入文件中寻找位置.请注意,在大多数格式中,无法搜索正是如此,所以 ffmpeg 将寻找之前最近的寻找点位置.当转码和 -accurate_seek 启用时(默认),搜索点和位置之间的这个额外段将被解码并丢弃.进行流复制时或使用了-noaccurate_seek,它会被保留.

      When used as an input option (before -i), seeks in this input file to position. Note the in most formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position. When transcoding and -accurate_seek is enabled (the default), this extra segment between the seek point and position will be decoded and discarded. When doing stream copy or when -noaccurate_seek is used, it will be preserved.

      当用作输出选项时(在输出文件名之前),解码但丢弃输入,直到时间戳到达位置.

      When used as an output option (before an output filename), decodes but discards input until the timestamps reach position.

      位置可以是秒,也可以是 hh:mm:ss[.xxx] 形式.

      position may be either in seconds or in hh:mm:ss[.xxx] form.

      这篇关于如何在给定时间使用 ffmpeg 为视频提取 1 个屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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