I would like to use my video camera to record high quality video and unfortunately subpar audio from the camera's internal microphone, while simultaneously record the audio onto a separate device with a better quality microphone.
Then afterwards automatically sync up the external audio so that it matches the video.
This seems to me to be similar to the problem of bpm detection, but simpler, in that you do not need to find loops of similarity but basically just overlay the audio channels and see where they match the best. Or detect a certain "sync sound" event.
I prefer programming in python and any pointers to some python code that either does this or could serve as a starting point is greatly appreciated.
Update: I have found this python application with matching Android clapboard that could do the trick. It seems to work by syncing to a special sound recorded both in the video file and in the external audio file.
Update II: And here is another one in python, that is meant to be used to sync up Yotube videos recorded at the same concert.
I have now tested Allison Deal's Video sync (also linked under "Update II" in the question) and it seems to do the job.
In the root of its git directory there is a file called "alignment_by_row_channels.py". If you comment in the test code at the end of that file, it can take two mp4 videos and print the time offset between the audio in the two videos.
I tested it with a Canon HF200 video camera and an LG G2 android phone, with talk and finger snaps and very low volume on the video camera. I then manually analyzed the sound tracks with audacity.
The alignment_by_row_channels.py script indicated an offset between the two track of 15.1893 seconds. My manual analysis by looking at waveforms gave 15.181 seconds (audacity does not output less than millisecond resolution, at least not by default).
The difference is only 8.3 milliseconds or thereabouts which seems to indicate that "alignment_by_row_channels.py" does the job.
(Beware that the git repo is hefty, probably due to deleted big objects)
Used this document and it worked for me:
http://www.dsg-bielefeld.de/dsg_wp/wp-content/uploads/2014/10/video_syncing_fun.pdf
praat_command = '{} {} {} {}'.format(
praat, praat_script, sound, sound_studio)
sound_offset_time = check_output(
praat_command, shell=True).decode("utf-16")
Praat script:
form Cross Correlate two Sounds
sentence input_sound_1
sentence input_sound_2
real start_time 0
real end_time 30
endform
Open long sound file... 'input_sound_1$'
Extract part: 0, 30, "no"
Extract one channel... 1
sound1 = selected("Sound")
Open long sound file... 'input_sound_2$'
Extract part: 0, 30, "no"
Extract one channel... 1
sound2 = selected("Sound")
select sound1
plus sound2
Cross-correlate: "peak 0.99", "zero"
offset = Get time of maximum: 0,0, "Sinc70"
writeInfoLine: 'offset'
Having found no tool to sync the start of video/audio recordings, but finding more such questions, I decided to make a tool myself: syncstart. It is now on github and pypi.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With