Syncing Audio and Video in Linux
After PodcampOhio, I realized that I've got quite a few video editing ideas to share with those of you who use Linux. This first one is how I sync my separate audio and video files.
I film STeaP TV with a Panasonic H200 and, while a great camera, it doesn't have a mic input so that I can easily sync up audio recorded out of the camera with the video in the camera. In order to do that, I have to export the audio from the video file, sync the better audio with the camera audio and then overlay the better audio on the video in new MPEG file.
Important tips while filming: start your audio recording first. You'll see why later. Also, when you've just started recording, slap two boards together or knock on the table or something. Really any thing that created two sharp spikes on the audio and do this before you really start doing anything. Everything before these spikes will be unusable after syncing.
Extracting the Audio
First you'll want to extract the camera audio from the video file. If the video file it MOV002.mpg, you can do that with:
mplayer MOV002.mpg -vc null -vo null -ao pcm:fast
You'll now have a file called audiodump.wav.
Syncing the Audio
Now we want to change the better audio to be synced with the camera audio. We can do that by, while filming, slapping some boards together to get a spike on the audio wave form. We can then load them both in Audacity and match up the spikes.
To do that, we zoom in to see both spikes on the screen, highlight from spike to spike in the better audio:
And then cut!
Now, highlight the better audio track and Export Selection... as MP3.
Overlaying The Audio on the Video
Now that the two audio streams have the spikes in the same place, the better audio is automatically synced with the new video! So now we just overlay the better audio on the video.
If we saved the better audio as BetterAudio.mp3 we can create a new video file called Episode.mpg like this:
mencoder MOV002.mpg -o Episodetest.mpg -ovc copy -oac mp3lame
-audiofile BetterAudio.mp3 -of mpeg
Voila!

