Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: johnr283 on March 20, 2022, 09:51:18 PM

Title: Audio out of sync during Avidemux playback
Post by: johnr283 on March 20, 2022, 09:51:18 PM
I'm trying to edit an MP4 but the video is out of sync during Avidemux playback. It's only in Avidemux. The video plays fine in VLC and MPC. I re-encoded it and it's the same thing.
Title: Re: Audio out of sync during Avidemux playback
Post by: eumagga0x2a on March 21, 2022, 12:08:49 AM
If audio is progressively ahead of video, this means you experience a performance limitation. Please make sure you have selected a hardware accelerated video output (on Windows: DXVA2 or OpenGL) and either enabled hardware accelerated video decoding (on Windows: DXVA2) if the MP4 the video track is encoded using a codec supported by the available hardware decoder or enabled multithreaded software decoding in Avidemux Preferences.

If video is progressively ahead of audio or the A/V offset remains strictly constant, please provide admlog.txt from loading this particular MP4 file. The Avidemux log file is located in %localappdata%\avidemux. The textual output of MediaInfo would be also useful.
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 21, 2022, 08:07:42 PM
admlog.txt
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 21, 2022, 08:09:26 PM
The video is ahead of the audio.
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 21, 2022, 08:12:57 PM
I can open the file in MediaInfo. How do I save the info?
Title: Re: Audio out of sync during Avidemux playback
Post by: eumagga0x2a on March 21, 2022, 11:44:58 PM
[simpleRender] 20:00:38-502 creating simple render
Please select the DXVA2 or the OpenGL renderer.

Quote from: johnr283 on March 21, 2022, 08:09:26 PMThe video is ahead of the audio.

Are you absolutely sure? A ubiquitous stereo AC3 audio track should not pose any problems. On the other hand, using an unaccelerated renderer (i.e. letting the CPU do all the heavy color conversion and scaling work) may easily result in video playback not reaching the necessary refresh rate.

Please retry with the DXVA2 renderer. If the problem persists, I'd probably need a sample.
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 22, 2022, 12:41:58 AM
admlog 2.txt
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 22, 2022, 12:46:20 AM
How do I upload a sample here?
Title: Re: Audio out of sync during Avidemux playback
Post by: szlldm on March 22, 2022, 02:26:20 AM
use wetransfer, and insert link her, or send via PM to eumagga0x2a
Title: Re: Audio out of sync during Avidemux playback
Post by: eumagga0x2a on March 22, 2022, 08:41:07 AM
[init] 00:36:40-319 Dxva (D3D) init successful, dxva render. w=1920, h=1080, zoom=0.2639, displayWidth=506, displayHeight=285
[spawnRenderer] 00:36:40-329 Dxva2 init ok

Hw accelerated renderer enabled and working, good. If the problem persists and you are going to provide the necessary sample, do you experience the A/V desync problem with a short MKV video created from this one by saving a part of it in copy mode? I prefer to keep samples rather small :-)

Quote from: szlldm on March 22, 2022, 02:26:20 AMuse wetransfer, and insert link her, or send via PM to eumagga0x2a

I'd like to add that WeTransfer doesn't require an email address despite suggesting otherwise. If you don't like WeTransfer for whatever reason, you could use Meta, Dropbox or Google Drive, which are also good options for providing samples.
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 22, 2022, 09:50:27 PM
I tried to upload the wetransfer link but get this error:
CleanTalk: *** Forbidden. Please enable JavaScript. Message seems to be spam. ***
Title: Re: Audio out of sync during Avidemux playback
Post by: eumagga0x2a on March 22, 2022, 09:53:35 PM
If you have uploaded the sample to WeTransfer and CleanTalk interferes with posting the link, please send me the link via PM.
Title: Re: Audio out of sync during Avidemux playback
Post by: eumagga0x2a on March 22, 2022, 10:26:27 PM
Thanks, got the sample, 18 seconds in duration. When I play it in Avidemux (my own local build off the latest git master), A/V sync is flawless as is in mpv. What do you observe when playing it?
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 22, 2022, 10:46:13 PM
Quote from: eumagga0x2a on March 22, 2022, 10:26:27 PMThanks, got the sample, 18 seconds in duration. When I play it in Avidemux (my own local build off the latest git master), A/V sync is flawless as is in mpv. What do you observe when playing it?

When I play it in Avidemux, the audio is a few seconds behind the video.
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 22, 2022, 10:52:04 PM
By behind the video, I mean the audio happens after the action has occurred.
Title: Re: Audio out of sync during Avidemux playback
Post by: eumagga0x2a on March 23, 2022, 10:16:31 AM
I didn't have a chance to test whether something funny happens in the audio device on Windows yet, but I definitely cannot reproduce the behaviour you describe with Avidemux on macOS.
Title: Re: Audio out of sync during Avidemux playback
Post by: eumagga0x2a on March 23, 2022, 08:30:51 PM
I've tested with my own build on Linux as well as with my own cross-compiled build on Windows 10 – no issues with the sample whatsoever, audio and video are perfectly in sync as far as I can tell (perfectly lip-synced).

Quote from: johnr283 on March 20, 2022, 09:51:18 PMI'm trying to edit an MP4 but the video is out of sync during Avidemux playback.

You reported the sync problem with a MP4 source, but provided a MKV sample (and your logs originate also from loading and playing Matroska sources). Does it mean that you experience A/V sync issues no matter what container?

Anyway, I cannot reproduce with the sample you provided.
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 23, 2022, 09:42:29 PM
My mistake, the source is MKV. Yes, it happens in both the original file and after converting to MP4. From your results, does this mean it's something with my PC and not the file or Avidemux?

I also have trouble with Avidemux playback while editing 4K files. I just assumed my PC couldn't handle 4K editing. Although again, I can play 4K HDR videos fine in various media players. Maybe my question should be asked on TomsHardware forums. My PC is an i5, 12 GB RAM, NVIDIA GeForce GTX 1650, Windows 10 64 bit.
Title: Re: Audio out of sync during Avidemux playback
Post by: eumagga0x2a on March 23, 2022, 11:21:30 PM
Quote from: johnr283 on March 23, 2022, 09:42:29 PMFrom your results, does this mean it's something with my PC and not the file or Avidemux?

Yes, this is what it looks like for me at the moment.

Quote from: johnr283 on March 23, 2022, 09:42:29 PMI also have trouble with Avidemux playback while editing 4K files. I just assumed my PC couldn't handle 4K editing. Although again, I can play 4K HDR videos fine in various media players.

Have you tried a 4K video after having enabled DXVA2 video display? No wonder 4K (probably HEVC 10-bit) won't play in real time with an unaccelerated video display. Such a video won't play in real time with software decoding and HDR tone mapping enabled either because HDR tone mapping in Avidemux is performed on the CPU.

Quote from: johnr283 on March 23, 2022, 09:42:29 PMMaybe my question should be asked on TomsHardware forums.

I cannot help in case of Windows-related issues, but I don't think this is a hardware problem.
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 23, 2022, 11:32:17 PM
I just tried a 4K video after having enabled DXVA2. It plays smoothly which it didn't before, but I still have the A/V sync problem.
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 24, 2022, 02:22:36 PM
It just occurred to me, I'm using Bluetooth headphones, why not try my speakers. The A/V sync is fine when using my PC speakers.
Title: Re: Audio out of sync during Avidemux playback
Post by: eumagga0x2a on March 24, 2022, 08:08:51 PM
You are spot on. Using my bluetooth headphones to listen to Avidemux audio playback, I needed to advance audio by ~200 ms to achieve lip-sync. When I have more time, I'll try to figure out what VLC is doing to detect the actual device-induced latency (for sure, it uses a more up-to-date Windows interface than Avidemux).

The only platform where Avidemux is able to query the delay is currently Linux with PulseAudio. If PulseAudio is able to measure and report the correct latency, Avidemux should be able to preserve A/V sync even with high latency outputs like via Bluetooth.
Title: Re: Audio out of sync during Avidemux playback
Post by: johnr283 on March 26, 2022, 01:16:01 AM
Thanks for all your help.