php - 如何使用 ffmpeg 跳过起始帧

标签 php ffmpeg

我使用 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/

相关文章:

php - foreach 给我同一行四次(PHP、Active Record、CodeIgniter)

php - 用户从下拉菜单中选择运算符并在 PHP 函数中使用它

php - 在行组中显示结果并对每个组值求和

php - 为什么 unset() 在 PHP 三元运算符中不起作用

video - HEVC:从输入二进制流中获取输入宽度和高度

c# - 如何正确地将字符串传递给ffmpeg?

php - "isset"函数的使用

ffmpeg - FMS FLV(速度)转 mp3/mp4/aac/wav

ffmpeg - 使用 ffmpeg : playback issue in older quicktime (7. 6.6 从 PNG 创建 MOV

c# - 使用 ffmpeg 和正则表达式获取 'location' 的视频