-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
video-audio drift #46
Comments
Thanks for the report. I can't seem to repro (made a 7:30 video). Is the audio behind or ahead? Currently wl-screenrec assumes that it's being fed exactly sample_rate samples per second. If this isn't the case, the audio could end up behind the video. It's also possible that the video and audio come from different clocks, in which case we will need something like -async 1, as noted on the wl-recorder issue. |
I think it actually has been both ways, but when I noticed this time the audio was ahead of the video. My recording locally has the same drift as the YouTube asset below: https://youtu.be/vsXXgenUCDY?t=1343 I suspect the drift is even more than one second at this point.
I do not know the internals of how this works, but what happens if there is a dropped chunk of audio or video? Is there any compensation? |
Video is timestamped using the timestamp from the compositor (which compositor are you using btw?) And audio is timestamped using how many samples have been received from the beginning of the stream, so audio isn't robust to dropout. This isn't ideal and I'll post a patch here that you can test so see if that's the issue. |
Both sway and Hyprland (correctly, imo) sample from the monotonic clock, so that shouldn't be why I can't repro. Can I assume you're using the pipewire pulseaudio implementation? |
No pipewire, only pulse audio. |
What does |
I saw that the 'neofetch' command was from my desktop, but I have the exact same setup (famous last words, right) on both the laptop and the workstation. Anyways:
|
Can you attempt installing (note that I still consider this a bug, but might be a ok workaround for now) |
I managed to install pipewire again (changed Window mananger to Hyprland) hoping that
|
I installed hyprland and the pipewire stack again. It seems to work fine with Firefox so far. As an added bonus, I just recorder 45 minutes of minecraft with my son and we had no audio/video lag in the recording. |
Glad you have a workaround! I'll look into adding a clock filter+resampler. Fixing this will not be trivial so may not be soon |
Closing this not to bulk up on your tidy Issue page. Drift when it happens is very irritating so any fundamental work to protect against this would be great to have. Thanks for the great work you put into this fine tool! |
Appreciate the sentiment but it is an issue and I'd like to keep it open for anyone else who runs into it and so I don't forget it exists. |
im experiencing the same issue, though with nixos
and im using pipewire for example this clip which i took yesterday from playing gmod, the desync is like 4 seconds |
Can anyone easily repro this? I can't seem to, but I think I have a fix... @pparaxan @hholst80 @vnuxa diff --git a/src/audio.rs b/src/audio.rs
index ec6a49a..354a46d 100644
--- a/src/audio.rs
+++ b/src/audio.rs
@@ -387,7 +387,7 @@ fn audio_filter(
.input("out", 0)
.unwrap()
.parse(&format!(
- "aformat=sample_rates={}:sample_fmts={}:channel_layouts={:#x}",
+ "aresample=async=1,aformat=sample_rates={}:sample_fmts={}:channel_layouts={:#x}",
codec_sample_rate,
codec_sample_format.name(),
codec_channel_layout.bits(), can anyone who can repro before that diff confirm if they can repro after? |
Huh... Well that's odd. |
update: can repro, testing the fix now... |
Just recorded a video playing a game, the audio unfortunately is ahead of the video even with the patch you gave.
|
OBS is probably doing something smart here, like ffmpeg can under the hood (but clearly I setup wrong :) ). Do you use pipewire or pulseaudio? (you can check with |
pipewire[-pulse]
Sway
2 minutes |
(I hope that's what you meant by |
Still have the patch applied- seems to be an on and off thing, |
I noticed that I get audio/video drift (they do not sync tight) on wf-recorder. I noticed I have the same issue with wl-screenrec.
Is there any remedies I can take to avoid the lag/drift that appears? It usually takes 5min+ for the drift to be noticeable and I think it says <1sec. But even a few hundred ms in drift starts to be noticeable and irritating. At one second I'd say the recording is broken.
I am using pulse audio and the options:
ammen99/wf-recorder#241
The text was updated successfully, but these errors were encountered: