If OBS Studio refuses to record on a recent Ubuntu (24.04, 24.10, 25.04, 25.10) with this dialog:
An encoder error occurred while recording: Couldn't initialize muxer
…and the OBS log (~/.config/obs-studio/logs/) shows:
[ffmpeg muxer: 'simple_file_output'] os_process_pipe_write for info structure failed
[ffmpeg muxer: 'simple_file_output'] ffmpeg-mux: Couldn't initialize muxer
…this is almost certainly AppArmor blocking unprivileged user namespaces, not a codec/container/path problem.
Ubuntu 24.04+ ships with:
kernel.apparmor_restrict_unprivileged_userns = 1
OBS spawns obs-ffmpeg-mux as a helper child process and pipes muxer configuration to it over stdin. The userns restriction breaks that IPC, so the muxer never initializes — even though the helper binary itself works fine when invoked directly.
You can confirm by temporarily disabling the restriction:
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0If recording starts working, this is your problem.
Re-enable the global restriction and grant OBS its own AppArmor profile that allows userns:
sudo tee /etc/apparmor.d/obs >/dev/null <<'EOF'
abi <abi/4.0>,
include <tunables/global>
profile obs /usr/bin/obs flags=(unconfined) {
userns,
include if exists <local/obs>
}
EOF
sudo systemctl reload apparmor
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=1OBS now has the exception it needs while the rest of the system stays protected. Recording survives reboot.
- If your OBS binary lives somewhere other than
/usr/bin/obs(e.g. Flatpak), adjust the profile path. Flatpak OBS has different sandboxing — different fix. - The
flags=(unconfined)attaches a profile without confining OBS further; we just need theusernsline to be allowed. - This is unrelated to the more common "MP4 + weird codec" muxer errors. If your log doesn't contain
os_process_pipe_write, you have a different problem.
This gist was generated by Claude Code. Please verify any information before relying on it.