Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#7,737 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@ANDROIDHASSAN がすでに取り組んでいます。

2026年10月11日 から。

  • #7740 @ANDROIDHASSAN による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Python
スター
14.6k
フォーク
3.9k
平均マージ
3日 1時間
マージ済み PR(30日)
173

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

livekit/agents のほかの issue

livekit/agents の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。