rsgain icon indicating copy to clipboard operation
rsgain copied to clipboard

Option to skip scanning opus files with existing headers output gain

Open Tokariew opened this issue 1 year ago • 2 comments

Currently if someone use opus in mode a or t opus file will be scanned in each subsequent run after the first even when used with -S output. Can we get some option to skip opus files with existing gain headers? Tested with:

➜ rsgain --version
rsgain 3.5.1 - using:
   libebur128     1.2.6
   libavformat    60.16.100
   libavcodec     60.31.102
   libavutil      58.29.100
   libswresample  4.12.100

Built with:
   TagLib         1.12

Compiler:         GCC 14.1
Build Date:       2024-06-08

Tokariew avatar Sep 24 '24 20:09 Tokariew

That's an interesting idea that I hadn't considered before. I suppose the downside of skipping files with an existing header gain is that it could have a 'false positive'. The header gain set by another program may not actually correspond to ReplayGain; it could have been set for some other purpose.

Then again, I would expect new users to scan their entire library when using rsgain for the first time. So, the 'false positive' issue may not actually be a significant problem at all.

I will have to give this some further thought.

complexlogic avatar Sep 25 '24 01:09 complexlogic

I was using r128gain in my podcast dowload and gain normalization and was thinking to switching to rsgain for it.

so i tested with firstly full run, and then hoping that -S option will provide option to skip scanned. Not sure if it should be in existing -S option as header gain is not ReplaGain info. And if it should work only in a or t mode for opus or for all modes

Tokariew avatar Sep 27 '24 19:09 Tokariew

This would be a really great feature to have. I have written a script to "compile" my lossless music collection to Opus which runs rsgain at the end, and it really is quite a bother to have it rescan the entire collection every time I add a single album.

My two cents is this could be implemented in two new Opus modes, as and ts, that in addition to writing album/track gain to the header also skips files with header gain set when using -S. Otherwise you could also add a new command line flag, like --skip-existing-opus-gain, or maybe the behaviour could be triggered by specifying the -S flag twice, by the same logic some programs become even more verbose when run with -vv.

lolomokakus avatar May 23 '25 21:05 lolomokakus

This feature request is now implemented in master. There's no special mode to enable it. If you pass -S, and the file is an Opus file, it will be skipped if the header gain is non-zero.

As I mentioned above, I expect that users will do a full library scan if they use rsgain for the first time, or if they change their settings. So this new behavior should not cause any false positive skips when the program is being used as intended.

complexlogic avatar May 29 '25 13:05 complexlogic

Thank you so much! I've tested the change and it seems to work great.

I did run into some weirdness though, I had one album that kept being rescanned despite the -S flag. After some examination I realised I was using Opus mode a and by chance the album averaged out at a gain value of exactly 0, which rsgain of course can't distinguish from an unscanned file. I'm not sure situations like that are going to come up often, but it might be a good idea to document it somewhere.

lolomokakus avatar May 30 '25 05:05 lolomokakus