News:

--

Main Menu

Can I save this edited file some way in v2.7.5?

Started by fish, January 09, 2020, 05:21:40 PM

Previous topic - Next topic

eumagga0x2a

Having spent quite some time on this topic, I would recommend to bite the bullet and to always re-encode such open GOP streams when deleting a middle portion.

There are fundamental problems which make it impossible to provide clean results in copy mode. The main issue is that even if we adjust segment layout to account for the presence of early B-frames (we don't do it yet, the failure to save your sample in copy mode after performing the specified cuts is the result), these frames may be (in your sample, they simply are) not cleanly decodable because they really reference frames from the previous GOP, now gone. At the same time they can't be dropped because other frames often use them as reference. So we end up with artifacts in some pictures, stutter etc. This is the best possible outcome. Is it worth the hassle?

A smaller but still complicated enough issue is that segment layout with segment boundaries at keyframe timestamps is strictly speaking invalid when we do stream copy and early B-frames are present.

Segment start must be set to the earliest non-droppable B-frame of the GOP which of course precedes the keyframe in display order but follows it in the stream order. At the same time the previous segment must be shortened to the last frame displayed before the segment switch (which is done as soon as PTS or DTS of a frame is equal or greater than the segment duration) + time increment.

These steps can be performed manually (an arduous procedure) while ignoring the warnings Avidemux will throw at the user. Doing so avoids timestamp collision and the failure to save video. We still have to put up with damaged pictures after most of the cuts.

Last but not least, the only real IDR (instant decoder refresh) frame no. 738 in the stream is advertized by the preceding SEI message wrongly as a recovery, non-IDR frame, so we distrust its IDR nature and warn about end point of the cut being set to this frame while it is the only safe place to do such a cut!

Your sample with the provided STR (steps to reproduce) helped to fix three major bugs in Avidemux and helped me to understand many aspects of the problem better, thank you very much again.