scherroman / mugen

A command-line music video generator based on rhythm
MIT License
220 stars 39 forks source link

Mugen crashes when merging video towards the end #47

Open DooDip opened 2 months ago

DooDip commented 2 months ago

Description It appears to be running out of RAM, but I have plenty and HTOP shows that it's running out of virtual RAM, and not using most of my 32gb.

Is it better to use 1 large video, or a bunch of small clips from a video? Is there anyway to get a log of how/why it's failing? When it fails, is there an option to save everything in the folder it tried to create? (Partial video, Segments, Rejected-Segements, etc?)

Platform Vendor ID: GenuineIntel Model name: 12th Gen Intel(R) Core(TM) i9-12900KF CPU family: 6 Model: 151

Mem: 31933 9583 17902 172 5083 22350 Swap: 9011 1589 7421

6.8.4-1-MANJARO Python 3.9 in miniconda


Analyzing audio...

Events: [<EventList 0-763 (764), type: Beat, selected: False>]

Generating music video from video segments and audio... 100%|?????????????????????????????????????????????????????????????????????????????????????????????????????????????| 765/765 [7:57:05<00:00, 37.42s/it]

Filter results: 0 segments failed filter not_is_repeat 0 segments failed filter not_has_low_contrast 0 segments failed filter not_has_text 0 segments failed filter not_has_cut

Writing music video '/home/mediaserver/Desktop/music_video_4/music_video_4.mkv'... zsh: killed mugen create --audio-source /srv/nfs/14TB/MugenProject/Khtdr.mp3


scherroman commented 1 month ago

Hey @DooDip I think I've run into a similar issue occasionally in the past where it seems it was just struggling to stitch together all the segments at the end and was likely failing from needing too much memory. I think most of the videos I generated in the past were in the range of 300-400 segments. I'm guessing you're using a longer or faster BPM to get to 765 segments, so depending on the resolution of the video sources and the specs on your computer that may be beyond the capabilities of the program currently.

As for the number of videos, you should definitely avoid passing in a bunch of small clips. It's intended to be used in scenarios like passing in a movie file, or multiple movies, or a folder full of episodes from a series, or even multiple folders for multiple seasons, perhaps even combining a series with one or more movies and then setting weights for how often you want to sample from each. Unfortunately there appears to an effective limit on the number of videos you can pass in because the program will fail due to the computer's open file limit past 50+ or so videos, and I haven't gotten around to working on a workaround yet. Would likely mean having to drop the reliance on moviepy and doing some magic with ffmpeg directly to build the final video in increments rather than all at once, which would probably solve both the open file limit and the memory issues you can get when trying to generate larger videos.

In general if there was an error with the program you should see the output printed to the console directly. If you didn't see anything in particular that sounds to me like it was killed by the OS, probably for needing too much memory/being out of memory.

There are two options --save-segments and --save-rejected-segments to save segments and rejected segments, but unfortunately savings segments runs at the very end, after generating the music video >.< I'll make a note to move that to before generating the final video given it can sometimes fail and it would be better to at least have the segments since you could throw that into another program! If you're at all interested in digging into the code, this is where the segments are output right after the command to write the music video to file.

Wish I could help more here but hope the context is useful at least