length mismatch > exporting to ac3

greetings,

with the help of audacity (2.3.2-2 64bit) i am restaurating my vhs captured mkvs under linux.

the usual workflow is to open up the mkv directly from within audacity, then editing the containing 16bit, 48khz stereo wav as follows:

deklicking
denoising
normalising

finally exporting to wav again (32bit floatpoint, 48khz, dither shaped) and remuxing the mkv with mkvtoolnix.

sometimes, to save up some space, ac3 is just good enough to go. now when exporting with audacity, i found out there is a tiny length mismatch with every exported ac3 in comparison to the original wav, resulting in slightly asynchronous videofiles. this never happens when exporting to wav.

now, is there a way to get identical durations with ac3s too?

Probably not. AC3 is a “lossy” format (as is MP3), which means they are “approximations” of the actual audio.

OGG is also a lossy format, so still much smaller than WAV, and still only an “approximation”, but I think it should give the exact length.

16-bit WAV is only half the size of 32-bit WAV, and still better quality than any “lossy” format. WAV will always give the right length (maximum file size is 4 GB).

FLAC is an interesting possibility. It is a “compressed” format, so only about half the size of WAV, but is “losslessly compressed”, so it’s exactly the same sound quality (and length) as WAV.

hi steve,

thanks for taking time to reply.

personally, i would go with flac or ogg as they are foss as well, but my tv only offers a limited feature set.

supported lossy audio codecs in mkvs: mp3, ac3, aac.

i guess neither makes much of a difference then - right?

So are you recombining the exported audio with video? If so, how are you doing that?

i just tested: well yes and no, ac3 is the best choice regarding the duration mismatch, worst is mp3.

you are right about ogg, exact same size as the wav. wished it would be supported.

see first post - mkvtoolnix.

I don’t know about AC3, but MP3 and AAC add a little silence at the beginning. MP3 also adds silence at the end. (I’m not sure if AAC adds silence at the end.)

If the sync error is constant throughout the program (and if the AC3 file is longer) you may be able to trim a few milliseconds off the beginning (with a short fade-in if necessary). Normally, I suggest adding a few frames of blank video but (apparently) you’re not editing the video and you may not want to “touch” it. Of course, it the AC3 is shorter you can add a bit of silence to the beginning of the audio.

If the sync gets worse throughout the program, that’s usually related to the time codes in the video part of the file. I’ve had A/V files go out-of-sync simply by editing and re-encoding them. And usually there’s no easy way to fix that. The more compressed formats (like MPEG-4) seem to be more prone to this but I’ve also seen it with MPEG-2.

finally exporting to wav again (32bit floatpoint, 48khz, dither shaped) and remuxing the mkv with mkvtoolnix.

Audacity doesn’t actually dither floating-point. But, you don’t need floating-point for your “final product”. Your digital-to-analog converter is integer based (fixed-point) and 24-bits at-most. Plus, the guys who do blind [u]ABX Tests[/u] have pretty-well demonstrated that there is no audible difference between a high resolution original and a copy downsampled to “CD quality”. In fact an good quality MP3 (or other lossy format) can often sound identical to the uncompressed original or sometimes you have to listen very carefully to hear the difference (in a proper blind listening test).

Perhaps you could try Avidemux (http://avidemux.sourceforge.net/)
No guarantee that it will be suitable for your needs, but it has options for adjusting an offset to synchronise the audio and video.

thanks a lot for answering, both of you.

i was not clear enough about that one, sorry. the 32bit floatpoint i chose within quality settings of audacity for general editing. i export to the exact same wav that i had recorded to initially (16bit, 48khz).

@steve - yep, avidemux is usually my choice of weapon when it comes to cutting (awesome copy stream function :wink:

actually, if unpacking > cleaning up in audacity > remuxing introduces a length mismatch for ac3s, i might better try optimizing the audio stream while capturing with obs studio instead of doing manual corrections later on.

the result will probably not sound as polished as with audacity, but i think this is the better approach in my case.

is anyone familiar with a “vhs” filter setup for this purpose in obs studio?

i found out, there is at least a noisereduction filter (unfortunately no declicker?), so that is at least half the battle.