Skip to content
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

OpenGL Screen Tearing Problem #163

Closed
reboot opened this issue Jul 12, 2014 · 1 comment
Closed

OpenGL Screen Tearing Problem #163

reboot opened this issue Jul 12, 2014 · 1 comment

Comments

@reboot
Copy link
Contributor

reboot commented Jul 12, 2014

I have been using OBS-Studio on Linux for some time now and always noticed some strange stutter in the streamed video and in saved files. This is not visible in the preview windows of OBS.

You can see this problem in the YouTube Video (at 1:00 and at 2:38) and in this Sequence of Frames from the Video.

Since this is not visible in the preview window I investigated how the frames are encoded and found that it basically works like this:

output_frame()
    gs_entercontext();
    download_frame(..., ..., &frame);
        stagesurface_map(..., &frame->data[0], ...)
            *frame->data[0] = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
    gs_leavecontext();
    output_video_data(..., &frame, ...);

Which means the pointer that is returned by OpenGL is passed to the encoder after the GL context is detached from the turrent thread. I could not find any information in the OpenGL documentation how long the pointer is valid and may be used, but I wrote the work-a-round reboot/obs-studio@c8b54a7 that copies the frame data into a buffer allocated in memory before it is passed to the encoder. The seems to fix the problem and I did not notice any stutter in streams or video files anymore. The work-a-round is not really a fix, but it demonstrates that OpenGL seems to reuse the buffer memory for the new image, before the encoder finished encoding the frame.

Hardware and Driver Info:

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTS 250/PCIe/SSE2
OpenGL version string: 3.3.0 NVIDIA 331.67

@jp9000
Copy link
Member

jp9000 commented Jul 12, 2014

Hm, thank you for pointing it out, I'll investigate.

Gol-D-Ace pushed a commit to Gol-D-Ace/obs-studio that referenced this issue Feb 20, 2021
palana added a commit to amazon-contributing/upstreaming-to-obs-studio that referenced this issue Jan 22, 2024
…amazon-ivs-service

Add proper Amazon IVS service
joelvaneenwyk pushed a commit to joelvaneenwyk/obs-studio that referenced this issue Feb 1, 2024
* obsproject#153 obsproject#167 obsproject#178 Update localization.
* obsproject#157 Fix a few example shaders and add some new ones.
* obsproject#160 Fix Look Ahead setting
* obsproject#162 Increase Direct3D11 texture eviction priority.
* obsproject#163 Asynchronous Nvidia Face Tracking.
* obsproject#164 Add clang-tidy support to CMake.
* obsproject#165 Fix some clang-10 errors.
* obsproject#168 Updated StreamFX logo.
* obsproject#169 Redesigned version string generation.
* obsproject#170 Fix compiler error with C++17 when using libobs.
* obsproject#171 Add global configuration handler.
* obsproject#172 Move Windows exclusive library handler into its own file.
* obsproject#174 Refactor everything into the streamfx:: namespace.
* obsproject#176 Implement a new UI/UX experience for StreamFX users.
* obsproject#177 Link to stdc++fs on GNU and Clang.
* obsproject#179 Fix incorrect render sizes and performance with gfx::shader.
* obsproject#181 obsproject#183 Fix locale strings missing info or no longer being used.
* obsproject#182 Add a default path for gfx::shader based on the selected file or the examples directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants