Attempt to fix video/audio desync when video pts gets desynced with clock
This commit is contained in:
parent
49c876ca00
commit
9f2f4240ba
@ -28,6 +28,8 @@ Recording monitors requires a gpu with NvFBC support (note: this is not required
|
|||||||
Run `interactive.sh` or run gpu-screen-recorder directly, for example: `gpu-screen-recorder -w $(xdotool selectwindow) -c mp4 -f 60 -a "$(pactl get-default-sink).monitor" -o test_video.mp4`\
|
Run `interactive.sh` or run gpu-screen-recorder directly, for example: `gpu-screen-recorder -w $(xdotool selectwindow) -c mp4 -f 60 -a "$(pactl get-default-sink).monitor" -o test_video.mp4`\
|
||||||
Then stop the screen recorder with Ctrl+C, which will also save the recording.\
|
Then stop the screen recorder with Ctrl+C, which will also save the recording.\
|
||||||
Send signal SIGUSR1 (`killall -SIGUSR1 gpu-screen-recorder`) to gpu-screen-recorder when in replay mode to save the replay. The paths to the saved files is output to stdout after the recording is saved.\
|
Send signal SIGUSR1 (`killall -SIGUSR1 gpu-screen-recorder`) to gpu-screen-recorder when in replay mode to save the replay. The paths to the saved files is output to stdout after the recording is saved.\
|
||||||
|
You can find the default output audio device (headset, speakers) with the command `pactl get-default-sink`. Add `monitor` to the end of that to use that as an audio input in gpu-screen-recorder.\
|
||||||
|
You can find the default input audio device (microphone) with the command `pactl get-default-source`.\
|
||||||
There is also a gui for the gpu-screen-recorder called [gpu-screen-recorder-gtk](https://git.dec05eba.com/gpu-screen-recorder-gtk/).
|
There is also a gui for the gpu-screen-recorder called [gpu-screen-recorder-gtk](https://git.dec05eba.com/gpu-screen-recorder-gtk/).
|
||||||
|
|
||||||
# Demo
|
# Demo
|
||||||
|
@ -1582,9 +1582,11 @@ int main(int argc, char **argv) {
|
|||||||
// res = cuCtxPopCurrent(&old_ctx);
|
// res = cuCtxPopCurrent(&old_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check if duplicate frame can be saved just by writing it with a different pts instead of sending it again
|
|
||||||
const double this_video_frame_time = clock_get_monotonic_seconds();
|
const double this_video_frame_time = clock_get_monotonic_seconds();
|
||||||
const int num_frames = std::max(1.0, std::round((this_video_frame_time - prev_video_frame_time) / target_fps));
|
const int64_t expected_frames = (this_video_frame_time - start_time_pts) / target_fps;
|
||||||
|
|
||||||
|
const int num_frames = std::max(0L, expected_frames - video_pts_counter);
|
||||||
|
// TODO: Check if duplicate frame can be saved just by writing it with a different pts instead of sending it again
|
||||||
for(int i = 0; i < num_frames; ++i) {
|
for(int i = 0; i < num_frames; ++i) {
|
||||||
frame->pts = video_pts_counter + i;
|
frame->pts = video_pts_counter + i;
|
||||||
if (avcodec_send_frame(video_codec_context, frame) >= 0) {
|
if (avcodec_send_frame(video_codec_context, frame) >= 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user