High Quality Audio Sync
If you've been following my encoding tutorials you know HD audio sync is a white whale I've been chasing for a while, and I wanted to share a few factors I've noticed in case anyone else is concerned with perfect sync. It seems like most viewers don't really notice if things are 5-10ms off from the original sync, and part of this may be due to the first factor - system lag.
I noticed this when I was troubleshooting sync issues on my laptop versus desktop. If I synced it properly on my desktop it would look wrong on my laptop, and I wasn't sure which one was correct. I had a relatively complicated audio setup with several physical equalizers and splitters, and it turned out that this was adding some delay to the audio playback. But when I removed all these items and played the audio back through a USB soundcard alone, I still detected 3-5ms difference between the desktop and laptop.
This is when I discovered that any audio-post-processing your computer does during playback can also make a significant (~3ms) difference in audio timing. This can apply to TVs as well - some of them have different audio processing/effect modes that may add delay. They also typically have an actual delay option to shift the audio a certain number of milliseconds in either direction, although sometimes it may not be granular enough to get a perfect sync if it only lets you do 10ms steps.
And finally you have the physical factor - light and sound also travel at different speeds, so if you're not sitting at a computer the distance to your TV can impact it as well - 3 meters between you and the TV is almost 9 ms transit time for the audio while light is nearly instant. So you may need to adjust the audio delay on your TV to compensate for the viewing distance.
Once you have your environment set up properly you can start seeing the delays - the easiest way I've found to test them is to use VLC's Track Synchronization option to do a little trial and error testing. Generally you're looking at between 3ms and 10ms. Unfortunately the real value is often partial milliseconds, which VLC won't allow, so you likely won't figure out a perfect sync with this method - but it will help you ballpark the delay you'll need. Certain eras of media are significantly different though, I've found several Blurays from a couple decades ago that have a 100ms delay for no apparent reason. Maybe the equipment at the time called for this, but now it just looks strange.
The other factor is your workflow - depending on what software you use there may be extra delay introduced during the multiple steps of potentially transcoding and then outputting and compressing your final product. For instance it seems like when ffmpeg is used to convert DTS to PCM, it shifts the audio approximately 176 samples. With ffmpeg you can use the adelay command to shift by samples in this format:
-af "adelay=delays=176S:all=1"
-af "adelay=delays=176S:all=1"
Originally I suspected this was from ffmpeg or Premiere baking the priming samples into the audio proper as I mentioned in my HQ Encoding tutorial, however as far as I know there aren't any DTS samples that correspond to that length, so I'm not sure if the software has a hardcoded value too that takes a bite out of the true value to result in 176, but visually after a bunch of testing that seems to be the best to my eye. But as I said this can also vary per Bluray, so it isn't a hard and fast rule by any means.
This is still an ongoing project for me, and I've added new pages to bestedit to catalog some specific detailed information like this on each edit. If it isn't exactly correct for your version of a disc at least it will give you a starting place. These can be found on the Advanced page link, which is on the first line of the edit list if it's available for the project, as shown in this example.
Here are a list of scenarios for Premiere Pro high quality encoding:
DTS-MA or Meridian Lossless (MLP): Convert to PCM, use ffmpeg adelay 176S on final MXF to reposition the video into approximately correct position
AC3: This is already compatible with Premiere, convert using the high-quality MP4 option, which copies the AC3 rather than converting to PCM. No adelay necessary since the audio isn't shifted.
DTS-MA or Meridian Lossless (MLP): Convert to PCM, use ffmpeg adelay 176S on final MXF to reposition the video into approximately correct position
AC3: This is already compatible with Premiere, convert using the high-quality MP4 option, which copies the AC3 rather than converting to PCM. No adelay necessary since the audio isn't shifted.
This script can help you measure the amount of shift you should apply to match the original video file: ffmpeg A/V Sync Test Script
