How to solve the problem of incorrect video length cut out by ffmpeg?

assume that the total duration of input.mkv is 35 minutes, and the video length cut with the following command is correct, which is 10 minutes:

ffmpeg -ss 00:10:00 -to 00:20:00 -accurate_seek -i input.mkv -codec copy -avoid_negative_ts 1 -y output.mkv

the video clipped with the following command has an error length of 15 minutes, that is, the total time (35 minutes) minus-to (20 minutes):

ffmpeg -ss 00:10:00 -to 00:20:00 -accurate_seek -i input.mkv -vcodec libx264 -acodec aac -y output.mp4

Multi-party search failed, ask for help!

Mar.11,2021

it is recommended to read the seeking section of ffmpeg in detail: https://trac.ffmpeg.org/wiki/.

The meaning of

parameter position is completely different, and the way of transcoding suppression and copy non-transcoding is also completely different. In addition, most mkv usually use H.264 encoding. If it is determined that the video stream of mkv is H.264, there is no need to call libx264 for second pressure at all, and directly-c copy cut.mp4 will be done

.

back to your question, because you misplaced the -ss parameter. For a detailed explanation, please refer to the Note section of the document: https://trac.ffmpeg.org/wiki/.

.

although most of the command parameter positions are independent of the result, most of the parameters of ffmpeg are location-related


ffmpeg -ss 00:09:50 -i input.mkv -ss 00:10:00 -to 00:20:00 -copyts -codec copy -avoid_negative_ts 1 -y output.mkv

the -I should be preceded by -ss parameter

.

ffmpeg-ss 00:10:00-to 00:20:00-accurate_seek-I input.mkv-codec copy-avoid_negative_ts 1 output.mkv

Menu