Audio Sync Comparison for Various Render Methods

john_dennis wrote on 4/21/2018, 8:39 PM

In this post there was a reference to troublesome audio sync with the lip movement. I decided to create a video from my own camera to use to test my various delivery methods. I recorded the butt of a drumstick hitting a piece of metal with a clock running in the background for general reference. The recording was 1280x720-29.97p AVC + PCM in a MOV wrapper. I found the Vegas2Handbrake encodes produced audio that leads the video by 48ms for a single midstream sample. Other popular encoding methods that I tested were surprisingly accurate with the exception of Mainconcept AVC Internet which led by a small amount. Though unlikely to cause a complaint, I would prefer it to lag if there was a variation. Since this is forum about making video...

Change Log

2018-04-25 Replaced video with improved titling.       

Comments

Musicvid wrote on 4/21/2018, 9:50 PM

Vegas2Handbrake encodes produced audio that leads the video by 48ms for a single midstream sample. 

Back in ~2012, I reported a ~42ms audio lead in Handbrake any time a PCM audio stream is the source. I'm still looking for the post, but I believe the bug report was never acted on...

john_dennis wrote on 4/22/2018, 1:40 PM

Continuing the investigation, I looked at possible jitter in the rendered output over a period of ~1:30 (M:SS). I set a marker at the first positive rise from the zero-crossing on the left track of the sound in the source project. Adjusted the zoom to a constant and took a screenshot of the result. The animation from the still image sequence:

Marco. wrote on 4/22/2018, 1:48 PM

Interesting testing. Curious if the sync drift of MainConcept AVC and Vegas2Handbrake is caused by the encoding or by the decoding process.

john_dennis wrote on 4/22/2018, 1:53 PM

Hmmm

Musicvid wrote on 4/22/2018, 1:54 PM

In Handbrake it's the decoder. No other common input format i tested causes the audio to lead the video.

john_dennis wrote on 4/22/2018, 1:56 PM

In a minute and a half, I don't see it as "drift" as much as a relatively consistent displacement from the source timing. 

john_dennis wrote on 4/22/2018, 2:28 PM

Musicvid said:

"In Handbrake it's the decoder. No other common input format i tested causes the audio to lead the video."

I rendered the whole camera source file in Handbrake and observed the rendered audio output from Handbrake lead the source file by 44 ms when both files are compared in a new Vegas project. 

2018-04-25 Made changes to the text (underlined) so that I don't run afoul of conventions for +/- ms described in this article on lip sync. 

Musicvid wrote on 4/22/2018, 2:33 PM

Hmmm^2

Was the audio fed to Handbrake PCM or compressed?

Musicvid wrote on 4/22/2018, 2:52 PM

Here's the one surviving test I was able to find from 2012. I believe it's mov/pcm.to HB and avc/aac from HB. This is probably where I got my 40-something-milliseconds audio lead.in 2012. I remember being so exasperated at the copyright hijack that I never uploaded the compressed audio version, which was a lot closer.

(Ignore my missive to the copyroaches. I left it up because it "did" scare the pests off...)

john_dennis wrote on 4/22/2018, 4:37 PM

"Was the audio fed to Handbrake PCM or compressed?"

PCM

I remember your video from the time but I don't remember having anything else about the issue at the time.

john_dennis wrote on 4/22/2018, 5:28 PM

I did a comparison of PCM audio in an MP4 wrapper from the Sony RX10-III camera. I encoded the camera audio directly in Handbrake 1.1.0 64 Bit (the Latest release as of this date) with the following result:

With an older version of Handbrake 0.9.9-5330, the audio lead was less (~23 ms):

Musicvid wrote on 4/22/2018, 5:28 PM

Me either, John, just piecing it back together after seeing your post.

john_dennis wrote on 4/22/2018, 5:44 PM

Then, there appears to be no shift at all when Handbrake 1.1.0 64 bit encodes video from a Canon 80D (AVC+AAC in MP4 wrapper):

The PCM line of investigation seems indicated.  

Musicvid wrote on 4/22/2018, 5:45 PM

I will link to this thread on the Handbrake forum.

john_dennis wrote on 4/22/2018, 5:50 PM

I will go drink something.

Musicvid wrote on 4/22/2018, 5:54 PM

Can you post the Handbrake encode logs for a desynced render?

They are required for support at Handbrake.

;?)

john_dennis wrote on 4/22/2018, 7:09 PM

Sent you a PM.

john_dennis wrote on 4/24/2018, 12:27 PM

I created a Vegas 10.0e project file that's available here, if anyone else cares to test their round-trip experience with audio sync through the various render options and applications. This test flashes two white frames with timecode that is frame-aligned with an audio pulse.

Cliff Etzel wrote on 4/24/2018, 9:10 PM

I gave up on using the Vegas2Handbrake script specifically for this reason - The audio drift was noticeable and the client for the current project I"m editing noticed it. Once I rendered directly in Vegas using the SONY MP4 option using CUDA not only did it render faster, there appears to be no audio drift - of course I'm rendering for Vimeo and set the encode rate fairly high - VBR min set to 12mbps and max set at 24mbps and let Vimeo take care of encoding for their platform on their end. I'm hesitant to give the script another shot due to the audio drift issues. Rather play it safe and let Vegas handle the encode directly.

MikeLV wrote on 5/23/2018, 10:38 AM

I've been using this script for a while, and I don't notice any audio drift in the finished encode. Maybe 42ms is not enough time to visibly notice something is off? Of course now that you mention this, it's going to be in my head.

wwaag wrote on 5/25/2018, 12:51 AM

Yes, there is a 44 msec delay in most external aac encoders such as Nero or Frauenhofer. For an explanation, read the first post in this thread. https://github.com/mbunkus/mkvtoolnix/issues/715

AFAIK, there is no option for adjusting delay in Handbrake.

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia RTX4070 graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

Musicvid wrote on 5/25/2018, 9:05 AM

Yes wwag, that is an internal delay that vbr (non-interleaved) material always needs, and it is invoked in the file headers, even old-school mpeg-2,

It is rarely exposed, but drifts a little, and can be tweaked in yamb/mp4box if you are a perfectionist who also is compelled to drive himself batty.

The bug reported now twice to Handbrake only affects interleaved, cbr audio (often PCM) with the libav decoder. Why the audio leads by the same amount may be a coincidence, but it is a bug when using pcm source which I guess doesn't specify annoffset in the file headers.

Now, as then, the new bug report, motivated by j_d, met with a response from Handbrake...

https://forum.handbrake.fr/viewtopic.php?f=11&t=37672

 

john_dennis wrote on 5/25/2018, 7:29 PM

I'm still starting my projects in Vegas 13-453 and have more or less ignored Vegas Pro 14. Today, I happened to render using Vegas 14-270 using the Intel HEVC render template, modified to fit the 1280x720-59.94p project properties. The output wins the audio lead prize with ~67ms. 

Peer review is important.

NickHope wrote on 5/26/2018, 5:33 AM

Here are my results in VEGAS Pro 15 Update 5 (build 361).

This shows that Intel HEVC sync is fixed in the current VP15 build, at least without QSV involvement, which I can't test.

I did also test MainConcept AVC with OpenCL encode mode (AMD HD6970) and the result was the same as the CPU encode mode.

No idea what's going on with Vegas2Handbrake. I did it twice and same result.