obsproject / obsproject/obs-studio

Segfault when recording with GPU texture encoder with color format other that NV12 or P010

Open
#12,731 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
76.4k
Forks
10.2k
Avg merge
4d 23h
Merged PRs (30d)
12

Description

Operating System Info

Other

Other OS

ArchLinux

OBS Studio Version

32.0.0

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/zQofTlOJNhL7bbzH

OBS Studio Crash Log URL

No response

Expected Behavior

When selecting a color format other than NV12 or P010 with a GPU that's capable of texture encoding, I expect to have an error message that does not allow me to select it.

Current Behavior

Crash with segmentation fault when starting the recording.

The crash log with backtrace is below.
I have analyzed the issue with GDB and it comes down to this :

  • gpu_encode_available() returns false in add_connection() because of the color format setting.
  • therefore we call start_raw_video() with receive_video() as the callback
  • receive_video() calls do_encode() which expects the obs_encoder_info struct to have an encode() method.
  • texture encoders do not have this method (NULL), therefore it segfault at this point

If I use NV12 color format, there is no issue.

info: ---------------------------------
info: [FFmpeg VAAPI encoder: 'advanced_video_recording'] settings:
	device:       /dev/dri/by-path/pci-0000:03:00.0-render
	rate_control: CQP
	profile:      0
	level:        -99
	qp:           20
	bitrate:      0
	maxrate:      0
	keyint:       120
	width:        1920
	height:       1080
	b-frames:     0
	ffmpeg opts:

[New Thread 0x7fff89ffb6c0 (LWP 7039)]
[New Thread 0x7fff75a776c0 (LWP 7040)]
[New Thread 0x7fff8a9ff6c0 (LWP 7041)]
[New Thread 0x7fff767bd6c0 (LWP 7042)]
[New Thread 0x7fff88a756c0 (LWP 7043)]
[New Thread 0x7fff7727a6c0 (LWP 7044)]
[New Thread 0x7fff752766c0 (LWP 7045)]
info: libfdk_aac encoder created
info: libfdk_aac bitrate: 160, channels: 2
info: libfdk_aac encoder created
info: libfdk_aac bitrate: 160, channels: 2
info: libfdk_aac encoder created
info: libfdk_aac bitrate: 160, channels: 2
info: libfdk_aac encoder created
info: libfdk_aac bitrate: 160, channels: 2
[Detaching after vfork from child process 7046]
info: ==== Recording Start ===============================================
info: [ffmpeg muxer: 'adv_file_output'] Writing file '/home/tom/Videos/obs/2025-10-14_20-33-58.mkv'...
[New Thread 0x7fff6fd076c0 (LWP 7047)]
[New Thread 0x7fff6f5066c0 (LWP 7048)]

Thread 21 "video-io: video" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffa3fff6c0 (LWP 6745)]
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff5129a8c in do_encode (encoder=encoder@entry=0x5555575b1800, frame=frame@entry=0x7fffa3ffe020,
    frame_cts=frame_cts@entry=0x7fffa3ffe160) at /usr/src/debug/obs-studio/obs-studio-32.0.1-sources/libobs/obs-encoder.c:1417
#2  0x00007ffff5129e61 in receive_video (param=0x5555575b1800, frame=0x7fffa3ffe100)
    at /usr/src/debug/obs-studio/obs-studio-32.0.1-sources/libobs/obs-encoder.c:1522
#3  0x00007ffff51a23f7 in video_output_cur_frame (video=0x555556907aa0)
    at /usr/src/debug/obs-studio/obs-studio-32.0.1-sources/libobs/media-io/video-io.c:159
#4  video_thread (param=0x555556907aa0) at /usr/src/debug/obs-studio/obs-studio-32.0.1-sources/libobs/media-io/video-io.c:204
#5  0x00007ffff24969cb in start_thread (arg=<optimized out>) at pthread_create.c:448
#6  0x00007ffff251aa0c in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
(gdb)
Steps to Reproduce

...

Anything else we should know?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in libobs/obs-encoder.c at do_encode() and receive_video(), then trace the gpu_encode_available() path described in add_connection(). Reproduce with a GPU texture encoder and a color format other than NV12 or P010; done means recording no longer segfaults and the unsupported format produces an error or is rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.