使用 -ss 和 -to 的 ffmpeg 部分转码

ffmpeg partial transcode using -ss and -to

我正在尝试使用 ffmpeg 实现部分转码。 我目前使用的命令是:

ffmpeg.exe -ss start-time -i source file -t duration -y -s 640x360 -b:v 1024k -vcodec libx264 -r 29.7 -movflags faststart -pix_fmt yuv420p outputfile

在 ffmpeg 文档中,我读到了 -to 参数:

-to position (output) Stop writing the output at position. position may be a number in seconds, or in hh:mm:ss[.xxx] form.

-to and -t are mutually exclusive and -t has priority.

但是当我尝试 -to 代替 "-t" 时,输出是相同的,我的意思是 -to[=21= 之后的值] 被视为输出视频的持续时间。我认为它会将价值视为结束时间。我错过了什么吗?

来自FFmpeg Wiki

Note that if you specify -ss before -i only, the timestamps will be reset to zero, so -t and -to have the same effect:

ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy cut.mp4
ffmpeg -i video.mp4 -ss 00:01:00 -to 00:02:00 -c copy cut.mp4

Here, the first command will cut from 00:01:00 to 00:03:00 (in the original), whereas the second command would cut from 00:01:00 to 00:02:00, as intended.

因此,确保在输入后放置 -ss,这样时间戳就不会被重置。