Repository navigation
Description
Unit
Port the encoder group reconfigure rules of libobs/obs-encoder.c.h to rust/obs-output, as a new module encoder_group_reconfig, next to encoder_lifecycle (#2512) and encoder_audio_start (#2320).
When an active encoder in a group gets new settings (dynamic bitrate), every encoder in the group must apply them on the same frame, so that their new keyframes line up. These decisions move:
obs_encoder_update(), the group branch. Input: the group'sreconfigure_request,encoders_reconfigured, the number of encoders in the group and the encoder'slast_handled_reconfigure_request. Output: start a new request, setreconfigure_again, or do nothing.encoder_group_new_reconfigure_request(): the request counter steps by one andencoders_updated_next_pts,encoders_reconfiguredandreconfigure_againare reset.handle_encoder_group_reconfigure_request(). It runs for each video frame fromreceive_video()and from the GPU encode thread (obs-video-gpu-encode.c.h). Input: the group's request counters,num_encoders_started,next_pts,frame_rate_divisors_lcm, and the encoder'scur_pts,timebase_num,frame_rate_divisor,last_reconfigure_requestandlast_handled_reconfigure_request. Output: apply the settings on this frame or not, the new counters, and the group's next shared frame (the encoder's next pts rounded up to a multiple oftimebase_num * frame_rate_divisors_lcm).gcd()andlcm()inadd_connection(). rust: Port the encoder connection lifecycle in obs-encoder.c to Rust #2512 kept these in C.remove_connection(): the reset of the reconfigure fields when the group becomes idle.
These stay in C:
obs_encoder_valid(),obs_data_apply(), thecontext.data,info.updateand active checks;- the group mutex, and every read and write of the encoder and the group;
info.update()indo_encode()and in the GPU encode thread;obs_encoder_set_group(), the group create and destroy.
C behaviour to keep and record in the characterization (no fix in this port):
lcm()works inint, so a large product of divisors overflows.next_pts % overall_timestepdivides by zero whentimebase_numor the LCM is 0.gcd(a, 0)divides by zero. The callers never pass 0 because the divisor is at least 1.
Plan (one PR, separate commits)
- A behaviour-neutral move of the decisions into
libobs/obs-encoder-group-reconfig.c.h, as hidden functions on plain values. - Characterization in
test_encoder_group_reconfig_steps. It covers:- the update request: the first request, a request while encoders are still applying the previous one, a second update to an encoder that already applied it (
reconfigure_again), a request after all encoders are done; - the frame step: a new request sets the next shared frame, the encoders that reach that frame apply the settings once, the last one starts the request that
reconfigure_againheld back; - the next shared frame: divisors 1, 2, 3 and their LCM, a pts already on the boundary, a pts just past it, the largest of the encoders' frames wins;
gcd()andlcm(): equal values, coprime values, one divides the other, the argument order;- the idle reset in
remove_connection(); - a real-libobs walk in
test_encoder_group_reconfig_walk: two and three video encoders from a test encoder plugin in one group, with frame rate divisors 1 and 2, encode real frames. Anobs_encoder_update()in the middle must make every encoder apply the settings on the same pts, once each. A second update while the first is still pending must run after it (reconfigure_again). It needs no GPU and no streaming service.
- the update request: the first request, a request while encoders are still applying the previous one, a second update to an encoder that already applied it (
- RED, then GREEN: the safe Rust core plus shims, in a
libobs.ported-encoder-group-reconfiggroup. Exported symbols are unchanged. - Tier 3 parity against the original C: exhaustive over small counters and divisors, plus proptests over update and frame sequences for groups of 1 to 4 encoders. Also a deliberate-break check and
port_comparisonnumbers (it runs once per video frame for each grouped encoder).
These real-libobs tests must stay green on every lane:
test_encoder_lifecycle_steps,test_encoder_group_null,test_multitrack_laddertest_encoder_gpu_gates_steps,test_encoder_packet_ts_steps
Production check: none on the obs-rust production box. Only the multitrack video output (frontend/utility/MultitrackVideoOutput.cpp.hpp) creates encoder groups, and production does not use it. The real-libobs walk test test_encoder_group_reconfig_walk runs grouped encoders through updates on real frames instead.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Oct 29, 2026
Claiming: #2913
Plan as in the issue: one PR with the behaviour-neutral move, the characterization (
test_encoder_group_reconfig_steps), RED/GREEN (obs-output::encoder_group_reconfig, grouplibobs.ported-encoder-group-reconfig) and Tier 3 parity. Before pushing: memory and time of the new tests, Windows on a local VM, and a local-gate stamp so PR CI can skip the Linux jobs. I expect a draft PR within 48 hours.vpacher commentedon Oct 29, 2026
Starting: behaviour-neutral move, then the characterization (
test_encoder_group_reconfig_steps,test_encoder_group_reconfig_walk).obs-output: Port the encoder group reconfigure rules (obs-rust#2919)