Some MP4 video files I downloaded, have problems. (They are not encrypted btw)
I downloaded them with IDM, yt-dlp, aria2, nothing changed, it always ended up with a video with a corrupted timezone.
Online watching experience in the web browser: When it comes to that bad frame, video playback stops and HTML5 Video Player goes back to the beginning of the video.
Offline watching experience in PotPlayer: When it comes to that bad frame, video playback stops and PotPlayer shuts down itself.
When I open those MP4s with MediaInfo, video duration is reported much more shorter. And it's the timezone where I get the error. 4 min 12 secs, for example, or 57 min 56 secs. The video is actually 2 hours long.
When I try to add its audio track to that video file, audio never gets synched with the video.
When I extract the video with FFmpeg, corrupted frames become frozen frames, you have to skip those frames manually to resume the video playback.
Is there a good solution for those files?
I think they are uploaded to the server like that. How can I remove a few frozen frames without any re-encoding and without paying money?
+ Reply to Thread
Results 1 to 22 of 22
-
-
You can probably remove the entire GOP though. That may be anywhere from half a second to 10 seconds or more.
-
I think the easiest editor for this is AviDemux. Open the MP4 file. Navigate to the I frame just before the bad frames using the slider or the up/down arrow keys. Press the A button (mark-in). Navigate to the I frame just after the bad frames. Press the B button (mark-out). Select Edit -> Cut. Make sure Video and Audio are set to Copy, and Output Format is set to MP4. The select File -> Save. In a few seconds you'll have a new video without the bad GOP.
-
I imported the file into AviDemux. AviDemux says that it is 57 min 58 secs.
PotPlayer's playlist shows it as complete (1 hours 44 mins 37 secs). But as I wrote before, it shuts down at 00:57:58, where our bad frame is located. Before coming to that point, I jump to 58th minutes at least, video playback resumes without any problem.
With MKVToolnix, I tried to cut the 00:00:00-00:57:58 part and 00:57:59-01:44:37 part, and later join them, but it deleted 10-15 seconds of the video.
I know that bad GOP is only 1 second. If I start the playback at exactly 00:57:59, no problem then. Only 1 second has to be deleted and AviDemux does not recognise the whole video. -
That doesn't mean the GOP with the bad frame is only one second. It could be 10 or 15 seconds long but playable up until the bad frame(s), one second before the end of the GOP. But most non-reencoding tools will only cut on keyframes. So you'll lose the entire GOP. That's probably what MkvToolNix did.
-
So, what must be done not to lose 15 seconds?
In MeGUI, Lsmashworks indexes a 57-mins-video. Re-encoding will give me a 57-mins video. It will be a waste of time.
VirtualDub2 reports a complete duration under "File > File Information". I don't know what will happen after re-encoding.
It's a pity that the HD version is only at that website. I sent an e-mail about the issue, and they did not pay any attention. -
With VirtualDub2 can you seek past the bad frames and see/play the rest of the video? If so, you can do something similar to the process I gave for AviDemux. Mark-in just before the bad frames, mark out at the start of the next GOP, Edit -> Cut. Then export what's left. I don't think it will let you Direct Stream Copy the video from MP4 files though, you'll have to reencode.
-
Personally, if you have Avisynth installed, I use the following script and save it as .AVS and then drop on my favorite player with frame by frame capabilties.
Just need to adjust the Pathe and name of video and change Atrack to -2 if there is no audio.
Code:ffmpegsource2("C:\Users\Bud\Desktop\Slide.mp4", atrack=-1).converttoRGB x = float(Width) / float(Height) last.LanczosResize(round(x * 480.0 / 4.0) * 4, 480) ShowFrameNumber(scroll=True, x=10, y=127, font="Arial", size=24, text_color=$ffff80) ShowTime(x=72, y=144, font="Arial", size=24, text_color=$ffff80) ScriptClip(Last, """Subtitle("[ "+Chr(FFPICT_TYPE)+" ]"+" " +String(current_frame), size=(Height*56.0/720), align=3)""", after_frame=True)
[Attachment 63563 - Click to enlarge] -
VirtualDub2 cannot play from 57:56 to 58:06. I marked that unplayable/unreadable segment, cut it.
Then tried to save the file with video-stream copy option, it says:
"Direct stream copy cannot be used with this video stream. You may want to select different Input Driver"
"File > Export > Stream Copy" method also didn't work, it gave me a file less than 1 KB.
Scanned for unreadable frames, it didn't even give a log file. -
Tried it. PotPlayer does not open it.
VirtualDub2 says:
"test.avs does not have a video stream"
Avisynth+3.7.1 installed. -
As noted, Direct Stream Copy does not work with MP4 files. You'll have to reencode. Set Video -> Full Processing Mode. Then Video -> Compression... Select and configure a codec*. Then File -> Save Video...
* Note that audio will also be decomrpessed with an MP4 source. So if you want it compressed you'll need to select Audio -> Full Processing Mode and select/configure an audio codec.Last edited by jagabo; 26th Feb 2022 at 06:54.
-
If you can remux the mp4 to AVI with ffmpeg you can use VirtualDub2 in Direct Stream Copy mode. But I suspect the remux will abourt at the bad frames.
-
Tried it. PotPlayer does not open it.
VirtualDub2 says:
"test.avs does not have a video stream"
Avisynth+3.7.1 installed. -
Found a command-line for removing corrupted parts:
ffmpeg -i video.mp4 -vf mpdecimate,setpts=N/FRAME_RATE/TB -an video-fixed.mp4
The process is so slow, only 12 frames per second. It will take several hours to complete.
I will also try the method @jagabo wrote and see which is the best. -
That's because you're reencoding the video. The default codec for MP4 output is x264 with the medium preset and crf=23.
Although that filter sequence might fix a corrupt video as a side effect it's not explicitly intended to do so. It removes duplicate frames creating a variable frame rate video with new time stamps. It may crash at corrupt frames just like many other programs. -
I said "so slow", because I expected a real-time (20-25 fps) encoding speed (like other 1080p videos I re-encoded before)
When it dropped to 10 fps, I aborted the process.
Average bitrate was 3400 kbps, I see that ffmpeg increased it to 4400 kbps. That's my other reason to abort.
I will re-encode it with VirtualDub2 at the same bitrate. It won't save the video, anyway. -
When it dropped to 10 fps, I aborted the process.It's not important the problem be solved, only that the blame for the mistake is assigned correctly
-
I still don't understand why a stream-service releases such corrupted videos (Not encrypted, but corrupted). If that happened at Netflix or Amazon, it would be a worldwide scandal.
I decided that re-encoding will just be a waste of time. In all cases, I'll lose 15-20 seconds of video and the original video quality. And it will take longer than expected.
I will wait for the stream-service to replace the corrupted video with a fresh one. Sad to see there is no other solution.
Similar Threads
-
MP4 repair (AAC audio repair)
By holger123 in forum Newbie / General discussionsReplies: 16Last Post: 5th Jun 2020, 17:47 -
fixing corrupted frames
By sashakhina in forum Video ConversionReplies: 1Last Post: 9th Jan 2020, 12:13 -
Comparing similar video files to find corrupted frames / audio glitches
By abolibibelot in forum Video ConversionReplies: 20Last Post: 2nd Oct 2019, 10:24 -
Finding corrupted Mp4 files in directory for windows 10
By donrohner in forum RestorationReplies: 1Last Post: 3rd Mar 2019, 11:53 -
Can't Repair corrupted/truncated MP4, only audio
By JoeL248 in forum Newbie / General discussionsReplies: 3Last Post: 5th Jan 2018, 03:22