Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to determine whether Opus file is VBR or CBR (Read 6114 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to determine whether Opus file is VBR or CBR

I have downloaded a few audio tracks (no copyright) from Youtube in Opus format (using youtube-dl), but I do not know whether these are VBR or CBR encoded files. Mediainfo does not seem to give that info, nor does VLC (or it is somewhere a parameter that I do not interpret correctly).

Using opusinfo I get the following output:

Quote
Processing file "ts1.opus"...
New logical stream (#1, serial: e43e9edd): type opus
Encoded with Lavf56.40.101
User comments section follows...
        LANGUAGE=eng
        DURATION=00:04:01.601000000
        encoder=Lavf56.40.101
Opus stream 1:
        Pre-skip: 312
        Playback gain: 0 dB
        Channels: 2
        Original sample rate: 48000Hz
        Packet duration:   20.0ms (max),   20.0ms (avg),   20.0ms (min)
        Page duration:   1000.0ms (max),  998.3ms (avg),  600.0ms (min)
        Total data length: 3702647 bytes (overhead: 0.822%)
        Playback length: 4m:01.593s
        Average bitrate: 122.6 kb/s, w/o overhead: 121.6 kb/s
Logical stream 1 ended

Is it the variable "page duration" that indicates that it is a VBR encoding ?
Or does the constant "packet duration" indicates that it is a CBR encoding ?

If these variables have nothing to do with VBR vs. CBR, do you have any suggestions (tool) to find out ?
Thanks.

Re: How to determine whether Opus file is VBR or CBR

Reply #1
Neither of those.  If a file is encoded in true CBR mode (--hard-cbr in opusenc) then opusinfo will say it at the end of the average bitrate line.  Try it on a known CBR file and you'll see it, fairly obvious once you know.  In the other modes it says nothing, as in your example.

Re: How to determine whether Opus file is VBR or CBR

Reply #2
If a file is encoded in true CBR mode (--hard-cbr in opusenc) then opusinfo will say it at the end of the average bitrate line.

@lithopsian Thanks. And is this the case for all Opus encoders, or specific behavior for opusenc ?
The opusinfo output mentioned that the encoder is Lavf56.40.101 ?

So there is not "affirmative" information that can be gathered from the file to confirm VBR? It is just the omission of the CBR mention?


Re: How to determine whether Opus file is VBR or CBR

Reply #4
Quote
The opusinfo output mentioned that the encoder is Lavf56.40.101 ?

That's a comment added by ffmpeg. You shouldn't worry about it as ffmpeg is still using libopus for the actual encoding. An experimental ffmpeg-native encoder exists, but it's not used by default, and I don't think it supports CBR anyway.

You can test this with:
Code: [Select]
ffmpeg -i input.ext -vbr 0 -ab 128k output.opus

Re: How to determine whether Opus file is VBR or CBR

Reply #5
That's a comment added by ffmpeg.
Thanks for your help. But it was not me that encoded the opus file with ffmpeg, but it is a youtube download, so the comment will have been added by youtube (and I assume it is a reference to the encoder they used).

@AiZ
Thanks, but I am on a windows machine, and don't have the software available to use the graph data. But I understand that ffprobe can give more info to allow a view on bitrates. I will look a bit further into that. Thanks for the pointer in that direction !

Re: How to determine whether Opus file is VBR or CBR

Reply #6
I'm using Windows too, you'll find gnuplot Windows binaries in the SourceForge repository.

Re: How to determine whether Opus file is VBR or CBR

Reply #7
Ok thanks, I'll give it a try.

 

Re: How to determine whether Opus file is VBR or CBR

Reply #8
so the comment will have been added by youtube (and I assume it is a reference to the encoder they used).

No, it wasn't. The comment was added by the tool that probably invoked ffmpeg (or used the FFmpeg libraries) to convert the file format from webm to opus.

Code: [Select]
youtube-dl -f 251 <url_or_id>

Now you have a Matroska/WebM file with Opus audio. Use mkvinfo or mediainfo to view the metadata, and you will see that the application/library mentioned is "google/video-file", and there is no mention of Lavf.

Now, remux that file to opus file format using ffmpeg:
Code: [Select]
ffmpeg -i file.webm -c copy file.opus

Now check the metadata of the opus file, and you will see the comment mentioning Lavf.

This is the best case scenario of what could be happening at your end, downloading the the audio stream with the highest quality available, then remuxing it to opus format. Other possible scenarios may involve transcoding which is not what you want.

In case you didn't know. Lavf is short for libavformat, the FFmpeg library that provides muxers/demuxers for different file formats. Lavc is short for libavcodec, the library that provides encoders/decoders for different codecs.

And in case you're still wondering, YouTube uses libopus and VBR.

Re: How to determine whether Opus file is VBR or CBR

Reply #9
Code: [Select]
youtube-dl -f 251 <url_or_id>
Now you have a Matroska/WebM file with Opus audio. Use mkvinfo or mediainfo to view the metadata, and you will see that the application/library mentioned is "google/video-file", and there is no mention of Lavf.
Thanks for clarifying that; I did indeed use ffmpeg for copying the audio stream (without re-encoding) from mkv to opus, so I did not think that ffmpeg would change that comment field. And I actually do use exactly that youtube-dl command with -f 251 for my downloads.

Now, remux that file to opus file format using ffmpeg:
Code: [Select]
ffmpeg -i file.webm -c copy file.opus

[...] Other possible scenarios may involve transcoding which is not what you want. [...]

Well, I had planned to use the webm file directly for transcoding into MP3 or AAC (see this topic where I ask for some recommendations for settings). Any advice more than welcome !

And in case you're still wondering, YouTube uses libopus and VBR.

Thanks for confirming. So I can confidently download the 251 stream knowing that it is best quality you can get from youtube...