nowrep / obs-vkcapture

OBS Linux Vulkan/OpenGL game capture
GNU General Public License v2.0
508 stars 25 forks source link

Switching scenes causes Game Capture to disconnect from the captured window #162

Closed amsyarzero closed 11 months ago

amsyarzero commented 11 months ago

Problem

When switching scenes in OBS, for some reason obs-vkcapture will disconnect from the captured window.

Below, I attached:

Specs

Log highlight

01:51:37.588: v4l2-input: /dev/video1: select timed out
01:51:37.588: v4l2-input: /dev/video1: failed to log status
01:51:37.858: adding 21 milliseconds of audio buffering, total audio buffering is now 21 milliseconds (source: Mic)
01:51:37.858: 
01:51:52.299: [linux-vkcapture] Client 1 connected (pid=0)
01:51:57.358: [linux-vkcapture] Client 1 not responding, disconnecting...
01:51:57.358: [linux-vkcapture] Client 1 disconnected
01:52:15.318: [linux-vkcapture] Client 2 connected (pid=0)
01:52:16.358: [linux-vkcapture] Creating texture from dmabuf 1920x1080 modifier:216172782120099860
01:52:16.358: [linux-vkcapture]  [0] fd:174 stride:7680 offset:0
01:52:20.688: ---------------------------------
01:52:20.688: [FFmpeg NVENC encoder: 'advanced_video_recording'] settings:
01:52:20.688:   encoder:      NVIDIA NVENC H.264 (FFmpeg)
01:52:20.688:   rate_control: CQP
01:52:20.688:   bitrate:      0
01:52:20.688:   cqp:          20
01:52:20.688:   keyint:       250
01:52:20.688:   preset:       p4
01:52:20.688:   tuning:       hq
01:52:20.688:   multipass:    qres
01:52:20.688:   profile:      high
01:52:20.688:   width:        1280
01:52:20.688:   height:       720
01:52:20.688:   b-frames:     2
01:52:20.688:   psycho-aq:    1
01:52:20.688:   GPU:          0
01:52:20.688: 
01:52:20.785: libfdk_aac encoder created
01:52:20.785: libfdk_aac bitrate: 160, channels: 2
01:52:20.785: libfdk_aac encoder created
01:52:20.785: libfdk_aac bitrate: 160, channels: 2
01:52:20.791: ==== Recording Start ===============================================
01:52:20.791: [ffmpeg muxer: 'adv_file_output'] Writing file '/home/amsyar/Videos/recording-dump/2023-09-05 01-52-20.mkv'...
01:52:38.983: User switched to scene 'Readying'
01:52:39.895: User switched to scene 'Recording'
01:52:44.958: [linux-vkcapture] Client 2 not responding, disconnecting...
01:52:44.958: [linux-vkcapture] Client 2 disconnected
01:52:50.787: Failed to create xdg-screensaver: 2
01:52:53.231: [ffmpeg muxer: 'adv_file_output'] Output of file '/home/amsyar/Videos/recording-dump/2023-09-05 01-52-20.mkv' stopped
01:52:53.231: Output 'adv_file_output': stopping
01:52:53.231: Output 'adv_file_output': Total frames output: 962
01:52:53.231: Output 'adv_file_output': Total drawn frames: 974

Video (click to view)

Video showcasing the issue

amsyarzero commented 11 months ago

Full log

01:51:36.468: Using EGL/X11
01:51:36.468: CPU Name: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
01:51:36.468: CPU Speed: 4001.325MHz
01:51:36.468: Physical Cores: 6, Logical Cores: 12
01:51:36.468: Physical Memory: 15818MB Total, 1399MB Free
01:51:36.468: Kernel Version: Linux 6.4.13-200.fc38.x86_64
01:51:36.468: Flatpak Branch: stable
01:51:36.468: Flatpak Arch: x86_64
01:51:36.468: Flatpak Runtime: runtime/org.kde.Platform/x86_64/6.4
01:51:36.468: App Extensions:
01:51:36.468:  - com.obsproject.Studio.Plugin.BackgroundRemoval
01:51:36.468:  - com.obsproject.Studio.Plugin.GStreamerVaapi
01:51:36.468:  - com.obsproject.Studio.Plugin.Gstreamer
01:51:36.468:  - com.obsproject.Studio.Plugin.InputOverlay
01:51:36.468:  - com.obsproject.Studio.Plugin.OBSVkCapture
01:51:36.468:  - org.freedesktop.LinuxAudio.Plugins.Calf
01:51:36.468:  - org.freedesktop.LinuxAudio.Plugins.LSP
01:51:36.468:  - org.freedesktop.LinuxAudio.Plugins.MDA
01:51:36.468:  - org.freedesktop.LinuxAudio.Plugins.ZamPlugins
01:51:36.468:  - org.freedesktop.LinuxAudio.Plugins.swh
01:51:36.468:  - com.obsproject.Studio.Locale
01:51:36.468: Runtime Extensions:
01:51:36.468:  - org.freedesktop.Platform.GL.default
01:51:36.468:  - org.freedesktop.Platform.GL.nvidia-535-104-05
01:51:36.468:  - org.freedesktop.Platform.VAAPI.Intel
01:51:36.468:  - org.freedesktop.Platform.openh264
01:51:36.468:  - org.freedesktop.Platform.VulkanLayer.OBSVkCapture
01:51:36.468:  - org.gtk.Gtk3theme.Breeze
01:51:36.468:  - org.kde.Platform.Locale
01:51:36.468:  - org.freedesktop.Platform.GL.default
01:51:36.468: Flatpak Framework Version: 1.15.4
01:51:36.468: Desktop Environment: KDE (KDE)
01:51:36.468: Session Type: x11
01:51:36.468: Window System: X11.0, Vendor: The X.Org Foundation, Version: 1.20.14
01:51:36.469: Qt Version: 6.4.3 (runtime), 6.4.3 (compiled)
01:51:36.469: Portable mode: false
01:51:36.512: OBS 29.1.3 (linux)
01:51:36.512: ---------------------------------
01:51:36.514: ---------------------------------
01:51:36.514: audio settings reset:
01:51:36.514:   samples per sec: 48000
01:51:36.514:   speakers:        2
01:51:36.514:   max buffering:   960 milliseconds
01:51:36.514:   buffering type:  dynamically increasing
01:51:36.517: ---------------------------------
01:51:36.517: Initializing OpenGL...
01:51:36.566: Loading up OpenGL on adapter NVIDIA Corporation NVIDIA GeForce GTX 1650/PCIe/SSE2
01:51:36.566: OpenGL loaded successfully, version 3.3.0 NVIDIA 535.104.05, shading language 3.30 NVIDIA via Cg compiler
01:51:36.591: ---------------------------------
01:51:36.591: video settings reset:
01:51:36.591:   base resolution:   1920x1080
01:51:36.591:   output resolution: 1280x720
01:51:36.591:   downscale filter:  Bicubic
01:51:36.591:   fps:               30/1
01:51:36.591:   format:            NV12
01:51:36.591:   YUV mode:          Rec. 709/Partial
01:51:36.591: NV12 texture support not available
01:51:36.591: P010 texture support not available
01:51:36.591: Audio monitoring device:
01:51:36.591:   name: Default
01:51:36.591:   id: default
01:51:36.591: ---------------------------------
01:51:36.605: Failed to load 'en-GB' text for module: 'aja-output-ui.so'
01:51:36.606: No AJA devices found, skipping loading AJA UI plugin
01:51:36.606: Failed to initialize module 'aja-output-ui.so'
01:51:36.618: Failed to load 'en-GB' text for module: 'aja.so'
01:51:36.618: No AJA devices found, skipping loading AJA plugin
01:51:36.618: Failed to initialize module 'aja.so'
01:51:36.622: Failed to load 'en-US' text for module: 'decklink-captions.so'
01:51:36.626: Failed to load 'en-US' text for module: 'decklink-output-ui.so'
01:51:36.630: A DeckLink iterator could not be created.  The DeckLink drivers may not be installed
01:51:36.630: Failed to initialize module 'decklink.so'
01:51:36.636: Failed to load 'en-GB' text for module: 'frontend-tools.so'
01:51:36.758: Failed to load 'en-GB' text for module: 'linux-capture.so'
01:51:36.767: Failed to load 'en-GB' text for module: 'linux-jack.so'
01:51:36.777: Failed to load 'en-GB' text for module: 'linux-pipewire.so'
01:51:36.779: [pipewire] Available captures:
01:51:36.779: [pipewire]     - Desktop capture
01:51:36.779: [pipewire]     - Window capture
01:51:36.783: Failed to load 'en-GB' text for module: 'linux-pulseaudio.so'
01:51:36.796: [obs-browser]: Version 2.21.1
01:51:36.796: [obs-browser]: CEF Version 103.0.5060.134 (runtime), 103.0.0-5060-shared-textures_143.2591+g4204d54+chromium-103.0.5060.134 (compiled)
01:51:36.801: NVENC supported
01:51:36.803: VAAPI: API version 1.18
01:51:36.803: FFmpeg VAAPI H264 encoding supported
01:51:36.804: FFmpeg VAAPI HEVC encoding supported
01:51:36.814: Failed to load 'en-GB' text for module: 'obs-libfdk.so'
01:51:36.826: Failed to load 'en-GB' text for module: 'obs-vst.so'
01:51:36.836: Failed to load 'en-GB' text for module: 'obs-websocket.so'
01:51:36.836: [obs-websocket] [obs_module_load] you can haz websockets (Version: 5.2.3 | RPC Version: 1)
01:51:36.836: [obs-websocket] [obs_module_load] Qt version (compile-time): 6.4.3 | Qt version (run-time): 6.4.3
01:51:36.836: [obs-websocket] [obs_module_load] Linked ASIO Version: 101201
01:51:36.840: [obs-websocket] [obs_module_load] Module loaded.
01:51:36.849: Failed to load 'en-GB' text for module: 'rtmp-services.so'
01:51:36.867: Failed to load 'en-GB' text for module: 'input-overlay.so'
01:51:36.867: [input-overlay] [input-overlay] Loading v5.0.0 build time 2022.09.01 14:06
01:51:36.882: [input-overlay] Using '/dev/input/js*' for gamepad discovery
01:51:36.882: [input-overlay::libgamepad] No device with id '(js0) ST LIS3LV02DL Accelerometer'
01:51:36.883: [input-overlay::libgamepad] Couldn't set binding.
01:51:36.967: [input-overlay] 'ST LIS3LV02DL Accelerometer' connected
01:51:36.973: [input-overlay] gamepad hook started
01:51:36.973: [input-overlay::libgamepad] Hook thread started
01:51:37.038: Failed to load 'en-GB' text for module: 'linux-vkcapture.so'
01:51:37.038: [linux-vkcapture] plugin loaded successfully (version 1.4.1)
01:51:37.051: Failed to load 'en-GB' text for module: 'obs-backgroundremoval.so'
01:51:37.052: [obs-backgroundremoval] plugin loaded successfully (version 1.0.1)
01:51:37.064: [obs-gstreamer] build: 7dd3e69, gst-runtime: 1.20.7
01:51:37.077: [obs-vaapi] version: 0.4.0, gst-runtime: 1.20.7
01:51:37.083: Failed to load 'en-GB' text for module: 'source-record.so'
01:51:37.083: [Source Record] loaded version 0.3.2
01:51:37.083: ---------------------------------
01:51:37.083:   Loaded Modules:
01:51:37.083:     source-record.so
01:51:37.083:     obs-vaapi.so
01:51:37.083:     obs-gstreamer.so
01:51:37.083:     obs-backgroundremoval.so
01:51:37.083:     linux-vkcapture.so
01:51:37.083:     input-overlay.so
01:51:37.083:     text-freetype2.so
01:51:37.083:     rtmp-services.so
01:51:37.083:     obs-x264.so
01:51:37.083:     obs-websocket.so
01:51:37.083:     obs-vst.so
01:51:37.083:     obs-transitions.so
01:51:37.083:     obs-outputs.so
01:51:37.083:     obs-libfdk.so
01:51:37.083:     obs-filters.so
01:51:37.083:     obs-ffmpeg.so
01:51:37.083:     obs-browser.so
01:51:37.083:     linux-v4l2.so
01:51:37.083:     linux-pulseaudio.so
01:51:37.083:     linux-pipewire.so
01:51:37.083:     linux-jack.so
01:51:37.083:     linux-capture.so
01:51:37.083:     image-source.so
01:51:37.083:     frontend-tools.so
01:51:37.083:     decklink-output-ui.so
01:51:37.083:     decklink-captions.so
01:51:37.083: ---------------------------------
01:51:37.083: ==== Startup complete ===============================================
01:51:37.133: All scene data cleared
01:51:37.133: ------------------------------------------------
01:51:37.134: v4l2-input: Start capture from /dev/video1
01:51:37.235: v4l2-input: Input: 0
01:51:37.236: v4l2-input: Resolution: 1280x720
01:51:37.236: v4l2-input: Pixelformat: MJPG
01:51:37.236: v4l2-input: Linesize: 0 Bytes
01:51:37.237: v4l2-input: Framerate: 30.00 fps
01:51:37.240: v4l2-input: /dev/video1: select timeout set to 166666 (5x frame periods)
01:51:37.275: pulse-input: Server name: 'PulseAudio (on PipeWire 0.3.79) 15.0.0'
01:51:37.276: pulse-input: Audio format: s32le, 48000 Hz, 1 channels
01:51:37.276: pulse-input: Started recording from 'alsa_input.usb-MOTU_M2_M20000025557-00.HiFi__m2_mono_in_M2_0_0__source'
01:51:37.280: pulse-input: Server name: 'PulseAudio (on PipeWire 0.3.79) 15.0.0'
01:51:37.280: pulse-input: Audio format: s32le, 48000 Hz, 2 channels
01:51:37.280: pulse-input: Started recording from 'alsa_output.usb-MOTU_M2_M20000025557-00.HiFi__hw_M2__sink.monitor'
01:51:37.286: [window-capture: 'Window Capture (Xcomposite)'] update settings:
01:51:37.286:   title: unknown
01:51:37.286:   class: unknown
01:51:37.286: 
01:51:37.290: Switched to scene 'Recording'
01:51:37.291: ------------------------------------------------
01:51:37.291: Loaded scenes:
01:51:37.291: - scene 'Recording':
01:51:37.291:     - source: 'Audio' (scene)
01:51:37.291:     - source: 'Window Capture (Xcomposite)' (xcomposite_input)
01:51:37.291:     - source: 'Game Capture' (vkcapture-source)
01:51:37.291:     - source: 'Webcam (Normal pos)' (scene)
01:51:37.291: - scene 'Stream Overlay':
01:51:37.291:     - source: 'group - stream overlay' (group)
01:51:37.291:         - source: 'Cider Now Playing' (browser_source)
01:51:37.291:         - source: 'Chat Overlay' (browser_source)
01:51:37.291: - scene 'Readying':
01:51:37.291:     - source: 'Desktop' (pulse_output_capture)
01:51:37.291:     - source: 'BG' (color_source_v3)
01:51:37.291:     - source: 'readying' (text_ft2_source_v2)
01:51:37.291:     - source: 'Stream Overlay' (scene)
01:51:37.291: - scene 'Streaming':
01:51:37.291:     - source: 'Audio' (scene)
01:51:37.291:     - source: 'Window Capture (Xcomposite)' (xcomposite_input)
01:51:37.291:     - source: 'Game Capture' (vkcapture-source)
01:51:37.291:     - source: 'Stream Overlay' (scene)
01:51:37.291:     - source: 'Webcam (Isaac pos)' (scene)
01:51:37.291:     - source: 'Webcam (Normal pos)' (scene)
01:51:37.291: - scene 'Webcam Only':
01:51:37.291:     - source: 'Audio' (scene)
01:51:37.291:     - source: 'Webcam' (v4l2_input)
01:51:37.291:     - source: 'Stream Overlay' (scene)
01:51:37.291: - scene 'BRB':
01:51:37.291:     - source: 'Desktop' (pulse_output_capture)
01:51:37.291:     - source: 'BG' (color_source_v3)
01:51:37.291:     - source: 'brb' (text_ft2_source_v2)
01:51:37.291:     - source: 'Stream Overlay' (scene)
01:51:37.291: - scene 'Tune In Next Time':
01:51:37.291:     - source: 'Desktop' (pulse_output_capture)
01:51:37.291:     - source: 'BG' (color_source_v3)
01:51:37.291:     - source: 'tune in next time' (text_ft2_source_v2)
01:51:37.291:     - source: 'Stream Overlay' (scene)
01:51:37.291: - scene 'Audio':
01:51:37.291:     - source: 'Mic' (pulse_input_capture)
01:51:37.291:     - source: 'Desktop' (pulse_output_capture)
01:51:37.291: - scene 'Webcam (Normal pos)':
01:51:37.291:     - source: 'group - webcam' (group)
01:51:37.291:         - source: 'Webcam Stream Border' (color_source_v3)
01:51:37.291:         - source: 'Webcam' (v4l2_input)
01:51:37.291:         - source: '"Streaming" Text' (text_ft2_source_v2)
01:51:37.291: - scene 'Webcam (Left pos)':
01:51:37.291:     - source: 'group - webcam' (group)
01:51:37.291:         - source: 'Webcam Stream Border' (color_source_v3)
01:51:37.291:         - source: 'Webcam' (v4l2_input)
01:51:37.291:         - source: '"Streaming" Text' (text_ft2_source_v2)
01:51:37.291: - scene 'Webcam (Isaac pos)':
01:51:37.291:     - source: 'group - webcam' (group)
01:51:37.291:         - source: 'Webcam Stream Border' (color_source_v3)
01:51:37.291:         - source: 'Webcam' (v4l2_input)
01:51:37.291:         - source: '"Streaming" Text' (text_ft2_source_v2)
01:51:37.291: ------------------------------------------------
01:51:37.588: v4l2-input: /dev/video1: select timed out
01:51:37.588: v4l2-input: /dev/video1: failed to log status
01:51:37.858: adding 21 milliseconds of audio buffering, total audio buffering is now 21 milliseconds (source: Mic)
01:51:37.858: 
01:51:52.299: [linux-vkcapture] Client 1 connected (pid=0)
01:51:57.358: [linux-vkcapture] Client 1 not responding, disconnecting...
01:51:57.358: [linux-vkcapture] Client 1 disconnected
01:52:15.318: [linux-vkcapture] Client 2 connected (pid=0)
01:52:16.358: [linux-vkcapture] Creating texture from dmabuf 1920x1080 modifier:216172782120099860
01:52:16.358: [linux-vkcapture]  [0] fd:174 stride:7680 offset:0
01:52:20.688: ---------------------------------
01:52:20.688: [FFmpeg NVENC encoder: 'advanced_video_recording'] settings:
01:52:20.688:   encoder:      NVIDIA NVENC H.264 (FFmpeg)
01:52:20.688:   rate_control: CQP
01:52:20.688:   bitrate:      0
01:52:20.688:   cqp:          20
01:52:20.688:   keyint:       250
01:52:20.688:   preset:       p4
01:52:20.688:   tuning:       hq
01:52:20.688:   multipass:    qres
01:52:20.688:   profile:      high
01:52:20.688:   width:        1280
01:52:20.688:   height:       720
01:52:20.688:   b-frames:     2
01:52:20.688:   psycho-aq:    1
01:52:20.688:   GPU:          0
01:52:20.688: 
01:52:20.785: libfdk_aac encoder created
01:52:20.785: libfdk_aac bitrate: 160, channels: 2
01:52:20.785: libfdk_aac encoder created
01:52:20.785: libfdk_aac bitrate: 160, channels: 2
01:52:20.791: ==== Recording Start ===============================================
01:52:20.791: [ffmpeg muxer: 'adv_file_output'] Writing file '/home/amsyar/Videos/recording-dump/2023-09-05 01-52-20.mkv'...
01:52:38.983: User switched to scene 'Readying'
01:52:39.895: User switched to scene 'Recording'
01:52:44.958: [linux-vkcapture] Client 2 not responding, disconnecting...
01:52:44.958: [linux-vkcapture] Client 2 disconnected
01:52:50.787: Failed to create xdg-screensaver: 2
01:52:53.231: [ffmpeg muxer: 'adv_file_output'] Output of file '/home/amsyar/Videos/recording-dump/2023-09-05 01-52-20.mkv' stopped
01:52:53.231: Output 'adv_file_output': stopping
01:52:53.231: Output 'adv_file_output': Total frames output: 962
01:52:53.231: Output 'adv_file_output': Total drawn frames: 974
01:52:53.232: ==== Recording Stop ================================================
01:52:53.273: libfdk_aac encoder destroyed
01:52:53.273: libfdk_aac encoder destroyed
01:52:57.978: ==== Shutting down ==================================================
01:52:58.055: [linux-vkcapture] destroy
01:52:58.055: pulse-input: Stopped recording from 'alsa_input.usb-MOTU_M2_M20000025557-00.HiFi__m2_mono_in_M2_0_0__source'
01:52:58.056: pulse-input: Got 3229 packets with 3874800 frames
01:52:58.056: pulse-input: Stopped recording from 'alsa_output.usb-MOTU_M2_M20000025557-00.HiFi__hw_M2__sink.monitor'
01:52:58.056: pulse-input: Got 3224 packets with 3868800 frames
01:52:58.072: v4l2-input: /dev/video1: Stopped capture after 2415 frames
01:52:58.178: All scene data cleared
01:52:58.179: ------------------------------------------------
01:52:58.306: [obs-backgroundremoval] plugin unloaded
01:52:58.306: [linux-vkcapture] plugin unloaded
01:52:58.307: [input-overlay::libgamepad] Hook thread ended
01:52:58.307: [input-overlay::libgamepad] Gamepad device '(js0) ST LIS3LV02DL Accelerometer' is still in use! (Ref count 2)
01:52:58.308: [obs-websocket] [obs_module_unload] Shutting down...
01:52:58.308: [obs-websocket] [obs_module_unload] Finished shutting down.
nowrep commented 11 months ago

The "video" is just png file.

The game capture scene item will disconnect when it gets hidden, that's intended.

Edit: video here https://www.youtube.com/watch?v=LuBvFZcyk7E

nowrep commented 11 months ago

So when you switch to another scene the game capture will disconnect, and when switching back it will reconnect. However it takes some time, which is not great.

I can add option to disable this behavior (=don't disconnect when hidden), would that work for you?

amsyarzero commented 11 months ago

@nowrep

The "video" is just png file.

That's intentional, because I didn't know how to embed a video in markdown. In hindsight, I should've just posted the link or do a hyperlink. My bad :bowing_man:

The game capture scene item will disconnect when it gets hidden, that's intended. So when you switch to another scene the game capture will disconnect, and when switching back it will reconnect. However it takes some time, which is not great. I can add option to disable this behavior (=don't disconnect when hidden), would that work for you?

That sounds perfect for my use case, but to try it out, do I have to reinstall this plugin?

Also, on another note, is there an advantage to disconnecting and reconnecting it? Because if there is, then it may be possible to add disconnect when inactive as an optional toggle, similar to how OBS has an optional toggle for shutting down sources when inactive (e.g. Browser Source).

nowrep commented 11 months ago

I just completely disabled the disconnecting on hide. Windows game capture isn't doing that either.

That sounds perfect for my use case, but to try it out, do I have to reinstall this plugin?

You need to build from source or wait for new release.