Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Custom Output (FFmpeg) mode for alpha channel / transparency recording
Closes #162
Closes #151
Overview
Currently,
obs-source-recordroutes recordings through the standard OBS encoder pipeline (obs_encoder_t+ffmpeg_muxer). Standard OBS video encoders are strictly limited to opaque pixel formats (such as NV12 and I420) and drop any alpha transparency before frames reach the muxer. Consequently, recording sources with transparent backgrounds (e.g., green screen chroma keying, overlays, VTuber avatars, stinger transitions) into codecs like ProRes 4444 or QuickTime RLE loses the alpha channel.This PR introduces a Custom Output (FFmpeg) mode for recording, routing the source frames directly through OBS's built-in
ffmpeg_output(the same backend used by OBS Studio's native Settings -> Output -> Custom Output (FFmpeg)). Becauseffmpeg_outputmanages its own libavcodec encode and muxing, it directly preserves alpha channels and supports transparent pixel formats (such asyuva444p10le,argb, etc.).Key Changes
Custom Output (FFmpeg) Recording Pipeline:
ffmpeg_outputoutput instance instead offfmpeg_muxer.obs_output_set_media()andobs_output_set_mixers()respecting track selection (different_audio).mov,mkv,webm,mp4, etc.) are mapped to libavformat container identifiers.fragmented_movandfragmented_mp4, fragmented muxer flags are automatically appended for crash-resilient recordings.Alpha Channel Preservation:
ff_alpha).VIDEO_FORMAT_BGRA.ffmpeg_output's internal format selection detects the BGRA input and negotiates alpha pixel formats (e.g.yuva444p10lefor ProRes 4444).Encoder Presets & Safe Defaults:
prores): Fast Apple ProRes encoder with alpha (profile=4).prores_ks): Costlier reference encoder.qtrle): Lossless QuickTime animation with alpha.ffv1): Lossless video in MKV.libvpx-vp9): WebM alpha video.libx264.pix_fmtoptions from options string (sinceffmpeg_outputdictates the pixel format).scale_width/scale_heightwhen the user actually requests downscaling/upscaling, avoiding unnecessaryswscalepasses.Crash Prevention & Async Stop Hardening:
stop_output_async) with reference counting and weak source tracking (obs_weak_source_t), eliminating UI lockups and race conditions when encoders take time to drain.Video
You can find a short video on how the feature works in practice here:
https://youtu.be/_agfOjppnxw
How to Test
mov.prores) or QuickTime RLE (alpha) (qtrle).