FFMPEG:最后10秒

问题描述:

我试图获得一个我不知道长度的视频的最后几秒,然后将这10秒作为新视频保存。这是否可以使用ffmpeg命令提示符?如果是,那么怎么样?

I'm trying to get the 10 last seconds of a video of which I dont know the length and then save those 10 seconds as a new video. Is this do able with the ffmpeg command prompt? And if so, how?

感谢您的帮助

Greets

使用 -sseof 选项。从文档


-sseof position(输入/输出)

喜欢 -ss 选项,但相对于文件结尾。这是负值在文件中较早,0在EOF。

-sseof position (input/output)
Like the -ss option but relative to the "end of file". That is negative values are earlier in the file, 0 is at EOF.

示例:

ffmpeg -sseof -10 -i input.mp4 output.mp4

请注意,在流复制模式(通过使用 -c copy 或等效),剪切将发生在最近的关键帧上,因此可能会削减您确切的所需时间。如果需要更多的准确性,您将不得不重新编码而不是流拷贝。

Note that in stream copy mode (by using -c copy or equivalent) the cut will occur on the nearest keyframe, so it may cut on your exact desired time. If more accuracy is needed you will have to re-encode instead of stream copy.