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

如何用FFmpeg按帧步长20将图片序列转视频?当前命令未筛选帧

Solution to Select Frames with Step 20 in FFmpeg

Got it, let's fix this for you! Your current command is including every frame from 1 to 400 because it lacks a filter to skip frames at your desired step of 20. Here's the adjusted command and a breakdown of how it works:

Correct FFmpeg Command

!ffmpeg -start_number 1 -i images%05d.jpg -vf "select='mod(n,20)==0',setpts=N/FRAME_RATE/TB" -vcodec mpeg4 result.mp4

What Each Component Does

  • select='mod(n,20)==0': This filter picks frames where the 0-based frame index n (your first input frame images00001.jpg is n=0) is divisible by 20. This means you'll get frames numbered 1, 21, 41, ..., 381 (the last valid frame before exceeding 400).
  • setpts=N/FRAME_RATE/TB: When you skip most frames, FFmpeg would otherwise play the remaining frames at the original speed, making the video way too fast. This filter adjusts the presentation timestamps to ensure the video plays at a normal, smooth pace.
  • Removed -vframes 400: Since we're explicitly selecting frames with the select filter, we don't need to limit the total frame count anymore. For your range (1 to 400), this command will output exactly 20 frames.

Alternative: Match File Numbering Directly

If you want to frame the selection based on your actual file numbers (instead of the internal index), use this command—it’s more intuitive for matching your named files:

!ffmpeg -start_number 1 -i images%05d.jpg -vf "select='mod(frame_num-1,20)==0',setpts=N/FRAME_RATE/TB" -vcodec mpeg4 result.mp4

Here, frame_num uses the 1-based number from your filenames. frame_num-1 converts it to a 0-based index, so the logic stays aligned with your step of 20. This won’t include images00400.jpg (since 400-1=399, which isn’t divisible by 20), but it’s a robust way to mirror your file naming structure.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 07:57:05