Naxesss / MapsetVerifier

A modding tool for osu!
93 stars 8 forks source link

Bitrate checking for ogg files is inconsistent with Spek and FFmpeg #20

Closed Ztumpie905509 closed 2 years ago

Ztumpie905509 commented 2 years ago

In MV it says the audio bitrate is 196kbps image

In Spek it says audio bitrate is 192kbps image

I converted the original flac file to ogg with this FFmpeg command: ffmpeg -i input.flac -map_metadata -1 -c:a libvorbis -b:a 192k audio.ogg

I assume that MV is wrong since 2 other apps says the ogg file is 192kbps.

My mapset for reference : https://osu.ppy.sh/beatmapsets/1706338#osu/3506931

Kyuunex commented 2 years ago

Could you try using the mediainfo utility on that ogg file and post the output.

Also normally, if you want an ogg, you should encode it with a preset instead of specifying a bitrate. Ogg preset 6 yields 192 kbps

Ztumpie905509 commented 2 years ago

This is the current audio file in the mapset

C:\Users\stump>ffprobe "E:\osu!\Songs\1706338 Assault Lily Last Bullet - Tsubomi no Naka no Kiseki\audio.ogg" -show_streams -show_format
ffprobe version N-102441-ge2301feabc Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10-win32 (GCC) 20210408
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
  libavutil      57.  0.100 / 57.  0.100
  libavcodec     59.  0.100 / 59.  0.100
  libavformat    59.  0.101 / 59.  0.101
  libavdevice    59.  0.100 / 59.  0.100
  libavfilter     8.  0.101 /  8.  0.101
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, ogg, from 'E:\osu!\Songs\1706338 Assault Lily Last Bullet - Tsubomi no Naka no Kiseki\audio.ogg':
  Duration: 00:04:32.33, start: 0.000000, bitrate: 196 kb/s
  Stream #0:0: Audio: vorbis, 48000 Hz, stereo, fltp, 192 kb/s
    Metadata:
      encoder         : Lavc59.0.100 libvorbis
[STREAM]
index=0
codec_name=vorbis
codec_long_name=Vorbis
profile=unknown
codec_type=audio
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=0
start_time=0.000000
duration_ts=13072000
duration=272.333333
bit_rate=192000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:encoder=Lavc59.0.100 libvorbis
[/STREAM]
[FORMAT]
filename=E:\osu!\Songs\1706338 Assault Lily Last Bullet - Tsubomi no Naka no Kiseki\audio.ogg
nb_streams=1
nb_programs=0
format_name=ogg
format_long_name=Ogg
start_time=0.000000
duration=272.333333
size=6681099
bit_rate=196262
probe_score=100
[/FORMAT]

The following one is another file generated by audacity ogg preset 6

C:\Users\stump>ffprobe "C:\Users\stump\Desktop\Desktop Folder\al_nc\output.ogg" -show_streams -show_format
ffprobe version N-102441-ge2301feabc Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10-win32 (GCC) 20210408
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
  libavutil      57.  0.100 / 57.  0.100
  libavcodec     59.  0.100 / 59.  0.100
  libavformat    59.  0.101 / 59.  0.101
  libavdevice    59.  0.100 / 59.  0.100
  libavfilter     8.  0.101 /  8.  0.101
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, ogg, from 'C:\Users\stump\Desktop\Desktop Folder\al_nc\output.ogg':
  Duration: 00:04:32.33, start: 0.000000, bitrate: 197 kb/s
  Stream #0:0: Audio: vorbis, 48000 Hz, stereo, fltp, 192 kb/s
    Metadata:
      DATE            : 2022
      ALBUM           : Neunt Praeludium (Last Bullet MIX) [限定盤]
      ARTIST          : 一柳隊、ヘルヴォル、グラン・エプレ
      TITLE           : 蕾の中の奇跡
      TOTALTRACKS     : 4
      GENRE           : Game
      track           : 2
[STREAM]
index=0
codec_name=vorbis
codec_long_name=Vorbis
profile=unknown
codec_type=audio
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=0
start_time=0.000000
duration_ts=13072000
duration=272.333333
bit_rate=192000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:DATE=2022
TAG:ALBUM=Neunt Praeludium (Last Bullet MIX) [限定盤]
TAG:ARTIST=一柳隊、ヘルヴォル、グラン・エプレ
TAG:TITLE=蕾の中の奇跡
TAG:TOTALTRACKS=4
TAG:GENRE=Game
TAG:track=2
[/STREAM]
[FORMAT]
filename=C:\Users\stump\Desktop\Desktop Folder\al_nc\output.ogg
nb_streams=1
nb_programs=0
format_name=ogg
format_long_name=Ogg
start_time=0.000000
duration=272.333333
size=6715296
bit_rate=197266
probe_score=100
[/FORMAT]

The audio stream for both of them is 192kbps, but for the format bitrate it is slightly larger than 192kbps. I guess MV is reading the format bitrate but not the audio stream bitrate so that this unexpected result was produced.

Naxesss commented 2 years ago

Spek uses ffmpeg/ffprobe, which approximates the bitrate of the audio stream based on its tags (you will never see anything other than 192 +- 32 * i there). In reality, OGG/Vorbis always produces an approximate of the target you input, so it giving e.g. 186 kbps or 197 kbps even if you specify 192 kbps or q6 is normal. Our testing giving bitrates lower than 192 kbps for some audio files shows that it isn't just the container doing it. See the Vorbis Spec:

The bitrate fields above are used only as hints. The nominal bitrate field especially may be considerably off in purely VBR streams.

So, because of being easier to measure and therefore enforce, we use the bitrate of the entire audio file. This also closer follows the intention of the rule, which is a filesize/length threshold. Hence the result you see in MV. Does that make sense?

Ztumpie905509 commented 2 years ago

Yes, thanks for the explanation, I guess I have to stick to mp3 instead then.