Video Audio Sync 
Work in progress.
Fix videos where the audio is out of sync, in much stranger ways than just a simple constant time shift.
Background
I transferred some old VHS cassettes to my computer using a video capture tool. The results were good, except that the audio was out-of-sync.
The audio tracks of the videos were longer than the video tracks. But speeding the audio up to match in length didn’t help. (The videos are so long that you can’t hear the speed difference.) The audio was still not in sync. It turned out that the amount of time the audio was off differed throughout the video. We’re talking everything from a couple of seconds up to one and a half minutes, with no predictable pattern.
Instead of speeding up the entire audio track, different segments of it needs to be sped up differently. I couldn’t find a tool that could do that in a somewhat automated fashion, so I built one myself (using technology I know and enjoy).
Requirements:
Later versions might work as well.
Browser support
I noticed that Firefox does not report the correct length of the audio. Chrome (and Chromium) does, however. The app should work in any modern browser, but be aware that browsers may interpret media files differently. Also, I haven’t really tested anything other than Firefox and Chrome.
Usage
- Run
python3 extract.py summer94.mp4 aacto separate the video and audio ofsummer94.mp4their own files (assumingaacis the audio format). - Open the separated video and audio files in the browser-based sync tool.
- Find matching points of video and audio using the tool and download the resulting points file.
- Run
python3 sync.py summer94_video.mp4 summer94_audio.aac summer94_audio_points.jsonto speed up and slow down segments ofsummer94_audio.aacaccording tosummer94_audio_points.jsonand then produce a single file again.
Development
For the frontend you’ll need Node.js 8 (or possibly later) and some knowledge about Elm and web technology.
npm installnpm run elm-installnpm start
Magic GET parameters:
?audio=audio.aac&video=video.mp4: Pre-load audio and video so you don’t have to upload the files so often. Putaudio.aacandvideo.mp4in thebuild/directory (you might need to create it first).?warn_on_close=1: Test onbeforeunload.
Additional tasks:
npm run elm-analyseruns elm-analyse.npm run elm-formatruns elm-format.npm run elm-forma -- --yesto avoid the prompt.npm run eslintruns ESLint.npm run eslint -- --fixfixes most errors.npm run stylelintruns stylelint.npm run stylelint -- --fixfixes most errors.npm run fixruns all format/lint tools in autofix mode.npm run buildmakes a production build.npm run testis run by Travis CI.