This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[HELP] Hybrid introducing audio delay that is not present in source material
#47
Quote:Adjusting audio delay from 0 by 43 to -43 due to encoder compensation.
This happens if you encode to aac.

Quote:So why is the encoder adding this delay of -43ms? And why is it often (always?) -43ms?
Different encoders use different sample lenght depending on the channel count, the aac profile and sample rate.
Also deplay is differently compensated by different containers (mp4/mkv) and muxers.
There should be a few discussions about the aac delay over at doom9s and gleitz (german) forum.
I collected all the infos and wrote some code for it ~9 years ago.
If you are interessted I can share the ~200 lines of code which Hybrid uses since then.
I posted a simplified version 7 years ago over at videohelp:
if (heaac) { //HE-AAC
  if (nero) {
    encoderDelay = int(2336 * 2000 / audioOutputSampleRate.toDouble() + 0.5);
  } else if (qaac) {
    encoderDelay = int(2585 * 2000 / audioOutputSampleRate.toDouble() + 0.5);
    mkvDelayFix = encoderDelay;
    mkvDelayFix -= int(2112 * 1000 / audioOutputSampleRate.toDouble() + 0.5);
  } else if (fhg) {
    encoderDelay = int(794 * 2000 / audioOutputSampleRate.toDouble() + 0.5);
  }
} else if (heaacv2) { //HE-AAC V2
  if (nero) {
    encoderDelay = int(2808 * 2000 / audioOutputSampleRate.toDouble() + 0.5);
  } else if (qaac) {
    encoderDelay = int(2585 * 2000 / audioOutputSampleRate.toDouble() + 0.5);
    mkvDelayFix = encoderDelay;
    mkvDelayFix -= int(2112 * 1000 / audioOutputSampleRate.toDouble() + 0.5);
  } else if (fhg) {
    encoderDelay = int(794 * 2000 / audioOutputSampleRate.toDouble() + 0.5);
  } else { //faac/fdk/...
    encoderDelay = int(2048 * 1000 / audioOutputSampleRate.toDouble() + 0.5);
  }
} else {  //AAC LC
  if (nero) {
    encoderDelay = int(2624 * 1000 / audioOutputSampleRate.toDouble() + 0.5);
  } else if (qaac) {
    encoderDelay = int(2112 * 1000 / audioOutputSampleRate.toDouble() + 0.5);
  } else if (fhg) {
    encoderDelay = int(1600 * 1000 / audioOutputSampleRate.toDouble() + 0.5);
  } else {  //faac/fdk/..
    encoderDelay = int(2048 * 1000 / audioOutputSampleRate.toDouble() + 0.5);
  }
}
delay = QString::number(inputDelay - encoderDelay);
see: ]videohelp.com
Side note: That code does not take into consideration that fdk and fhg use different sampleSizes depending on the channel count and how Hybrid would modify the result depending on the used muxer, but it shows the general complexity of the calculation.

-> Since the channel count (usually 2 or 6), the sample rate (usually 48 000Hz) is often the same the delay modifier also often is the same. Smile

Cu Selur
Reply


Messages In This Thread
RE: Hybrid introducing audio delay that is not present in source material - by Selur - 11.10.2021, 15:26

Forum Jump:


Users browsing this thread: 1 Guest(s)