Audio not sync after encode.

Questions and answers on how to get the most out of FFAStrans
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Audio not sync after encode.

Post by emcodem »

Mahmoud Rady wrote: Sat Oct 05, 2019 3:31 pm pcm_ s24le also gives the same result
To be honest, i think there is a good reason why ffmpeg delays the audio; i don't think you suffer from kind of a bug or so. Maybe your video pts just starts 2 frames before the first audio sample pts so ffmpeg inserts silent audio for the first 2 frames. There are lots of possibilities.

However, if you always have the same delay about 2 frames, you could possibly just use -itsoffset 0.08 to resync audio and video?
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 »

Thanks emcodem, it says encoding failed after adding -itsoffset 0.0

-f mov -vcodec dvvideo -vtag dvcp -pix_fmt yuv420p -s 720x576 -b:v 25m -qscale 15 -acodec pcm_s24le -ac 2 -ar 48000 -itsoffset 0.40
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Audio not sync after encode.

Post by emcodem »

Hey Mahmoud,

yeah, that is because itsoffset is an input option. I thought you might be able to google for this and use it in a commandline processor.

From your last post, i suspect that you are using custom ffmpeg processor, there you can play with -af adelay instead of itsoffset like this:

-f mov -vcodec dvvideo -vtag dvcp -pix_fmt yuv420p -s 720x576 -b:v 25m -qscale 15 -acodec pcm_s24le -ac 2 -ar 48000 -af adelay=delays=1920S
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 »

Hi Emcodem, I really appriciate your help on this but I'm still couldn't fix it.

workflow with command line proccessor
CMD 01.PNG
CMD 01.PNG (47.86 KiB) Viewed 9535 times
CMD 02.PNG
CMD 02.PNG (26.32 KiB) Viewed 9535 times
workflow without CMD and the Params added in the bottom box but it gives an error on the H264 node.
no CMD 01.PNG
no CMD 01.PNG (50.99 KiB) Viewed 9535 times
Mahmoud Rady
Posts: 29
Joined: Tue Sep 17, 2019 10:49 am

Re: Audio not sync after encode.

Post by Mahmoud Rady »

Output
source is in the upper audio track
FFAStrans output in the bottom audio track
Output.PNG
Output.PNG (11.18 KiB) Viewed 9534 times
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Audio not sync after encode.

Post by emcodem »

Hey Mahmoud,
it is great that you stick to that topic, keep it on, i am sure we can solve this.

You need to use a "Custom ffmpeg" processor instead of the h264 encoder node. There is no way we can make this work with the predefined h264.

in the custom ffmpeg's processor configuration you input this:

Code: Select all

-f mov -vcodec dvvideo -vtag dvcp -pix_fmt yuv420p -s 720x576 -b:v 25m -qscale 15 -acodec pcm_s24le -ac 2 -ar 48000 -af adelay=delays=1920S
let me know your results please!
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 »

Thanks for your reply... Here is the final output after adding -af adelay=delays=1920S
only the left channel in the last track has shiffted slightly to the right. I want them to be synced perfectly to the first track.
Attachments
-af adelay=delays=1920S.PNG
-af adelay=delays=1920S.PNG (7.38 KiB) Viewed 9517 times
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Audio not sync after encode.

Post by emcodem »

Mahmoud Rady wrote: Thu May 28, 2020 10:57 am -af adelay=delays=1920S
Ah, correct, we do not want to delay the audio but shift it to the other direction.
Before i go on with shots in the dark, i would like to be able to reproduce your problem. Could you upload a short example file you are using to reproduce the problem please?
https://drive.google.com/drive/folders/ ... sp=sharing

Thanks!
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 »

Hi Emcodem, input and output sample have been uploaded.
Capture.PNG
Capture.PNG (24.63 KiB) Viewed 9470 times
it's a slight shift but I want them perfectly in sync.
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Audio not sync after encode.

Post by emcodem »

Hi Mahmoud,
thanks for the files, they are just perfect samples for playing with this.
Unfortunately in my first try, i don't see the audio being shifted


My method is to first extract the audios from the files and save them to wav, e.g. this command:
ffmpeg -i "C:\Users\meme\Downloads\input_30 sec.mov" -vn "C:\Users\meme\Downloads\input.wav"

Then i compare the 2 wav files using audacity. What i see this way is perfect alignement.
inputvsoutput.png
inputvsoutput.png (176.55 KiB) Viewed 9417 times
Also, when using some player that shows me the VU, i see exactly the same VU power in both files when i compare frame by frame. The thing that both of my measuring methods have in common is that it is always ffmpeg libraries that do the decoding.

Are you using different tools for measuring or are you using always the same tool (Permiere?)? ...different decoders might show different behaviour when decoding, especially when using delivery formats like mp4/mov/h264/aac.
emcodem, wrapping since 2009 you got the rhyme?
Post Reply