squentin / gmusicbrowser

jukebox for large collections of music
http://gmusicbrowser.org
GNU General Public License v3.0
196 stars 42 forks source link

Add opus support #77

Closed jplatte closed 4 years ago

jplatte commented 10 years ago

It would be nice to be able to play opus files. This should definitely be possible with #76 done, but may also be possible without it.

genebustam commented 8 years ago

I'd like to see this too

cbiere commented 8 years ago

I second this. Since there's been support for Opus in gstreamer and mplayer for years, I was quite surprised when I found out, that all my Opus files are being ignored.

nicolas-raoul commented 8 years ago

Apparently GStreamer support has been added about 2 years ago (#76).

But unfortunately gmusicbrowser still does not play Opus files (gmusicbrowser v1.1.14 on Ubuntu 2015.10)

Opus is the format used by youtube-dl -x (audio download from YouTube)

berarma commented 8 years ago

+1

RomanHargrave commented 8 years ago

mpv supports opus, so it's just a matter of modifying GMusicBrowser to include the files in the index.

cbiere commented 7 years ago

Switched to Clementine Music Player because of this.

RomanHargrave commented 7 years ago

Making some progress hacking on oggheader Tantalizing Progress Image

davidfoerster commented 7 years ago

@RomanHargrave libopus supports 44.1 kHz sampling rate? Or is that reading "work in progress"?

RomanHargrave commented 7 years ago

@davidfoerster It's the input encoding rate. The ID packet encodes data about what the encoder was fed. As for sample rate I am unsure. I suppose I should put it in a different info field.

RomanHargrave commented 7 years ago

@davidfoerster I wasn't thinking. I edited my comments before you, heh.

WRT backends, due to the way GMusicBrowser handles files, you only need to implement a tag/metadata parser for each format. The file itself is handed as-as to the decoder (mpv, gstreamer, etc). mpv and gstreamer should both work, since I know for fact they support opus.

RomanHargrave commented 7 years ago

One thing to note is that while it may seem that the length calculation brought over from ogg works, it doesn't quite - it's usually off by ten to twenty seconds.

RomanHargrave commented 7 years ago

Tags are read correctly now, I haven't touched writing yet.

davidfoerster commented 7 years ago

@RomanHargrave I'm surprised you can't reuse the code that parses and writes the Ogg container data and tags of Vorbis files.

RomanHargrave commented 7 years ago

I suppose I could. This was more the result of tinkering with things.

Already I can tell you that due to Perl 5's way of going about classes (and my not having read much about them), that if I include the Ogg parser, I don't know that much of the shared non-namespaced code will even be accessible.

RomanHargrave commented 7 years ago

@davidfoerster I've merged the common code.

davidfoerster commented 6 years ago

Is there any chance to add better replaygain support? At the moment the GStreamer decoder applies replaygain from the metadata (as it should) but GMB is unaware of it and thus applies the configured fall-back gain regardless.

I'm attaching a sample file in Opus and Vorbis format (both from the CC-licensed Machina II by the Smashing Pumpkins and thus legal to redistribute).

RomanHargrave commented 6 years ago

@davidfoerster the issue is with missing RG support in non-gstreamer backends? or the issue is with improper RG support in the Opus tag parser?

davidfoerster commented 6 years ago

@RomanHargrave I'd say the issue is in the tag parser, not in GStreamer. The latter appears to do what it's supposed to (apply replay gain according to file metadata) while GMB applies the fall-back gain meant for files without replay gain info on top the replay gain that GStreamer applies.

I should mention that GMB displays empty replay gain entries for Opus files in the file properties dialogue even though opusinfo shows replay gain data for the same file(s).

RomanHargrave commented 6 years ago

i'll need to explore the RG implementation in GMB core for that. my backend is MPV (I use jack and have a large collection of different file types, GStreamer is simply out of the question for me). I'll have to investigate a few things:

  1. Does RG even work correctly for MPV - if not, fix it

  2. Where/why RG problems happen with Opus

davidfoerster commented 6 years ago

I'd investigate the MPV back-end too if I knew which Perl bindings or other (Ubuntu) packages I need to install to enable the MPV option in the audio back-end settings of GMB. The mpv package suggested by the gmusicbrowser package didn't do it. Any suggestions?

My best guess is still that GMB's Opus tag parser is simply unaware of the replay gain data and I'd assume that it works independently of the audio back-end.

RomanHargrave commented 6 years ago

The MPV backend appears to have working RG. You do not need any special modules installed - all RPCs are done internally. The backend itself uses JSON::PP, Time::HiRes and IO::Socket::Unix which are all most certainly going to be present in the first place.

davidfoerster commented 6 years ago

I lacked the JSON:PP module and installed it now. The others are part of the Perl base installation. The MPV option in GMB is still unselectable.

RomanHargrave commented 6 years ago
sub check_version
{   return unless $mpv;
    my $output= qx/$mpv -V/;
    my ($ok,$version);
    if ($output=~m/mpv\s*(\d+)\.(\d+)(\S+)?/i) { $ok= $1>0 || $2>=7; $version= "$1.$2".($3||"") } #requires version 0.7 or later
    elsif ($output=~m/mpv\s*(git-[[:xdigit:]]+)/i) { $ok=1; $version=$1; } #assume git version is ok
    else { warn "mpv: error looking up mpv version\n"; }
    warn "mpv: found mpv version $version\n" if $version && ($::debug || !$ok);
    if (!$ok) { warn "mpv version earlier than 0.7 are not supported -> mpv backend disabled\n" }
    return $ok;
}

do you have ≥0.7?

RomanHargrave commented 6 years ago

@davidfoerster I've just performed EBU loudness measurements of the same track played in MPV by GMB, first in ogg, then opus.

RG mode is set to album, and the two files have identical RG tags.

OGG Measurement:

Ogg

Spectrum w/ Peaks:

OGG Spectrum

Screencap of OGG file properties

Opus Measurement:

Opus

Spectrum w/ Peaks:

Opus Spectrum

Screencap of Opus file properties

Comparing the two spectrums, it would appear that any visible difference in volume between these during playback is within an error margin.

Deviation

Capture Setup:

Capture Setup

The above observations lead me to wonder if this is an issue somewhere else, as the actual tag format parsing and loading is done inside oggheader.pm even for opus files. All that opusheader.pm does is extract the raw OGGTag data from the opus file. So as far as GMB is concerned the RG data is identical at playback time, even if it may ultimately be up to GStreamer or MPV to ultimately handle the gain adjustment.

davidfoerster commented 6 years ago

What's the fall-back gain in your GMP configuration? I set mine to -9.0 dB. If I set it to 0 both files are played back at the same volume (which is consistent with my earlier problem description).

On another note I have an old MPV version and can't install or even build a newer version trivially. I'll try again tomorrow or whenever I find time.

RomanHargrave commented 6 years ago

FBG is 0.0dB but swapping between album/track mode causes noticeable changes for both formats.

MPV invocation is

/usr/bin/mpv --input-unix-socket=/home/roman/.config/gmusicbrowser/gmb_mpv_sock --idle --no-video --no-input-terminal --really-quiet --gapless-audio=weak --softvol-max=100 --mute=no --no-sub-auto --volume=55 --af-add=@RG:volume=0:replaygain-album=yes:replaygain-clip=yes:replaygain-preamp=1 --replaygain album --af=channels=2 --ao jack --jack-name GMusicBrowser

I'll have to start it manually and see if can catch GMB changing to fallback gain, though I doubt it.

RomanHargrave commented 6 years ago

On a more pressing note, I've noticed that GMB is writing bad tag headers for certain opus files. This certainly warrants a more critical investigation than potential RG issues.

mrlee14 commented 5 years ago

Switched to Clementine Music Player because of this.

Me too then dumped for Amarok and now I want to go back to gmusicbrowser since all sucks...the biggest sucker was exile... (hahaha)

squentin commented 4 years ago

Better late than never I guess. It's fixed in both branches: master (gtk3) and v1.1.x (gtk2) Please report any problems you encounter with opus files.