Audio not sync after encode.

Questions and answers on how to get the most out of FFAStrans
dklooker
Posts: 29
Joined: Mon May 22, 2017 1:22 pm

Audio not sync after encode.

Post by dklooker »

Hi,

I am encoding a xdcamhd mxf / prores quicktime file to mp4. I am using the standard h264 encoder. After the encode my audio is slipped 1 frame ahead in time. I am not doing any fancy stuff.

I also tried encoding with custom ffmpeg (aac for audio), and also in this situation the audio is 1 frame ahead.

When using the mp3lame coder the audio is in sync. But I want to use aac for compatibility. Some players on mac do not have sound with the mp3lame coder.

Can you help me out?

Greetings,
David
admin
Site Admin
Posts: 1687
Joined: Sat Feb 08, 2014 10:39 pm

Re: Audio not sync after encode.

Post by admin »

Hi David, thank you for using FFAStrans and welcome to the forum! :-)

It might be tricky. Are you seeing the exact same behaviour on all your media? And are you using the "A/V Media" decoder?

-steinar
dklooker
Posts: 29
Joined: Mon May 22, 2017 1:22 pm

Re: Audio not sync after encode.

Post by dklooker »

Hi Steinar,

We see it on mxf(xdcam50mbit) files en quicktime prores (422HQ). Those are the formats we use.

I am not using a/v media decoder. It's straight from folder input -> encoder -> output folder

I read something about timestamping/negative delaying audio etc.. but it would be great to get the proces as clean as possible. Btw. encoding straight from the commandline gave the same negative delay/missing 1 frame.

If you need examples, let me know.

Greetings,
David
admin
Site Admin
Posts: 1687
Joined: Sat Feb 08, 2014 10:39 pm

Re: Audio not sync after encode.

Post by admin »

Yes, that's why I wrote that it might be tricky. If it's something deep within ffmpeg that's causing this then I'm not sure how I will work around it with FFAStrans. Ffmpeg is the main decoder/encoder in FFAStrans so if ffmpeg has a problem, FFAStrans has a problem. I'm happy to take all suggestions on how to fix it by using ffmpeg.

-steinar
dklooker
Posts: 29
Joined: Mon May 22, 2017 1:22 pm

Re: Audio not sync after encode.

Post by dklooker »

Hi Steinar,

I will do a test with some other formats. Is there a different audiocodec you can suggest?

And is this a known problem with aac?

David
dklooker
Posts: 29
Joined: Mon May 22, 2017 1:22 pm

Re: Audio not sync after encode.

Post by dklooker »

Hi Steinar,

It seems that my problem of audio not being sync is a decode problem. I checked windows media player and the beginning of sound was there (I was using a white flashframe on each second with a 1 frame 1kHz tone.) 'quicktime player' and 'telestream switch' are missing the first (audio)frame. Also importing the resulting encodes in Pro Tools removed the first frame from the beginning and offsetting the audio with 1 frame ahead.

BTW it is not 1 frame exactly but 1 frame and a bit...

So any thoughts? Is using Libfaac a possible solution?

David
admin
Site Admin
Posts: 1687
Joined: Sat Feb 08, 2014 10:39 pm

Re: Audio not sync after encode.

Post by admin »

I'm afraid I don't have the answers for you so you will have to experiment with ffmpeg on this one. The PCM audio codec is always the cleanest one but not well supported in a mp4 container.

-steinar
Mahmoud Rady
Posts: 29
Joined: Tue Sep 17, 2019 10:49 am

Re: Audio not sync after encode.

Post by Mahmoud Rady »

Hi both, Have you found a solution for this 1 frame delay?
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Audio not sync after encode.

Post by emcodem »

Hey Mahmoud,
to be honest, i don't think anyone is looking into a solution for this as dklooker reported that it is about the decoder instead of the encoder.
If you have an application that targets only decoders that show that problem it should be easy to add one silent frame at start of your audio stream. Delivery Formats like AAC are not tuned for accuracy but for saving bandwith. Also there is a lack of standartisation regarding behaviour of decoders for delivey codecs.
Basically i don't see a problem when delivery formats with high compression cause 1 frame (40ms delay), see this ebu recommendation:
https://tech.ebu.ch/docs/r/r037.pdf

The technical aspect behind this might be something like that:
viewtopic.php?f=4&t=809&p=3242&hilit=22 ... onds#p3242

Unfortunately, the only "production" codec for audio that ever crossed my way is uncompressed PCM format. So basically the recommendation is that you work with uncompressed audio and only the final product (e.g. the file you upload to youtube finally) can have compressed codecs like aac
emcodem, wrapping since 2009 you got the rhyme?
Mahmoud Rady
Posts: 29
Joined: Tue Sep 17, 2019 10:49 am

Re: Audio not sync after encode.

Post by Mahmoud Rady »

emcodem wrote: Thu Oct 03, 2019 2:13 pm it should be easy to add one silent frame at start of your audio stream.

So basically the recommendation is that you work with uncompressed audio and only the final product (e.g. the file you upload to youtube finally) can have compressed codecs like aac
Thanks emcoden,

I'm already exporting uncompressed PCM. Can you guide me on how to add or remove 1 or more frames from an audio track?
My Custom ffmpeg encoder is:

Code: Select all

-f mov -vcodec dvvideo -vtag dvcp -pix_fmt yuv420p -s 720x576 -b:v 25m -qscale 15 -acodec pcm_s16le -ac 2 -ar 48000
pcm_ s24le also gives the same result

check the attached image and let me know what you think.
Capture.PNG
Capture.PNG (143.16 KiB) Viewed 12212 times
Thanks.
Post Reply