News:

--

Main Menu

Error 22 Invalid Timestamps, saved video incomplete

Started by Cormy1, April 14, 2023, 03:56:02 AM

Previous topic - Next topic

Cormy1

Are there any solutions for this that don't involve re-encoding?
Is the source file the problem?
It is very large but I could upload it.
If I just import the file then re-save it with 0 changes this error still occurs.
Generates a video of 4 minutes and 10 seconds no matter what.
Same issue on latest nightly

eumagga0x2a

Quote from: Cormy1 on April 14, 2023, 03:56:02 AMIs the source file the problem?

Yes, it is:

[extractSPSInfo] 02:05:24-380 fps1000:25000

.............

[indexify] 02:05:24-911 Build Track index, track timescale: 1000000
[indexify] 02:05:24-948 Histogram map has 2 elements.
Frame duration 16695 count: 135571
Frame duration 16696 count: 208270
[indexify] 02:05:24-953 Video index done.
[indexify] 02:05:24-954 Setting video timebase to 1 / 1000000

This is where the disaster starts: we've got a "60fps" (60000/1001) video track with wrong fps value stored in the codec extradata and an extremely high clock frequency (the video track timebase denominator) at 1 MHz, used to approximate the exact timing with a microsecond precision. Avidemux currently doesn't handle videos with clock frequency beyond the standard MPEG-TS frequency of 90 kHz:

[getTimeBase] 03:41:15-034 Ref video 0 is frame-encoded, copy mode: 1
[usSecondsToFrac] 03:41:15-034 1 us -> 0 / 1 (max: 90000)
[getTimeBase] 03:41:15-034 Timebase set to 0 / 1

i.e. an invalid time base, which gets replaced by an imprecise value derived from average fps:

[rescaleFps] 03:41:15-049  TimeBase for video 1000/59894
[open] 03:41:15-049 Video stream time base :1000 / 59894, average frame rate: 59894 / 1000

........

[open] 03:41:15-113 Timebase In  = 1000/59894
[open] 03:41:15-356 Timebase codec = 1000/59894
[open] 03:41:15-356 Timebase stream = 1/59894
[open] 03:41:15-357 Using 1000 as timebase roundup.

As 1000/59894 is greater than the precise value 1001/60000, at some point two frames passed to the muxer get identical DTS values, expressed in the units of 1000/59894, resulting in the failure to save the file. You could try setting time base in the configuration of the MP4 muxer to 60 kHz (or 90 kHz).

Of course, the attempt of Avidemux to clamp down the clock frequency of such (sort of broken) videos to accomodate needs of some mostly legacy codecs and (not legacy) containers causes the problem in the first place.


Cormy1

What results from changing the timebase? The extradata/metadata and frame durations?
Would it be in my best interest to remux with the changed timebase to fix the frame times, then re-import the fixed video before making any edits?

I can confirm that I was able to remux it with the changed timebase, I just wonder now if it is better to edit the video with the changed timebase, or edit the original and change the timebase in 1 step.
I'm only trying to make a simple cut.

Thank you

eumagga0x2a

Quote from: Cormy1 on April 17, 2023, 03:57:03 AMWhat results from changing the timebase?

This results in a smaller (if any) roundup value = no timestamp collision, but very high timestamp values, which posed (or still pose) a problem for some hardware, the reason for the attempt to keep timebase numerator as high as possible in the first place.