ArdenButterfield / stammer

Recreate any audio track by rearranging the frames of another video
MIT License
434 stars 29 forks source link

Frame length arg #45

Closed optionboom closed 1 year ago

optionboom commented 1 year ago

Addresses #37. It's a little messy, but it works.

Example usage: python stammer.py hams.mp4 song.mp3 hamsong.mp4 -f 0.1 will use frame lengths of 0.1 seconds.

ArdenButterfield commented 1 year ago

Thanks for your work! The audio works great, but I'm not sure it quite handles video correctly yet? You call build_output_video(frames_dir, outframes_dir, matcher, 1/real_frame_length, output_path) which sticks the frames from the matcher (at the custom frame rate) together at the source frame rate. This means that the audio and video gets out of sync, or even truncated, especially at high frame-rates. Instead, I think we'll need to do something a bit cleverer involving skipping or duplicating video frames.

ArdenButterfield commented 1 year ago

I can give it a shot in a sec, unless you want to.

optionboom commented 1 year ago

Oh, I see. Yeah, switching that to 1/frame_length should fix it, because it'll use the custom length if there is one and the source if there isn't. I can't test that right now so go ahead.

Edit: Never mind, that doesn't work.

ArdenButterfield commented 1 year ago

i'm working on it now

ArdenButterfield commented 1 year ago

I still want to tidy up the math some, but I think i solved it. Any thoughts?