RecorderIO: option to encode at a constant bit rate (and set the bit rate)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- audio-video-rtc
Hướng nghiên cứu
Start with the RecorderIO implementation and its encoding thread, then review the open pull request #7740 and related issue #4052 to understand the current work. The proposal names codec_context.bit_rate and the Opus vbr option; completion means exposing both settings with defaults preserved and tests covering constant packet sizes, defaults, and invalid bit rates.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Feature Type
Would make my life easier
Feature Description
RecorderIO encodes the session recording with the encoder's defaults: libopus, variable bit rate, 96 kb/s target for stereo. There is no way to change this.
Two examples of consequences:
- Recorded lengths display wrong on macOS. A session almost always opens on silence, which VBR packs into 3-byte packets. Players that estimate an Ogg Opus length from the file size over the bit rate of the first pages then overshoot badly. AVFoundation's quick duration, which Finder, QuickLook and Preview use, showed a 211 s recording as 6:53 and 7:09 (two recordings of the same session, before and after noise cancellation). The files are correct: ffprobe, CoreAudio (
afinfo) and AVFoundation's precise duration all read 211.8 s. The same session recorded by LiveKit Egress, which is constant 128 kb/s, showed 3:34. - Quality and size cannot be matched to Egress (#4042 asked for the bit rate for this reason).
I measured what fixes the length estimate, re-encoding the same recording:
| Change | AVFoundation estimate (real length 3:32) |
|---|---|
Ogg page layout (page_duration 20 ms or 260 ms) |
8:02 / 6:24 |
| Drop the silent opening | 5:07 |
| Constrained VBR | 7:45 |
vbr=off at 96 kb/s |
3:33 |
vbr=off at 128 kb/s |
3:33 |
Only a constant bit rate works, so a bit rate alone (the scope of #4052) does not cover it.
Proposal
Two keyword arguments on RecorderIO, with defaults that keep today's behaviour:
RecorderIO(agent_session=session, bit_rate=128_000, constant_bit_rate=True)
bit_rate: int | None = None: setscodec_context.bit_rate;Nonekeeps the encoder default.constant_bit_rate: bool = False: sets the Opusvbr=offoption.Truewithbit_rate=128_000matches Egress recordings byte for byte per second (320-byte packets).
Both libopus and ffmpeg's native opus encoder honour the two settings (checked with PyAV 18).
Workarounds / Alternatives
- Subclassing
RecorderIOand overriding_encode_threadwith a copy that sets the two values. That is what we run today, with a test that pins the SDK method's source hash so an upgrade tells us to re-sync the copy. It works, but it freezes a method that has had three fixes since August (#6921, #7047, #7079). - Re-encoding the file after the session: lossy twice and too slow at shutdown for long sessions.
- Changing the Ogg page layout: tested, does not help (table above).
- #4052 (open since November 2025, approved twice) adds
bitrateonly and now conflicts with the rewritten module; withoutvbr=offit does not fix the length estimate.
Additional Context
Additional Context:
- Related: #4042 (closed as completed, but #4052 never merged).
- Agents 1.8.4; PyAV 18.0.0; macOS 26. Measured with
AVURLAsset.durationwith and withoutAVURLAssetPreferPreciseDurationAndTimingKey. - I have a PR ready with the two arguments, docstrings, and unit tests (constant packet sizes at 64 and 128 kb/s, defaults unchanged, invalid bit rate rejected). If you would rather expose these through
AgentSession.start(record=...)/RecordingOptionsas well, happy to add that.
- Ngôn ngữ chính
- Python
- Star
- 14.6k
- Fork
- 3.9k
- Merge trung bình
- 3 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 173
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của livekit/agents
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Assistant markup is stripped from chat history when expressive mode is offCó thể đã có người làm @ShivamSharma43 đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hostsCó thể làm lại được @AbarnaaSree đã nhận 47 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
livekit/agents#7022 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
DuplexRealtimeAdapter: transcript fragment for audio that is never sent anchors the next burst, shifting transcripts by one utteranceCó thể đã có người làm @dyyfk đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của livekit/agents
Issue tương tự
-
area:core-platform effort:S priority:P3 status:in-review type:test
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 80/100
randomparity/kdive#3246 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Requantification library converts m/z to mass with the hydrogen-atom mass instead of the proton massĐang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
nf-core/metaboigniter#130 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
common-workflow-language/cwl-utils#477 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add dependabotĐang mởfeat
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 72/100
open-nudge/opentemplate#204 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
github-stale-ci-pr-closer: KV state is double-wrapped, never persists, and hits the depth-32 limitCó thể đã có người làm @VascoSch92 đã nhận hôm nay. Đang mởpriority:medium ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
OpenHands/extensions#781 ·
Maintainer thường phản hồi trong vòng 1 ngày