Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

RecorderIO: option to encode at a constant bit rate (and set the bit rate)

Đang mở
#7,737 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@ANDROIDHASSAN đang làm issue này rồi.

Từ ngày 11/10/2026.

  • #7740 của @ANDROIDHASSAN — đang mở

Đá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ả

enhancement
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:

  1. 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.
  2. 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: sets codec_context.bit_rate; None keeps the encoder default.
  • constant_bit_rate: bool = False: sets the Opus vbr=off option. True with bit_rate=128_000 matches 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 RecorderIO and overriding _encode_thread with 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 bitrate only and now conflicts with the rewritten module; without vbr=off it 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.duration with and without AVURLAssetPreferPreciseDurationAndTimingKey.
  • 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=...) / RecordingOptions as 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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của livekit/agents

Tất cả issue của livekit/agents

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.