happycube / ld-decode

Software defined LaserDisc decoder
GNU General Public License v3.0
310 stars 80 forks source link

Audio offset for AC3 #844

Open atsampson opened 1 year ago

atsampson commented 1 year ago

Having watched a few discs with AC3 audio now, it works really well, but lip sync is consistently out with the AC3 track - it needs to be delayed by about 190-200 ms to line up with the EFM and analogue tracks.

The PAL/NTSC LaserVision specs note that EFM decoding will incur a delay, and say that you should advance the EFM audio by 15.3 ms relative to the analogue audio to compensate. So I suspect the LaserDisc AC3 spec (which we don't have) has some similar wording.

Would it be worth having ld-decode take this into account when feeding RF to the AC3 demodulator?

DreckSoft commented 1 year ago

Absolutely yes. Saves a lot of time in post-processing and what's even more important: It would be less error prune. A lot of people using DDD to preserve movies will miss the necessary delay.

happycube commented 1 year ago

I think you'ld have to add silence to the ac3 file itself. I originally thought it'd be very tricky, but some googling found https://superuser.com/questions/579008/add-1-second-of-silence-to-audio-through-ffmpeg .

DreckSoft commented 1 year ago

Yes, if you have an AC3 frame with silence with the same bitrate, you can just copy it at the beginning.

But you can only correct multiples of 32ms, cause that's the duration of one AC3 frame (with 48khz sampling rate).

AkBKukU commented 1 year ago

I also noticed this, I've been using ffmpeg to correct it when making my final re-encoded file. You can add a delay to input sources with -itsoffset so I've been using the following with AC3 reads -itsoffset 0.19 -i *.ac3.

ValeZAA commented 4 months ago

There is another issue here. Due to the way lossy codecs work, and AC3 is no exception, there should be a priming of silence in the start, not present in the original source audio on disk creation: 256 samples in the very start and some in the end (end remainder can be absent). Those should be cut. But check in audacity whether AC3 has silence in the start.

Mp4 has edit list for that, mp4 has edts atom with media time 256.

So it is not just 190 ms.