Given that av sync is on and the correct fps is set, why would the audio track and the video track not be of the same length. When the video file is played in a media player, no such problems occur, but when placed into blender's video editor, the total length of the video is longer than that of the audio. this varies from a short 8 second video with a 1 frame difference to a 2 hour long video with several thousand frames of difference. Also the audio does lag behind the video accordingly, but it takes a minute or so to really notice it desyncronising.
When you import a video with audio into the sequencer, the following happens:
The video and audio are split into individual tracks, so they become effectively separate entities.
The audio track is imported into the sequencer while respecting the total play-length of the audio, So there is no pitch shift. (Basically, the audio is never sped up or slowed down, it will always sound right)
The video is imported frame-for-frame at the Frame Rate set in Blender's render panel, this means there is no frame interpolation or frame dropping going on.(Basically, the video will always play frame-by-frame, so it will be sped up or slowed down if the source video does not match the Frame Rate setting in Blender)
This has the unpleasant effect that if you import a 10 second video that is 24fps into Blender's 25fps timeline, the audio will last 10 seconds, but the video track (which has 240frames) will be squeezed into 240/25 = 9.6 seconds, hence the mismatch.
So, if all your source videos are the same FPS, then just set the Blender fps to that number, and you should be fine. If you have source videos of different FPS, then you can use the Speed Control strip to adjust the timing of each.
He just dragged out the end of the video snip by grabbing it then dragging, he added speed effect by selecting the strip and then going to Add > Effects Strip > Speed Control, then he made sure the box that says "Stretch to input strip length" in checked in the Speed Controls.
By doing this he was able to change the rendering to match the audio file even within a project that had a different FPS
This may be of interest to those who found this thread searching in a "greater context". I had a similar problem using Avidemux – whose purpose explicitly is editing…
A video file "file.mp4" (from youtube) reported in Avidemux to have a video length of 29 min, but an audio length of over 36 min. No "delay" or prefs value would help, as the delay grew towards the video's end. (Real SH.. !)
Here's a way to work around this "bug":
- Having opened "file.mp4" in Quicktime-player-7 export only its "sound -> WAVE" (file.wav)…
- next quit Quicktime and open the original "file.mp4" in Avidemux …
- where you add "file.wav" via this menu item:
- Audio > main track > Audio source (External WAV) > Open "file.wav".
- (For audio track settings I chose MP2(lav), 160 bps, reducing WAV's size)
- save the lot in any convenient format.
This procedure takes very little time – far less than my previous trials.