You are not logged in.

#1 2023-01-24 20:16:31

mega0drive
Member
Registered: 2023-01-24
Posts: 3

ffmpeg -ss -to does not clip particular file correctly

ffmpeg -i ~/input.mkv -ss 00:02:28 -to 00:02:37 ./source/output.mkv

outputs a completely different part of the video, a different version of this video outputs correctly but the input video is lower quality.

How do I find out what causes this issue?

Last edited by mega0drive (2023-01-26 00:38:43)

Offline

#2 2023-01-24 22:19:18

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,325

Re: ffmpeg -ss -to does not clip particular file correctly

Is the syntax w/o -ss legal?
That aside, try mkvinfo, there're probably multiple video streams (concatenated?) and ffmpeg picks the wrong one, or maybe audio and video are of different length or whatnot.
How did you obtain the timestamps? ffplay?

Offline

#3 2023-01-26 00:43:45

mega0drive
Member
Registered: 2023-01-24
Posts: 3

Re: ffmpeg -ss -to does not clip particular file correctly

@seth
oops, forum typo, fixed it
mkvinfo doesn't show multiple video streams, it does show that the 'default duration' for the video and audio streams are different though, is that something? 00:00:00.041708333 vs 00:00:00.085333333 (video and audio respectively)
i got the time stamps from watching it in smplayer, had no trouble with other files doing it like that

I tried just copying the video stream but it still doesn't clip the part I want

Last edited by mega0drive (2023-01-26 00:44:42)

Offline

#4 2023-01-26 03:21:56

mpan
Member
Registered: 2012-08-01
Posts: 1,591
Website

Re: ffmpeg -ss -to does not clip particular file correctly

The order of arguments is important in ffmpeg. Your `-ss` and `-to` do not apply to the input file. What you do is re-encode the entire file using default settings (usually producing poor quality) and then cut the output, using timestamps from the output stream, not the input stream.

If you wanted to cut a fragment from the input, the options should apply to the input, not to the output file:

ffmpeg -ss START -to END -i INPUT ENCODING_OPTIONS… OUTPUT

Last edited by mpan (2023-01-26 03:23:34)


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#5 2023-01-26 16:19:32

mega0drive
Member
Registered: 2023-01-24
Posts: 3

Re: ffmpeg -ss -to does not clip particular file correctly

@mpan did not realise that, thank you

ffmpeg -ss 00:02:28 -to 00:02:37 -i ~/input.mkv -c:v copy -map 0:0 ./source/output.mkv

has the same issue, but when trying ffplay like @seth suggested i noticed the video im trying to clip has an opening section missing which changes the timestamps vs when it's opened in smplayer or vlc, could someone explain why that might be?

Last edited by mega0drive (2023-01-26 16:20:04)

Offline

#6 2023-01-26 16:40:50

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,325

Re: ffmpeg -ss -to does not clip particular file correctly

It's probably because the audio track is twice as long as the video and probably starts ahead.
Matroska is a really versatile format (hence the name) and allows offsets in the container as well as timestamp scaling; simply adding a start and endposition might not be enough information to know what you want and ffmpeg guesses/defaults "wrong" (you could possibly use mkvmerge instead)

Offline

Board footer

Powered by FluxBB