Skip to content

Instantly share code, notes, and snippets.

@lazydao
Last active September 19, 2025 13:30
Show Gist options
  • Select an option

  • Save lazydao/8a87b0a6103f2d7ca17e03fab91642fe to your computer and use it in GitHub Desktop.

Select an option

Save lazydao/8a87b0a6103f2d7ca17e03fab91642fe to your computer and use it in GitHub Desktop.
ffmpeg

剪出最后 1 分钟

① 最快(不重编码,直接拷贝)

ffmpeg -sseof -60 -i "input.mp4" -c copy -avoid_negative_ts make_zero "last1min.mp4"
  • -sseof -60:从文件末尾往前定位 60 秒
  • -c copy:不重编码(快,零画质损失)
  • 可能会落在最近的关键帧,起点不是“帧级精确”。

② 帧级精确(重编码 1 分钟片段)

ffmpeg -sseof -60 -i "input.mp4" -t 60 ^
  -c:v libx264 -preset veryfast -crf 20 -c:a aac -b:a 192k "last1min_x264.mp4"
  • 先从结尾定位,再用 -t 60 精确取 60 秒。
  • 会重编码(稍慢,但起点精确)。

小提示

  • 输出给网页播放,顺手加上:-movflags +faststart(mp4 头部优化)。
  • 路径有空格请加引号 "..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment