jiixyj / loudness-scanner

A tool that scans your music files and tags them with loudness information.
MIT License
133 stars 23 forks source link

Support Opus files with .ogg extension #35

Open valpackett opened 5 years ago

valpackett commented 5 years ago

Looks like sndfile opens Ogg files and bails when it finds Opus instead of Vorbis inside.

found plugin input_sndfile
found plugin input_mpg123
found plugin input_musepack
found plugin input_ffmpeg
Error opening file 'track.ogg'

After removing input_sndfile.so from the plugin search path:

found plugin input_mpg123
found plugin input_musepack
found plugin input_ffmpeg
  Loudness
-13.3 LUFS, track.ogg

So it might make sense to try multiple plugins.

But then, looks like the tag writing also determines the codec by file extension :(

Many places (e.g. Android) only support the .ogg extension, so that should be supported. File extensions are not supposed to mean anything in unix anyway.


As a workaround, I have this script:

#!/usr/bin/env ruby
opusfiles = $*.map { |f| File.join(File.dirname(f), File.basename(f, '.*') + '.opus') }
opusfiles.each { |op| File.delete(op) if File.exist?(op) }
$*.zip(opusfiles).each { |og, op| puts [og, op].inspect; File.symlink(og, op) }
system 'loudness', 'tag', '-L', '--opus-vorbisgain-compat', *opusfiles
opusfiles.each { |op| File.delete(op) }