mifi / lossless-cut

The swiss army knife of lossless video/audio editing
https://losslesscut.app/
GNU General Public License v2.0
26.61k stars 1.28k forks source link

Extremely high frame rate in data after cutting #1096

Closed FiftyFour7250 closed 1 month ago

FiftyFour7250 commented 2 years ago

Hi. This problem has been bothering me for more than a year. After cutting, the video file becomes with an extremely high frame rate. Technically, it's still the same 24 fps, but more is displayed in the file data, for example via MediaInfo. Much more. If you cut some ~70GB 4K HDR file, then from 24 fps it will turn into about ~5000 fps. If the files are lighter, 5GB 1080p for example, then there it rises to ~800 fps. In a number of players, this causes playback problems, so after cropping I have to convert them to MKVToolNix.

mifi commented 2 years ago

May be the same issue as #757 ?

FiftyFour7250 commented 2 years ago

@mifi I don't know. Is it possible to fix? Is there anything I can do to help? Here is a concrete example. The original file is 2.5 hours and 59.7 GB, 23.976 FPS image

Cut: 1 min, 455 MB, and 3534.140 (!!!) FPS image Download the cropped segment

mifi commented 2 years ago

Hard to say without being able to reproduce, but it seems to be only the metadata that is wrong, no? In ffprobe it shows still the correct fps 24fps (and in losslesscut). Also when playing the file back in a player, it seems to be playing back at 24fps, and not 3534.140. In which player does it cause problems?

You could try to download the latest ffmpeg and run the ffmpeg command from the help screen from your command line with ffmpeg 5 and see if that resolves the problem, or if possible share an original file that I can look into.

FiftyFour7250 commented 2 years ago

but it seems to be only the metadata that is wrong, no? In ffprobe it shows still the correct fps 24fps (and in losslesscut). Also when playing the file back in a player, it seems to be playing back at 24fps, and not 3534.140.

Yea, that's what I'm talking about. This is still 24 fps, and in the absolute majority of players and other programs this doesn't cause problems. But some special cases may conflict with this. So the problem of extremely high FPS in metadata exists.

Hard to say without being able to reproduce if possible share an original file that I can look into.

I don't have that much space on GoogleDrive to send 60 GB, but as I said, it happens to me with almost any file, so here's a smaller option. The only thing that I understood is that the larger original file, then more fake frame rate increases. Thus, in the examples below, since the original file is only 2.44 GB - it has increased from 23.976 to 47.784, not so much, but still problem, and at least you will be able to reproduce

There are two files, the original, and a cropped one with fake fps.

mifi commented 2 years ago

Thanks. I did some testing with ffmpeg v5 and I can see that even with the simplest ffmpeg command, it shows the behaviour that you're describing. But it only happens when actually cutting the file. Another interesting observation is that it changes Frame rate mode from Constant (original file) to Variable, also only when cutting. And the frame rate gets higher, the shorter the cut is.

ffmpeg -i S232.mkv -t 100 -c copy out.mkv

Frame rate mode                          : Variable
Frame rate                               : 85.324 FPS
Original frame rate                      : 23.976 (24000/1001) FPS
ffmpeg -i S232.mkv -t 10 -c copy out.mkv

Frame rate mode                          : Variable
Frame rate                               : 843.414 FPS
Original frame rate                      : 23.976 (24000/1001) FPS
ffmpeg -i S232.mkv -t 1 -c copy out.mkv

Frame rate mode                          : Variable
Frame rate                               : 6 832.934 FPS
Original frame rate                      : 23.976 (24000/1001) FPS

When not cutting at all, the frame rate stays the same as the original:

ffmpeg -i S232.mkv -c copy out.mkv

Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS

TBH I'm not sure why this is happening and whether it can be solved with some ffmpeg option. Needs some more research. At least I would think it would be a common problem because it happens with such a basic command.

Looking at #757 it seems like it's the exact same thing happening.

FiftyFour7250 commented 2 years ago

@mifi I don't understand this very well, so I can hardly help, but maybe it's worth looking towards mkvtoolnix? I mean, there's also working lossless, in a few seconds, even without changing anything, we get the same file, but with the correct frame rate, and it even fixes the fake fps. Maybe it's possible to use the same method in LosslessCut?

mifi commented 2 years ago

i'm not at all familiar with mkvtoolnix code, and I don't think it even uses the ffmpeg command line, like LosslessCut does, so I'm not sure if it's comparable.

Xuchilbara commented 8 months ago

Hi, just wanted to corroborate that this happens to me as well. Sorry if the thread is old.

I'm using MPEG-2 files from DVDs now, and they are 25 FPS, but when I split them by chapters using LLC the framerate in MediaInfo says "variable frame rate" and then an insane high number.

The files seem to play correctly, but it bothers me it could produce some problems with some players or converters.

As another mate commented already, MKVToolNix doesn't do that, also Avidemux too (but this one isn't really useable for chapters tho...). Although the process is slower and it produces small extra chapters in between, possibly from menus or something, so I like Lossless Cut better, except for this little technical quirk.

PS: Also they're interlaced and it adds one line to MediaInfo saying "stored in 2 blocks" or something like that.

I await some feedback and thank you for such an amazing program.

FernandoFuvio commented 3 months ago

I'm having an issue similar to this. In my case it's actually editing a "cut & merge" video from LLC in DaVinci Resolve. The original video was CFR 60fps, but after I edit it in LLC it becomes a VFR with a different framerate. Usually it's not an issue, but when I edit it in DaVinci Resolve the audio drifts away from the video.

At the start of the clip it is perfeclty synced, but as the clip goes it gets more and more unsynced with the audio. I've had this issue before with VFR recordings so I'm thinking is the same issue.

The audio stays at "constant 60fps", but the video image gets "time-shifted" by the VFR conversion.

If only we could cut the files without converting it to VFR, this issue would be gone.

mifi commented 1 month ago

closing this to keep issue count down - but it will be tracked in #1027