我使用 ffmpeg 创建视频的简短预览...
$length = $length_video/5;
$ffmpeg_path." -i ".$content." -vf select='lt(mod(t\,".$length.")\,1)',setpts=N/FRAME_RATE/TB -af aselect='lt(mod(t\,".$length.")\,1)',asetpts=N/SR/TB -an ".$content_new.";
实际上这将创建 5 秒。视频。问题是因为第一帧是从 0-1 秒提取的。
有没有机会跳过第一帧并提取接下来的 5 帧?
问题是因为视频介绍的第一帧实际上是无用的
最佳答案
此选择过滤器应跳过前 5 帧:
$ ffmpeg -i input_file -vf select="gte(n\, 5)" ...
对于时间跨度,它更容易 - 这会跳过第一秒:$ ffmpeg -i input_file -ss 1 ...
-ss
需要一段时间:The following examples are all valid time duration:
55
55 seconds
12:03:45
12 hours, 03 minutes and 45 seconds
23.189
23.189 seconds
由于视频压缩的工作机制(P 和 B 帧不能独立存在),这些方法都不会完全准确。 ffmpeg 将尝试进行相应调整:
Note that 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.
引用 ffmpeg documentation更多。
关于php - 如何使用 ffmpeg 跳过起始帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49846095/