feat(media_publish): per-track bitrate + codec-aware encoder options#35
Open
rickstaa wants to merge 1 commit into
Open
feat(media_publish): per-track bitrate + codec-aware encoder options#35rickstaa wants to merge 1 commit into
rickstaa wants to merge 1 commit into
Conversation
The trickle output path hardcoded x264-only encoder options
(preset=superfast, tune=zerolatency, forced-idr, bf) for every codec and had
no way to set a target bitrate. That made rendition ladders unusable for ABR
(the encoder picked its own bitrate) and made non-x264 encoders (libsvtav1,
libvpx-vp9, *_nvenc) fail at avcodec_open2.
VideoOutputConfig gains three optional, backward-compatible fields:
- bit_rate: target average video bitrate (bits/sec)
- profile: H.264/H.265 profile (ignored by codecs without one)
- encoder_options: extra ffmpeg options merged over the per-codec defaults
Encoder options are now codec-aware: x264/x265 keep the original low-latency
set (identical behavior); other codecs start from empty defaults so they open,
and callers tune via encoder_options (e.g. {"preset":"p4","tune":"ll"} for
av1_nvenc). bit_rate is applied to the stream's codec context after add_stream.
Unlocks bitrate control AND AV1/HEVC/VP9 on the live/trickle transcode path.
Defaults are unchanged, so existing x264 users see no difference.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CjPDUcYXLR6K2ft4g7TYbt
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Problem
The trickle output path (
MediaPublish/VideoOutputConfig) had two limits:VideoOutputConfighas no bitrate field, so a rendition ladder can't set per-tier bitrates — the encoder picks its own default. That makes the output unpredictable and unusable for real ABR.preset=superfast,tune=zerolatency,forced-idr,bf) and applied to every codec, solibsvtav1/libvpx-vp9/*_nvencfail atavcodec_open2withInvalid argument.Change
VideoOutputConfiggains three optional, backward-compatible fields:bit_rate— target average video bitrate (bits/sec)profile— H.264/H.265 profile ("high","main","baseline"); codecs without one ignore itencoder_options— extra ffmpeg options merged over the per-codec defaultsEncoder options are now codec-aware (
_encoder_base_options): x264/x265 keep the original low-latency set (identical behavior), other codecs start empty so they open cleanly, and callers tune viaencoder_options(e.g.{"preset":"p4","tune":"ll"}forav1_nvenc).bit_rateis applied to the stream's codec context afteradd_stream.Result
Unlocks bitrate control and AV1/HEVC/VP9 on the live/trickle transcode path in one change. Defaults are unchanged — existing libx264 callers see no difference.
Tests
tests/test_media_publish_encoder.py— x264 keeps its options, non-x264 get empty base options, and the new fields default to no-op / are accepted.4 passed.Follow-ups (not in this PR)
avcodec_open2succeeds; opt in viaencoder_options).gop_sizefromkeyframe_interval_s(segmentation currently drives keyframes).🤖 Generated with Claude Code