-ss with codec copy corrupts output
Summary of the bug:
The fast -ss tool with -codec copy seems to produce videos with incorrect metadata(?). The cuts sometimes cause video players (tested on VLC and win10 Movies & TV) to get confused, and start to playback the video from the "beginning" (of the input file) with a black screen of just a frozen frame (which is the frame at the -ss timepoint). Meanwhile sound plays back as if it was not cut at all. What is even more confusing that the behavior of this problem is inconsistent, some timepoints (typically the ones further from 0:00 in the input) are okay, some produce the incorrect black screens/glitches (see an example here: https://github.com/fourMs/MGT-python/issues/168). In some cases the metadata doesn't even get changed and the output claims to have the same number of frames and length as the input. The problem seems to be related to the mp4 container(?). It happens all the time with my test mp4 file, but if I first convert it to an avi and try to trim that the problem never happens. If I take the converted avi video, convert it back to mp4, and try to trim that with -ss and -codec copy, the problem reappears.
How to reproduce:
% ffmpeg -i input.mp4 -ss 5 -t 5 -codec copy output.mp4
ffmpeg version ffmpeg-2020-12-12-git-5148740e79-full_build
built on windows