russelltg / wl-screenrec

High performance wlroots screen recording, featuring hardware encoding
Apache License 2.0
266 stars 9 forks source link

Audio/video desync when using history #19

Closed pbogut closed 11 months ago

pbogut commented 12 months ago

When using --history flag audio and video is loosing synchronisation.

The problem seams to be that video is trimmed but audio is not, so if I start with --history 30 and then will start recording 60 seconds later I will end up with 30second video clip and 60s audio clip. So video hangs on last frame 30 second into recording and then audio still plays.

Hope that explanation maks sense, I can draw it or do some screenshots from kdenlive if its not clear enough.

russelltg commented 11 months ago

Ah that makes sense, thank you for the report. Should be an easy fix

russelltg commented 11 months ago

Should be fixed, pleas reopen if not

russelltg commented 11 months ago

There was some issues with my previous fix, but should be good now

russelltg commented 11 months ago

well, think it's still broken. will need to look closer another time

russelltg commented 11 months ago

welp i keep thinking i'm going to stop working on it but keep having an idea. think it's fixed now--sorry for email spam :)

pbogut commented 11 months ago

Thank you very much for this fix, looks like the audio is in sync with video now, that is great. I'v noticed however one issue (sorry). It looks like audio length is still of the original length and end of the clip is filled with silence (kind of).

I'm using this command to test it:

(sleep 15s; kill -USR1 wl-screenrec; sleep 10s; kill -INT wl-screenrec) &; cargo run -- -o DP-1 --audio --history 5  --audio-device "$(pactl get-default-sink).monitor"

What it does it starts recording with 5s buffer. After 15s sends USR1 (at this point clip should be 5 sec long). Sends INT after another 10 seconds. Should result with 15sec recording. What we get is 25s clip with first 15s of what we really want.

Then in mpv it just jumps from 15s to 25s, so ends correctly just displays wrong duration. When I import it to kdenlive I have 25s clip with 10s of silence and one still frame at the end.

I can easly trim video after with

ffmpeg -ss 0 -t 15 -i screenrecord.mp4 -c:a copy -c:v copy screenrecord_trimed.mp4

So I'm not too much bothered with that.

Once again thanks for the desync fix. I can create separate issue for this if you think that's better to have it separated.