-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FFMPEG fails while trying to mux a large audio with video -- With workaround! #116
Comments
I would love if we could use Im experiencing this same problem with ffmpeg but I can't seem to fix it.
|
@t94xr 1652 fragments is fairly small even for a normal latency stream. Are you sure your case isn't more likely to do with the specific ffmpeg version being used? There were issues with 6.0 and 6.0.1 if I am not mistaken. You could try running the mux command manually with the |
hmm I'll update, im on Deb 12 |
It would probably be better to run the command and see what the error actually is first, as updating has caused more breakage than not. I don't think 5.1.4 had issues, but I cannot remember since I don't think I ended up on that version. I went from 4.X to 6.0.1 or something. |
just updated to this... added the fmpeg repos, which seems to be the latest available to me. |
Well I am pretty sure 6.0.1 is a known broken version, it has issues with the audio streams when muxing if I recall. |
well if i force fmpeg 6.1.1 deb onto my system, it borks ffmeg outright, so I'll go fingers crossed, I have a second method as a backup, now with mkvmerge I can do it manually but it would be great if it. |
I've tested everything on Windows using ffmpeg 6.1.1 and it works flawlessly. fml |
FFMPEG fails while trying to mux an audio file (AAC format at least) of around 14 GB or more, with a video file that may be larger.
The error is: I observe FFMPEG allocating more and more RAM, and finally always failing as it approaches 4 GB, reporting "Cannot allocate enough memory" right before it exits.
After much tinkering, I found a way around this, that produced perfect, seamless results from a 160 GB, 933 hour livestream:
Basically, I found that MKVMERGE will mux them.
However, it cannot take them as-is (the video coming out with an incorrect resolution, and possibly other problems), so first FFMPEG must correct them.
However, since FFMPEG cannot take files that cause it to allocate more than 4 GB memory, the files must be split. I used a file splitter to split my video file, which I renamed "v.h264", into chunks of no more than about 30 GB, and did the same for the audio file, "a.aac".
To make sure the pieces can be recombined seamlessly, I opened all the video pieces at once in a hex editor(*). I observed that the first piece starts with a sequence, "00 00 00 1C" followed by "ftypdash", that is repeated at very regular but slightly different intervals throughout the whole file -- and throughout every piece. Therefore, I cut-and-pasted such that every file piece starts with this sequence.
Then I did the same for the audio file.
As mentioned, now FFMPEG will accept them and "fix" them into playable audio & video files, by running:
ffmpeg -hide_banner -nostdin -loglevel fatal -stats -i a1.aac -c copy a1_.aac
ffmpeg -hide_banner -nostdin -loglevel fatal -stats -i a2.aac -c copy a2_.aac
ffmpeg -hide_banner -nostdin -loglevel fatal -stats -i a3.aac -c copy a3_.aac
...
ffmpeg -hide_banner -nostdin -loglevel fatal -stats -i v1.h264 -c copy v1_.h264
ffmpeg -hide_banner -nostdin -loglevel fatal -stats -i v2.h264 -c copy v2_.h264
ffmpeg -hide_banner -nostdin -loglevel fatal -stats -i v3.h264 -c copy v3_.h264
...
Then I used "MKVToolNix GUI" to combine the video, and then combine the audio, and then mux the two. (This program simply ran MKVMERGE.EXE each time).
Voilà! My 160 GB MKV video file plays and seeks quickly and perfectly, with no seams or skips.
I hope this helps someone -- esp the developer.
The text was updated successfully, but these errors were encountered: