Skip to content

Add Opus encoding support#24

Merged
arkq merged 1 commit intomasterfrom
copilot/add-opus-encoding-support
Nov 6, 2025
Merged

Add Opus encoding support#24
arkq merged 1 commit intomasterfrom
copilot/add-opus-encoding-support

Conversation

Copy link

Copilot AI commented Nov 5, 2025

Adds Opus audio encoding as a new output format option alongside existing RAW, WAV, MP3, and OGG formats.

Implementation

  • New writer: writer-opus.{c,h} implements Opus encoding via libopus

    • Manually handles OGG muxing using libogg (similar to Vorbis writer)
    • Creates RFC 7845 compliant OpusHead and OpusTags headers
    • Supports 16-bit PCM input, configurable bitrate
    • Buffers PCM data to match 20ms Opus frame size requirements
  • Build system: Added ENABLE_OPUS CMake option requiring opus and ogg packages

  • Integration: Updated writer.{c,h} and main.c to register WRITER_TYPE_OPUS and handle -t opus flag

  • Tests: Added unit tests in tc-writer.c covering writer creation and encoding

Usage

# Build with Opus support
cmake .. -DENABLE_OPUS=ON

# Record with Opus encoding
svar -t opus output-template

Error messages now correctly list available formats:

error: Unknown output file type {raw, wav, rf64, ogg, opus}: unknown

[!WARNING]

Original prompt

This section details on the original issue you should resolve

<filter_complete></filter_complete>

<issue_title>support opus</issue_title>
<issue_description>I noticed encoding in VORBIS is possible, but the newer and better algorithm OPUS would be also nice to have.

BTW the output filetype says wav twice in its help message:

error: Unknown output file type {raw, mp3, wav, wav, ogg}: opus

Thanks for the SW.
Cheers!</issue_description>

Comments on the Issue (you are @copilot in this section)

@arkq > BTW the output filetype says wav twice in its help message

Thanks for reporting that, I've pushed the fix into the master.</comment_new>

Original prompt

This section details on the original issue you should resolve

<issue_title>support opus</issue_title>
<issue_description>I noticed encoding in VORBIS is possible, but the newer and better algorithm OPUS would be also nice to have.

BTW the output filetype says wav twice in its help message:

error: Unknown output file type {raw, mp3, wav, wav, ogg}: opus

Thanks for the SW.
Cheers!</issue_description>

Comments on the Issue (you are @copilot in this section)

@arkq > BTW the output filetype says wav twice in its help message

Thanks for reporting that, I've pushed the fix into the master.</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI assigned Copilot and arkq Nov 5, 2025
Copilot AI changed the title [WIP] Add support for OPUS encoding in output Add Opus encoding support Nov 5, 2025
Copilot AI requested a review from arkq November 5, 2025 21:28
@arkq
Copy link
Owner

arkq commented Nov 6, 2025

@copilot use libopus-dev (/usr/include/opus/opus.h) instead of libopusenc-dev

Copy link
Author

Copilot AI commented Nov 6, 2025

@copilot use libopus-dev (/usr/include/opus/opus.h) instead of libopusenc-dev

Done! Rewrote the Opus writer to use libopus (/usr/include/opus/opus.h) instead of libopusenc. The implementation now manually handles OGG muxing using libogg, following RFC 7845 for Opus encapsulation in OGG containers. See commit 4bd45bf.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@arkq arkq force-pushed the copilot/add-opus-encoding-support branch from 4bd45bf to b030962 Compare November 6, 2025 20:24
@arkq arkq force-pushed the copilot/add-opus-encoding-support branch from b030962 to 39b1eb6 Compare November 6, 2025 20:29
@arkq arkq merged commit 39b1eb6 into master Nov 6, 2025
11 checks passed
@arkq arkq deleted the copilot/add-opus-encoding-support branch November 6, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support opus

2 participants