antiboredom / videogrep

automatic video supercuts with python
https://antiboredom.github.io/videogrep
Other
3.33k stars 257 forks source link

Hangs forever at "[+] creating clips" #111

Closed emenel closed 2 years ago

emenel commented 2 years ago

When running videogrep from a python script on a set of 50+ videos with vtt files it repeatably hangs after "[+] creating clips" using Python 3.10.4

I'm testing with the included auto_youtube.py demo script. On the first run with freshly downloaded videos it seems to work, but on subsequent attempts to use the downloaded videos again it freezes. I have tried letting it run overnight to see if it is just slow, but it never moves beyond this step.

When I stop the script this is the trace:

^CTraceback (most recent call last): File "/Users/[redacted]/Source/supercut-um/scut.py", line 8, in <module> videogrep.videogrep(files, 'dollars', 'fragment', 'supercut.mp4', 0, 0.5, 0, False, True) File "/Users/[redacted]/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/videogrep/videogrep.py", line 520, in videogrep create_supercut_in_batches(segments, output) File "/Users/[redacted]/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/videogrep/videogrep.py", line 334, in create_supercut_in_batches create_supercut(composition[start_index:end_index], filename) File "/Users/[redacted]/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/videogrep/videogrep.py", line 298, in create_supercut videofileclips = dict([(f, VideoFileClip(f)) for f in all_filenames]) File "/Users/[redacted]/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/videogrep/videogrep.py", line 298, in <listcomp> videofileclips = dict([(f, VideoFileClip(f)) for f in all_filenames]) File "/Users/[redacted]/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/moviepy/video/io/VideoFileClip.py", line 118, in __init__ self.audio = AudioFileClip(filename, File "/Users/[redacted]/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/moviepy/audio/io/AudioFileClip.py", line 70, in __init__ self.reader = FFMPEG_AudioReader(filename, fps=fps, nbytes=nbytes, File "/Users/[redacted]/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/moviepy/audio/io/readers.py", line 65, in __init__ self.buffer_around(1) File "/Users/[redacted]/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/moviepy/audio/io/readers.py", line 247, in buffer_around self.buffer = self.read_chunk(self.buffersize) File "/Users/[redacted]/.asdf/installs/python/3.10.4/lib/python3.10/site-packages/moviepy/audio/io/readers.py", line 113, in read_chunk s = self.proc.stdout.read(L) KeyboardInterrupt

Is it a bad file? A bad vtt?

antiboredom commented 2 years ago

It could be an issue with one or more of the files - I'm guessing the video files, not the vtts. Just to be clear - it works once, and then when you run it again, with the same parameters it hangs?

There's a few things that you could do to help debug: 1) Run videogrep as a command line tool rather than in the python script. Does it work? That will at least indicate if something is up with the script or videogrep itself. 2) can you do an ls -l in the folder with the downloads (feel free to remove any sensitive info). Curious to see if there are any empty vtt or video files.

Lastly, just as a note, videogrep usually won't completely hang - it might take a long time to render a video, but you should see a slowly moving progress bar etc.

emenel commented 2 years ago

Thanks for the quick reply.

That's correct, it works when I run it the first time and it downloads all the videos fresh. When I run it again with the already downloaded videos it hangs on 'creating clips'.

I actually can't get the command line tool to run, and I'm not sure why (the command isn't found, and i've checked my path)... so maybe that's the thing i should investigate before putting any more time into trying to figure this out.

I'll post any more info as I get it.

emenel commented 2 years ago

Ok .. I figured out the command line problem, which was just a path issue due to moving to asdf for language version management. I will do some more debugging and post either my solution or followups here.

Thanks again.

antiboredom commented 2 years ago

Great! Keep me posted…

emenel commented 2 years ago

It seems to be working properly now! I'm not entirely sure why to be honest... maybe fixing the command line tool did something?

I also decided to download all the videos separately from running videogrep via command line, rather than use python to do both as a script. I'm not sure what functional difference that wold make, but it seems to have resolved this issue.

Thanks again for the help and quick replies!

antiboredom commented 2 years ago

Glad to hear!