I've been running into this same problem for a long time now. I do a lot of encoding from .mkv to .mp4 (mostly hardcoding of subtitles, for compatibility for mobile devices). However, when I try to tag these .mp4 files, I will sometimes get a "hole" in the video. I can confirm that the files were fine prior to tagging. The oddest thing is that the corrupting is random; some files are fine, some aren't. For now, for any videos I encode, I copy the file prior to tagging, tag one of them, and if I find that that file has been corrupted as I'm watching it, I make a new copy of the untagged file and tag it (this usually results in the file being fine). I have no idea why tagging an .mp4 would result in it being corrupted. It should also be noted that this doesn't apply to all .mp4's I've tried; I've downloaded hundreds of .mp4's from YouTube and tagged them the exact same way, and I've never had a single problem with any of them.
If a way to stop this from happening or repair the files is impossible, I'd settle for a procedural way to check to see if the files are corrupted, since the only way I currently have is to watch them. I have an example of the corrupted files here:
Untagged, fine: https://www.dropbox.com/s/sbhflvtglhxftoj/A...ged%29.mp4?dl=0
Tagged, glitched at about 17 minutes: https://www.dropbox.com/s/lypzxtqivjqz2h4/A...min%29.mp4?dl=0
If you want to see this for yourself, I had a HELL of a time (moreso than usual) when trying to tag TV-Nihon's release of Kamen Rider OOO (which are .mp4's that I tried to tag straight as opposed to encoding first). 4 times out of 5, they'd be corrupted after tagging.
EDIT: I seem to have found a way to tell if a file is corrupted. If I take my tagged files and run just the audio through my encoder (which is very, very quick), jump to the end of that file, and if the audio there is glitched, then there's a glitch in the video itself. So I should be able to avoid glitches while I'm watching. However, I would still very much like to get some insight on how they get corrupted in the first place and how to prevent it from happening in the future.