You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: libobs/obs-ffmpeg: VAAPI crashes when the first encoded packet holds only headers (upstream #13316) #216
libobs/obs-nal.c:27: obs_nal_find_startcode() computes end - 3 and reads from it without checking for an empty buffer, reached from obs_avc_keyframe() / obs_hevc_keyframe() called by plugins/obs-ffmpeg/obs-ffmpeg-vaapi.c (vaapi_encode_internal).
Class
NULL pointer dereference (crash).
How it is reached
If the VAAPI encoder's first packet holds only parameter sets (SPS/PPS, or VPS/SPS/PPS for HEVC), obs_extract_avc_headers() moves all of it into the header, leaving the packet buffer NULL with size 0. The keyframe check then runs on (NULL, 0) and reads address 0. The reporter's crash (AMD Mullins, radeonsi) has the trace obs_nal_find_startcode(p=0x0, end=0x0) ← obs_avc_keyframe ← vaapi_encode_internal ← vaapi_encode_tex.
Reproduced on a Radeon 680M by forcing a header-only first packet (a shim on avcodec_receive_packet): H.264 and HEVC texture encoding segfault with the same backtrace. The Rust port of the NAL code already returns early on end <= p; only the C build crashes.
Proposed fix and failing test
Fix: obs_nal_find_startcode() returns end when end <= p (matching the Rust port), and the VAAPI encoder skips a packet whose data is empty instead of passing NULL on.
RED tests (cmocka): test_avc_keyframe_empty in test_avc_parse.c (a header-only SPS+PPS packet through obs_extract_avc_headers(), then the keyframe check, plus (NULL, 0)) and test_hevc_keyframe_empty in test_hevc.c both crash today with SIGSEGV. With the fix both pass, and with the forced header-only first packet all four VAAPI encoders (ffmpeg_vaapi, ffmpeg_vaapi_tex, hevc_ffmpeg_vaapi, hevc_ffmpeg_vaapi_tex) record cleanly.
Cause: when the VAAPI encoder's first packet contains only the stream headers (SPS/PPS, or VPS/SPS/PPS for HEVC), OBS moves all of it into the header and is left with an empty packet. The keyframe check then read address 0, which is the obs_nal_find_startcode(p=0x0, end=0x0) frame in your trace. The NAL scanner now stops on an empty buffer and the encoder skips empty packets. Forcing a header-only first packet on a Radeon 680M gave your exact backtrace before the fix, and clean recordings on all four VAAPI encoders after it.
Workaround on stock OBS: use a software encoder (x264) instead of VAAPI.
obs-rust is an AI-assisted fork of OBS; on Arch it's obs-studio-rust-git in the AUR.
If you can try it on the Mullins machine, a short reply here on whether VAAPI recording starts would really help, especially if it still crashes.
Activity
rdoupe commentedon Oct 11, 2026
Claiming: this issue.
test_avc_keyframe_emptyandtest_hevc_keyframe_empty(both crash today).obs_nal_find_startcode()(like the Rust port) and skip empty packets in the VAAPI encoder.PR within the hour.
libobs, obs-ffmpeg: Handle an empty packet in the keyframe checks
test/cmocka: Cover keyframe checks on an empty packet
libobs, obs-ffmpeg: Handle an empty packet in the keyframe checks
rdoupe commentedon Oct 11, 2026
@vicho314 you reported this in obsproject/obs-studio#13316, so a heads-up: it's fixed here in obs-rust by #218.
Cause: when the VAAPI encoder's first packet contains only the stream headers (SPS/PPS, or VPS/SPS/PPS for HEVC), OBS moves all of it into the header and is left with an empty packet. The keyframe check then read address 0, which is the
obs_nal_find_startcode(p=0x0, end=0x0)frame in your trace. The NAL scanner now stops on an empty buffer and the encoder skips empty packets. Forcing a header-only first packet on a Radeon 680M gave your exact backtrace before the fix, and clean recordings on all four VAAPI encoders after it.Workaround on stock OBS: use a software encoder (x264) instead of VAAPI.
obs-rust is an AI-assisted fork of OBS; on Arch it's
obs-studio-rust-gitin the AUR.If you can try it on the Mullins machine, a short reply here on whether VAAPI recording starts would really help, especially if it still crashes.