You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Debian环境PHP调用FFmpeg提取帧报Could not get frame filename错误咨询

问题根源

查看错误日志的编码器输出可以看到 Stream #0:0(und): Video: webp (libwebp_anim), yuv420p...,Debian 10 源自带的 FFmpeg 4.1 版本识别到 .webp 后缀时,默认会启用动画 webp 编码器 libwebp_anim,即使你已经指定了 -vframes 1 只输出1帧,image2 封装器依然会判定你需要输出多帧序列,当发现输出文件名没有序列占位符时就抛出对应的错误。OSX 环境下的 FFmpeg 版本默认对单帧 webp 使用静态编码器 libwebp,所以不会触发该问题。

解决方案

两种修复方式任选其一即可:

方案1:强制指定使用静态webp编码器

修改抽帧代码,保存时强制指定使用非动画的 libwebp 编码器:

$sec = 1;
$ffmpeg = \FFMpeg\FFMpeg::create([
   'ffmpeg.binaries'  => exec('which ffmpeg'),
   'ffprobe.binaries' => exec('which ffprobe')
]);

$video = $ffmpeg->open($file);
$frame = $video->frame(TimeCode::fromSeconds($sec));
// 传入额外编码器参数
$frame->save($newFilePath, [
    'c:v' => 'libwebp'
]);
if(!file_exists($newFilePath)) {
      $this->output->writeln('make: ' . $newFilePath);
}

方案2:添加 -update 1 参数

按照 FFmpeg 官方提示,给单帧输出添加 -update 1 参数,允许覆盖同一个输出文件:

$sec = 1;
$ffmpeg = \FFMpeg\FFMpeg::create([
   'ffmpeg.binaries'  => exec('which ffmpeg'),
   'ffprobe.binaries' => exec('which ffprobe')
]);

$video = $ffmpeg->open($file);
$frame = $video->frame(TimeCode::fromSeconds($sec));
// 传入update参数
$frame->save($newFilePath, [
    'update' => '1'
]);
if(!file_exists($newFilePath)) {
      $this->output->writeln('make: ' . $newFilePath);
}

如果你使用的 PHP-FFMpeg 版本不支持给 save 方法传额外参数,也可以直接调用 exec 手动执行 FFmpeg 命令,参数参考报错日志里的命令,额外加 -c:v libwebp 或者 -update 1 即可。

内容的提问来源于stack exchange,提问作者Sam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 19:39:05