desbma / r128gain

Fast audio loudness scanner & tagger (ReplayGain v2 / R128)
GNU Lesser General Public License v2.1
172 stars 9 forks source link

existing tags not found #19

Closed hboetes closed 4 years ago

hboetes commented 4 years ago

As a first test I checked if a tagged file was properly detected. It was not and ended up with these tags:

% metaflac --export-tags-to=- *1* | grep REPLAY
REPLAYGAIN_ALGORITHM=BS.1770
REPLAYGAIN_REFERENCE_LOUDNESS=-23.0 LUFS
REPLAYGAIN_ALBUM_GAIN=-14.2 LU
REPLAYGAIN_TRACK_GAIN=-9.80 dB
REPLAYGAIN_TRACK_PEAK=0.99835200
REPLAYGAIN_ALGORITHM=BS.1770
REPLAYGAIN_REFERENCE_LOUDNESS=-23.0 LUFS
REPLAYGAIN_ALBUM_GAIN=-14.2 LU
REPLAYGAIN_TRACK_GAIN=-9.00 dB
REPLAYGAIN_TRACK_PEAK=0.99765000
REPLAYGAIN_ALGORITHM=BS.1770
REPLAYGAIN_REFERENCE_LOUDNESS=-23.0 LUFS
REPLAYGAIN_ALBUM_GAIN=-14.2 LU
REPLAYGAIN_TRACK_GAIN=-5.00 dB
REPLAYGAIN_TRACK_PEAK=0.99475100

After removing all tags with metaflac --remove-tag='REPLAYGAIN_ALBUM_GAIN' --remove-tag='REPLAYGAIN_TRACK_PEAK' --remove-tag='REPLAYGAIN_ALGORITHM' --remove-tag='REPLAYGAIN_TRACK_GAIN' --remove-tag='REPLAYGAIN_REFERENCE_LOUDNESS' *flac and tagging again I got

metaflac --export-tags-to=- *2* |grep REPLAY
REPLAYGAIN_TRACK_GAIN=-10.50 dB
REPLAYGAIN_TRACK_PEAK=0.99630700
REPLAYGAIN_ALBUM_GAIN=-9.20 dB
REPLAYGAIN_ALBUM_PEAK=0.99996900

Looks like the existing tag detection is not entirely perfect.

desbma commented 4 years ago

Can you upload such file somewhere, so I can look at it ?

hboetes commented 4 years ago

Sure, and it's easy to reproduce: $ wget https://ia800300.us.archive.org/3/items/cj2009-10-05.ku100_at37/cj2009-10-05d01t02.ku100_at37.flac $ bs1770gain --overwrite cj2009-10-05d01t02.ku100_at37.flac $ r128gain -a -s cj2009-10-05d01t02.ku100_at37.flac $ metaflac --export-tags-to=- cj2009* |grep REPLAY REPLAYGAIN_ALGORITHM=BS.1770 REPLAYGAIN_REFERENCE_LOUDNESS=-23.0 LUFS REPLAYGAIN_TRACK_GAIN=7.30 dB REPLAYGAIN_TRACK_PEAK=0.55001800 REPLAYGAIN_ALBUM_GAIN=7.30 dB REPLAYGAIN_ALBUM_PEAK=0.55001800

cj2009-10-05d01t02.ku100_at37.flac https://drive.google.com/file/d/18KW68xtGkjhrevVNdN6vxstv13JBu3qg/view?usp=drive_web

On Fri, Jun 19, 2020 at 9:19 AM desbma notifications@github.com wrote:

Can you upload such file somewhere, so I can look at it ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/desbma/r128gain/issues/19#issuecomment-646480724, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARN5KKAOM7KVTWSYSRL36LRXMGO3ANCNFSM4OCO5S6A .

desbma commented 4 years ago

I can't access that file on Google Drive without login.

Looking at the bs1770gain code, they seem to take some liberties with the replaygain standard so they probably write tags incompatible with the rest of the world.

But I'd need a track file to confirm that.

hboetes commented 4 years ago

OK, I found a smaller file, which I can attach sample.zip

desbma commented 4 years ago
$ r128gain -s -v debug think-stereo-48000.flac
2020-06-21 17:26:30,996 MainThread: Detected FFmpeg lib versions: libavutil: 56.31.100, libavcodec: 58.54.100, libavformat: 58.29.100, libavdevice: 58.8.100, libavfilter: 7.57.100, libavresample: 4.0.0, libswscale: 5.5.100, libswresample: 3.5.100, libpostproc: 55.5.100
2020-06-21 17:26:31,052 MainThread: File 'think-stereo-48000.flac' already has a track gain tag, skipping track gain scan
2020-06-21 17:26:31,054 MainThread: File 'think-stereo-48000.flac': loudness = SKIPPED, sample peak = SKIPPED
$ r128gain -a -s -v debug think-stereo-48000.flac
2020-06-21 17:27:11,108 MainThread: Detected FFmpeg lib versions: libavutil: 56.31.100, libavcodec: 58.54.100, libavformat: 58.29.100, libavdevice: 58.8.100, libavfilter: 7.57.100, libavresample: 4.0.0, libswscale: 5.5.100, libswresample: 3.5.100, libpostproc: 55.5.100
2020-06-21 17:27:11,164 MainThread: All files already have an album gain tag, skipping album gain scan
2020-06-21 17:27:11,165 MainThread: File 'think-stereo-48000.flac' already has a track gain tag, skipping track gain scan
2020-06-21 17:27:11,166 MainThread: File 'think-stereo-48000.flac': loudness = SKIPPED, sample peak = SKIPPED

The tags are properly detected, which version of r128gain are you using, and how did you install it?

hboetes commented 4 years ago

r128gain v1.0.2. Scan audio files and tag them with ReplayGain/R128 loudness

So to reproduce, this is a wav file from firefox repository, encoded to flac and then bs1770gain --overwrite to tag it. After that I ran:

% r128gain -s -v debug think-stereo-48000.flac
2020-06-21 20:11:35,443 MainThread: Detected FFmpeg lib versions: libavutil: 56.31.100, libavcodec: 58.54.100, libavformat: 58.29.100, libavdevice: 58.8.100, libavfilter: 7.5
7.100, libavresample: 4.0.0, libswscale: 5.5.100, libswresample: 3.5.100, libpostproc: 55.5.100
2020-06-21 20:11:35,543 ThreadPoolExecutor-0_0: Analyzing loudness of file 'think-stereo-48000.flac'...                                                                       
2020-06-21 20:11:35,605 ThreadPoolExecutor-0_0: /usr/local/bin/ffmpeg -i think-stereo-48000.flac -filter_complex [0:a]asplit=2:outputs=2[s0][s1];[s0]aformat=channel_layouts=s
tereo:sample_fmts=s16[s2];[s2]replaygain[s3];[s1]aformat=channel_layouts=stereo:sample_fmts=s16:sample_rates=48000[s4];[s4]afifo[s5];[s5]ebur128=framelog=verbose[s6] -map [s3
] -map [s6] -f null /dev/null -hide_banner -nostats
2020-06-21 20:11:35,735 MainThread: File 'think-stereo-48000.flac': loudness = -20.5 LUFS, sample peak = -3.7 dBFS                                                            
2020-06-21 20:11:35,735 MainThread: Tagging file 'think-stereo-48000.flac'

Next time I run it I get:

% r128gain -s -v debug think-stereo-48000.flac
2020-06-21 20:18:09,117 MainThread: Detected FFmpeg lib versions: libavutil: 56.31.100, libavcodec: 58.54.100, libavformat: 58.29.100, libavdevice: 58.8.100, libavfilter: 7.5
7.100, libavresample: 4.0.0, libswscale: 5.5.100, libswresample: 3.5.100, libpostproc: 55.5.100
2020-06-21 20:18:09,273 MainThread: File 'think-stereo-48000.flac' already has a track gain tag, skipping track gain scan                                                     
2020-06-21 20:18:09,280 MainThread: File 'think-stereo-48000.flac': loudness = SKIPPED, sample peak = SKIPPED                                                                 

So this time I attached the file only tagged with bs1770gain. sample.zip

I compiled it with my own package manager, straight from git.

# Description: replaygain tagger

name=r128gain
version=git
release=1.0.2
branch=master
source="https://github.com/desbma/r128gain.git"

build()
{
    cd $name
    python3 setup.py install --root $PKG
}
desbma commented 4 years ago

The file is missing the REPLAYGAIN_TRACK_PEAK / REPLAYGAIN_ALBUM_PEAK mandatory tags.

If interoperability is one of your concerns, I advise you not to use bs1770gain. It writes tag with different conventions than what players understand, and violates several parts (at least 3, and I didn't look very deep) of the RG specification.

hboetes commented 4 years ago

OK, thanks for the detailed explanation. I'm trying to get rid of bs1770gain in an orderly fashion.