1

I'm sort of new to FFmpeg, but I got much of the basics down. I am trying to understand how to encode audio with Opus. My knowledge is a bit weak when it comes to audio, bitrates, sample rate and Hz.

My MP4 input file (a music video) is encoded using AAC audio with the following FFprobe audio parameters:

[sample_rate] => 44100
[channels] => 2
[channel_layout] => stereo
[bit_rate] => 127999

I am using the following FFmpeg command to convert this MP4 file to WEBM:

ffmpeg -i input.mp4 -map 0:s? -map 0:v -map 0:a? -vf scale=-2:720 -movflags +faststart -c:v libvpx-vp9 -crf 32 -b:v 1024k -c:a libopus output.webm

When I run it the shell command, I get: the following warning:

[libopus @ 0x55ccad7dc440] No bit rate set. Defaulting to 96000 bps.

From what I understand, Opus is supposed to have variable bit rate (VBR) enabled by default, and that is supposed to detect and match the input audio bitrate. However, it seems that opus is not matching the original 127,999 bps.

Does this mean Opus is reducing the quality of the audio? The music in the output actually sounds good to me, but I have a hearing problem. From what I read, a lot of people can perceive differences in audio quality up to 256kbps bitrates, and these music videos are intended to be seen by an audience, not just myself. Music quality is of paramount importance for these.

I also do not want to set a constant bitrate of -b:a 256k, because the input may not be that high and this just wastes disk space trying to upscale. I'd like opus to -vbr in order to maximize the audio quality to at least as good as the original input quality! But if 96k is as high as Opus -vbr goes, that means we are losing out on lots of audio quality if the input has higher fidelity bitrate, right? I'm assuming higher bitrate on the input file is equivalent to higher audio quality?

Help me understand. What flags would you use in the FFmpeg command for Opus to maximize audio quality?

Giacomo1968
  • 58,727
peppy
  • 13

1 Answers1

0

The libopus encoder does not support quality-based encoding.

The default bitrate is based on channel count. You'll have to set some manual bitrate. It can go as high as 256k * # of channels. VBR is on by default and it means not all audio frames will be constrained to a fixed bitrate. It will hover around the target bitrate.

Gyan
  • 38,955