obs-ffmpeg: Fix Opus encoder bitrate and errors
Description
Fixes issue #12753 where the Opus encoder incorrectly allows bitrate selection up to 1024 kbps, causing confusing "Failed to open AAC codec" errors when values exceed FFmpeg libopus's 256 kbps per-channel limit.
Changes Made
- Added
opus_properties()function: Creates Opus-specific properties with correct bitrate range (64-256 kbps) - Fixed error messages: Changed hardcoded "AAC codec" to display actual codec name (
enc->type) - Updated
opus_encoder_info: Uses newopus_properties()instead of genericenc_properties()
Technical Details
- FFmpeg's libopus enforces a maximum of 256 kbps per channel
- The 256 kbps limit is more than sufficient (typical WebRTC usage is 30-90 kbps)
- Error message fix improves reporting for all FFmpeg audio encoders (AAC, ALAC, FLAC, etc.)
Testing
- Code follows OBS coding guidelines (kernel normal form, tabs for indentation)
- No trailing whitespace
- All lines under 120 columns
- Verified against existing code patterns
Related Issues
Closes #12753
Safety verification
Ran through the codebase to check for potential compatibility issues:
Backward compatibility with old configs
If someone has bitrate=320 in their config, OBS won't crash. The frontend already has FindClosestAvailableSimpleOpusBitrate() that clamps out-of-range values. A config with 320 kbps will just get downgraded to 256.
See: audio-encoders.cpp lines 326-348
Error message change
Changed "Failed to open AAC codec" to use the actual codec name. Checked if anything parses these errors - nothing does. They just get passed through to the UI for display via obs_encoder_get_last_error().
See: obs-output.c lines 2586, 2600
Other encoders
AAC uses the same enc_properties and correctly supports up to 1024 kbps. PCM/ALAC/FLAC also use it but they're lossless so the bitrate setting gets ignored anyway (line 217 sets bit_rate=0 for lossless codecs).
Edge cases checked
- Config with 320 kbps: clamps to 256
- Config with 128 kbps: works as-is
- Config with 32 kbps: clamps to 64 (minimum)
No breaking changes. Old configs handle gracefully.
Please split the changes into separate commits.
Split into two commits as requested:
- Fix hardcoded error message (affects all FFmpeg audio encoders)
- Fix Opus encoder bitrate limit (addresses #12753)
The error message fix is now separate since it benefits all codecs, not just Opus.
Do not use merge commits to keep up with master branch history. Use git rebase instead.