devhotteok / TwitchLink

Twitch Stream & Video & Clip Downloader/Recorder. The best GUI utility to download/record Broadcasts/VODs/Clips.
https://twitchlink.github.io
MIT License
389 stars 31 forks source link

Any way to recover corrupted mp4 file after not having enough space on disk? #184

Closed marcohohoho closed 6 months ago

marcohohoho commented 9 months ago

This is my fault since I didn't check my current disk space.

Mp4 file got corrupted (I think) this happened to me before though but it just cut off and published an mp4 file. This time, it didn't.

Log File Part: `[out#0/mp4 @ 000001ffcc5e6e40] Error writing trailer: No space left on device

frame=3534600 fps= 60 q=-1.0 Lsize=37133568kB time=16:21:50.02 bitrate=5163.8kbits/s speed= 1x

video:35974391kB audio:1173078kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

[2023-12-09 21:22:02,250][INFO] Subprocess ended with exit code 0.

[2023-12-09 21:22:02,254][INFO] Download Failed

[2023-12-09 21:22:02,254][WARNING] Download failed for the following reason.

[2023-12-09 21:22:02,255][ERROR][BaseEngine.py:41] File System Error: FileError.WriteError

There is not enough space on the disk.

NoneType: None`

image

I have a 35gb of mp4 file here but can't open it with any player I have.

Linden10 commented 8 months ago

Sorry this is late but the only way I can think of recovering the mp4 is to use ffmpeg to remux it, since the video doesn't play at all in any video player I believe that the video after remuxing (copying the video/audio into a new video container without re-encoding the whole thing) will still have some corrupted parts of the vid.

Download and install ffmpeg and use this command with the video: ffmpeg -i "C:\Path\to\video.mp4" -c:v copy -c:a copy "C:\Path\to\Output.mp4"

Replace the paths with the path to your video and where you want the output to be.

That's the only way I can think of getting the video to work again. Do note that you'll need plenty of file space, basically the same amount as the video itself to remux it!

Hope this helps, Happy New Years and sorry nobody responded this whole time! I only just noticed your post after checking up on TwitchLink's github as it's currently finicky to use at the moment. Anyways see ya!

marcohohoho commented 8 months ago

Oh no worries @Linden10 , will try this remuxing with ffmpeg the next time this happens. Thanks for the response, will keep this in mind!

marcohohoho commented 7 months ago

@Linden10 I've tried it just now, it seems remuxing won't work, ffmpeg doesn't treat the "incomplete" mp4 file as valid.

[mov,mp4,m4a,3gp,3g2,mj2 @ 00000245f69f3f80] moov atom not found [in#0 @ 00000245f69d8a80] Error opening input: Invalid data found when processing input Error opening input file 1test.mp4. Error opening input files: Invalid data found when processing input

Linden10 commented 7 months ago

@Linden10 I've tried it just now, it seems remuxing won't work, ffmpeg doesn't treat the "incomplete" mp4 file as valid.

[mov,mp4,m4a,3gp,3g2,mj2 @ 00000245f69f3f80] moov atom not found [in#0 @ 00000245f69d8a80] Error opening input: Invalid data found when processing input Error opening input file 1test.mp4. Error opening input files: Invalid data found when processing input

Ah, I never seen this error before but after looking it up online…I finally understand why your video isn’t playable!

This error “moov atom not found” means that your video is missing the video header that contains metadata about the video. From what I read, this usually happens when a recording/program ungracefully stops recording/downloading (meaning it didn’t exit/close properly) and thus the moov atom that’s normally found at the end of the mp4 file (or sometimes beginning) is missing/not added!

I found a thread that explains how to fix this issue using a program called Untrunc but you’ll need another video that’s similar to the one you’re trying to fix. (Basically download any vod of the same creator that contains the same resolution and such, size doesn't matter, you can even trim it if you want).

Here’s the link to the program: https://github.com/anthwlock/untrunc

I never used it before and don’t know it works but there’s an windows build linked in there that you can use.

Here’s the thread I read where I learned about the program and such, hope it helps! https://www.reddit.com/r/ffmpeg/comments/zge6sy/recovered_mp4_moov_atom_not_found/

devhotteok commented 6 months ago

I'm sorry, but if the download was forcibly interrupted due to disk space issues, the file would not have been saved correctly, and as a result, it is likely that most video players will not be able to play it. You might want to try using a specialized video recovery program.