HydrogenAudio

Lossy Audio Compression => Opus => Topic started by: Pierre22 on 2018-05-28 10:46:26

Title: How to determine whether Opus file is VBR or CBR
Post by: Pierre22 on 2018-05-28 10:46:26
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.
Title: Re: How to determine whether Opus file is VBR or CBR
Post by: lithopsian on 2018-05-28 13:22:18
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.
Title: Re: How to determine whether Opus file is VBR or CBR
Post by: Pierre22 on 2018-05-28 13:49:25
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?
Title: Re: How to determine whether Opus file is VBR or CBR
Post by: AiZ on 2018-05-28 21:35:29
Hello,

If you don't mind the hassle, as you seem to like ffmpeg :
MP3 - Tech / EncSpot accuracy and alternatives? (https://hydrogenaud.io/index.php/topic,98284.msg900540.html#msg900540)

Happy transcoding,

    AiZ
Title: Re: How to determine whether Opus file is VBR or CBR
Post by: 2012 on 2018-05-28 21:52:19
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
Title: Re: How to determine whether Opus file is VBR or CBR
Post by: Pierre22 on 2018-05-28 22:41:51
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 !
Title: Re: How to determine whether Opus file is VBR or CBR
Post by: AiZ on 2018-05-28 23:00:00
I'm using Windows too, you'll find gnuplot Windows binaries in the SourceForge repository.
Title: Re: How to determine whether Opus file is VBR or CBR
Post by: Pierre22 on 2018-05-29 10:13:47
Ok thanks, I'll give it a try.
Title: Re: How to determine whether Opus file is VBR or CBR
Post by: 2012 on 2018-05-29 13:10:33
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.
Title: Re: How to determine whether Opus file is VBR or CBR
Post by: Pierre22 on 2018-05-29 14:49:16
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 (https://hydrogenaud.io/index.php/topic,116040) 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...