FFmpeg - Encode Vorbis: Difference between revisions
Created page with "Category:FFmpeg Category:Vorbis <pre> ffmpeg -i <input.file> -a:c libvorbis -qscale:a 3 <output.file> </pre> "libvorbis" - Usable range ≥ 96 Kbps. Recommended range ≥ 192 Kbps.<br/> -qscale:a – audio quality. Range is -1.0 to 10.0, where 10.0 is highest quality. Default is -q:a 3 with a target of 112kbps. The formula 16×(q+4) is used below 4, 32×q is used below 8, and 64×(q-4) otherwise. Examples: 112=16×(3+<b>4</b>), 160=32×<b>5</b>, 192=32×<b>6</..." |
No edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:FFmpeg]] | [[Category:FFmpeg]] | ||
[[Category:Vorbis]] | [[Category:Vorbis]] | ||
This article explains how to encode audio using the '''libvorbis''' codec in FFmpeg. It includes the recommended command, quality settings, usable ranges, and how the Vorbis quality scale maps to approximate bitrates. | |||
== Overview == | |||
Vorbis is an open, patent‑free, lossy audio codec known for good quality at lower bitrates. FFmpeg supports Vorbis encoding through the '''libvorbis''' library. | |||
This article focuses on the **quality‑based variable bitrate (VBR)** mode, which is the recommended way to encode Vorbis audio. | |||
== Basic Encoding Command == | |||
Use the following FFmpeg command to encode an audio file to Vorbis: | |||
<pre> | <pre> | ||
ffmpeg -i <input.file> -a:c libvorbis -qscale:a 3 <output.file> | ffmpeg -i <input.file> -a:c libvorbis -qscale:a 3 <output.file> | ||
</pre> | </pre> | ||
-qscale:a | * `-a:c libvorbis` — Selects the Vorbis encoder. | ||
* `-qscale:a` (or `-q:a`) — Sets audio quality (VBR mode). | |||
== Quality Scale ( -qscale:a ) == | |||
Vorbis uses a **quality scale** instead of fixed bitrates. | |||
* **Range:** -1.0 to 10.0 | |||
* **Default:** `-q:a 3` | |||
* **Higher values = higher quality and higher bitrate** | |||
'''General guidance:''' | |||
* Usable range begins around **96 kbps** | |||
* Recommended range begins around **192 kbps** | |||
== Approximate Bitrate Formula == | |||
Vorbis does not use fixed bitrates, but the FFmpeg documentation and Vorbis encoder model provide approximate calculations. | |||
The encoder uses the following rules internally: | |||
* For `q < 4` | |||
→ **Bitrate ≈ 16 × (q + 4)** kbps | |||
* For `q < 8` | |||
→ **Bitrate ≈ 32 × q** kbps | |||
* For `q ≥ 8` | |||
→ **Bitrate ≈ 64 × (q − 4)** kbps | |||
=== Example Values === | |||
* **q=3 →** 16×(3+4) = **112 kbps** | |||
* **q=5 →** 32×5 = **160 kbps** | |||
* **q=6 →** 32×6 = **192 kbps** | |||
* **q=10 →** 64×(10−4) = **384 kbps** | |||
These values are approximations; actual bitrates vary slightly depending on content. | |||
== Recommended Settings == | |||
Most users will want: | |||
{| class="wikitable" | |||
! Use Case !! Recommended q !! Approx Bitrate | |||
|- | |||
| Voice recordings || 2–3 || ~96–112 kbps | |||
|- | |||
| General music || 4–5 || ~128–160 kbps | |||
|- | |||
| High‑quality music || 6 || ~192 kbps | |||
|- | |||
| Archival (lossy) || 8–10 || ~256–384 kbps | |||
|} | |||
Use `-q:a 6` as a safe high‑quality default for music. | |||
== Complete Example == | |||
Re‑encode an input file to Vorbis at quality 6: | |||
<pre> | |||
ffmpeg -i input.wav -c:a libvorbis -q:a 6 output.ogg | |||
</pre> | |||
== Notes == | |||
* Vorbis is intended for **VBR**, not CBR. | |||
* AAC and Opus tend to outperform Vorbis at low bitrates, but Vorbis remains excellent for music in the 160–192 kbps region. | |||
* For transparency, quality **q=5–6** is typically enough. | |||
== References == | |||
* https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio | |||
* https://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide | |||
Latest revision as of 15:54, 14 March 2026
This article explains how to encode audio using the libvorbis codec in FFmpeg. It includes the recommended command, quality settings, usable ranges, and how the Vorbis quality scale maps to approximate bitrates.
Overview
Vorbis is an open, patent‑free, lossy audio codec known for good quality at lower bitrates. FFmpeg supports Vorbis encoding through the libvorbis library. This article focuses on the **quality‑based variable bitrate (VBR)** mode, which is the recommended way to encode Vorbis audio.
Basic Encoding Command
Use the following FFmpeg command to encode an audio file to Vorbis:
ffmpeg -i <input.file> -a:c libvorbis -qscale:a 3 <output.file>
- `-a:c libvorbis` — Selects the Vorbis encoder.
- `-qscale:a` (or `-q:a`) — Sets audio quality (VBR mode).
Quality Scale ( -qscale:a )
Vorbis uses a **quality scale** instead of fixed bitrates.
- **Range:** -1.0 to 10.0
- **Default:** `-q:a 3`
- **Higher values = higher quality and higher bitrate**
General guidance:
- Usable range begins around **96 kbps**
- Recommended range begins around **192 kbps**
Approximate Bitrate Formula
Vorbis does not use fixed bitrates, but the FFmpeg documentation and Vorbis encoder model provide approximate calculations.
The encoder uses the following rules internally:
- For `q < 4`
→ **Bitrate ≈ 16 × (q + 4)** kbps
- For `q < 8`
→ **Bitrate ≈ 32 × q** kbps
- For `q ≥ 8`
→ **Bitrate ≈ 64 × (q − 4)** kbps
Example Values
- **q=3 →** 16×(3+4) = **112 kbps**
- **q=5 →** 32×5 = **160 kbps**
- **q=6 →** 32×6 = **192 kbps**
- **q=10 →** 64×(10−4) = **384 kbps**
These values are approximations; actual bitrates vary slightly depending on content.
Recommended Settings
Most users will want:
| Use Case | Recommended q | Approx Bitrate |
|---|---|---|
| Voice recordings | 2–3 | ~96–112 kbps |
| General music | 4–5 | ~128–160 kbps |
| High‑quality music | 6 | ~192 kbps |
| Archival (lossy) | 8–10 | ~256–384 kbps |
Use `-q:a 6` as a safe high‑quality default for music.
Complete Example
Re‑encode an input file to Vorbis at quality 6:
ffmpeg -i input.wav -c:a libvorbis -q:a 6 output.ogg
Notes
- Vorbis is intended for **VBR**, not CBR.
- AAC and Opus tend to outperform Vorbis at low bitrates, but Vorbis remains excellent for music in the 160–192 kbps region.
- For transparency, quality **q=5–6** is typically enough.