Page 1 of 5

Audio not sync after encode.

Posted: Mon May 22, 2017 1:32 pm
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

Re: Audio not sync after encode.

Posted: Mon May 22, 2017 3:32 pm
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

Re: Audio not sync after encode.

Posted: Mon May 22, 2017 6:50 pm
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

Re: Audio not sync after encode.

Posted: Mon May 22, 2017 8:38 pm
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

Re: Audio not sync after encode.

Posted: Tue May 23, 2017 10:23 am
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

Re: Audio not sync after encode.

Posted: Mon May 29, 2017 6:07 am
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

Re: Audio not sync after encode.

Posted: Mon May 29, 2017 6:40 pm
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

Re: Audio not sync after encode.

Posted: Tue Oct 01, 2019 7:25 pm
by Mahmoud Rady
Hi both, Have you found a solution for this 1 frame delay?

Re: Audio not sync after encode.

Posted: Thu Oct 03, 2019 2:13 pm
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

Re: Audio not sync after encode.

Posted: Sat Oct 05, 2019 3:31 pm
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 12206 times
Thanks.