Coder Social home page Coder Social logo

OPUS file support about diffuse HOT 23 CLOSED

vyoln avatar vyoln commented on June 2, 2024 1
OPUS file support

from diffuse.

Comments (23)

icidasset avatar icidasset commented on June 2, 2024 2

Thanks, I’ll add it to the list of accepted file formats when I can find some time. If you do plan on making your own build of Diffuse you’ll also need to add the file extension here:

"\\.(mp3|mp4|m4a|flac|ogg|wav|webm)$"

from diffuse.

vyoln avatar vyoln commented on June 2, 2024 1

I don't understand what you mean by opening the same track in your browser (using Chrome), but I do see that the codec (OPUS) is supported by Chromium/Chrome here. I also saw that where the audio codecs are listed in this project, the OPUS codec is not listed (link). I am currently compiling a version which I am trying to get the OPUS format supported, and I will let you know once it is done.

Thanks again,
vyoln

from diffuse.

vyoln avatar vyoln commented on June 2, 2024 1

I tested this on Chrome and Firefox with a local WebDav server, and the playback works fully! (the metadata can sometimes get messed up, but that could be a file problem or it not being in a specific album)

Thanks,
vyoln

from diffuse.

vyoln avatar vyoln commented on June 2, 2024 1

I've now tested with my full music library (Amazon S3), and OPUS files work!

Thanks again,
vyoln

from diffuse.

vyoln avatar vyoln commented on June 2, 2024 1

Sure, here is an opus file to test with! https://www.dropbox.com/scl/fi/np2tjrhx1cr8dib9go6a2/KICK-BACK.opus?rlkey=i2jq3ed7rjphxc8sa9mfo8lmm&dl=0 (can't upload through github)

On the settings page, it says Built on Feb 9th 2024, 11:23:54, so I believe that it is the latest version.

Thanks,
vyoln

from diffuse.

vyoln avatar vyoln commented on June 2, 2024 1

Here is the same song with metadata for testing! https://www.dropbox.com/scl/fi/a96c3fr5m99cdeslsp3l6/KICK-BACK-with-metadata.opus?rlkey=gxaqo1khglapubcdzcblqfi8t&dl=0

Thanks,
vyoln

from diffuse.

Netherquark avatar Netherquark commented on June 2, 2024

As far as I'm aware, if your browser supports the codec/format diffuse can stream it. Please try opening the same track in your browser directly for playback.

from diffuse.

vyoln avatar vyoln commented on June 2, 2024

I have a follow-up question: is there anyway to use local files as the source (as my system is pretty slow and all sources are getting stuck at 5%)?

Thanks,
vyoln

from diffuse.

icidasset avatar icidasset commented on June 2, 2024

I have a follow-up question: is there anyway to use local files as the source (as my system is pretty slow and all sources are getting stuck at 5%)?

Thanks, vyoln

See #328

And yeah it can take a while to process the first time around.

from diffuse.

vyoln avatar vyoln commented on June 2, 2024

Thanks for your reply! It was much faster! I have an update on the support:

  • Files show up
  • Metadata works (title, art) (after one refresh of the sources)
  • Playing songs don't work

With that being said, I have one question. How do playing songs work in Diffuse/what files/libraries do the playing?

Thanks again,
vyoln

Edit: Tested out just playing the audio through an HTML file, it is not a browser problem. This is the code I used:

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <audio controls src="songname.opus">
    </body>
</html>

from diffuse.

vyoln avatar vyoln commented on June 2, 2024

Please ignore my last reply ^^

I've been researching, and I keep seeing that .opus is actually a mimetype of audio/ogg. Now, after I changed one song from ".opus" to ".ogg", it now works in Diffuse. So, my new problem is getting an opus file, and changing it into an ogg file in Diffuse natively. If you know how to do this that would be great, but for now I will try and mess around with "common.ts" and "Pick.elm" to do this.

Thanks,
vyoln

from diffuse.

icidasset avatar icidasset commented on June 2, 2024

It does seem like .opus is used as a file extension, so I can add it.

my new problem is getting an opus file, and changing it into an ogg file in Diffuse

Adding the .opus file extension to Pick.elm and common.ts is by far the easiest solution. If you'd instead replace the file extension then the syncing mechanism wouldn't work anymore.

from diffuse.

vyoln avatar vyoln commented on June 2, 2024

If that is the case, then the .opus files were showing up but not playing (from my other reply). Would you possibly know why it is like that or any hunches on why it is not playing?

Thanks again,
vyoln

from diffuse.

vyoln avatar vyoln commented on June 2, 2024

Please ignore my last reply again ^^

It now seems like the OPUS files are working. I don't know what I did but they now work and the metadata is still there.
I'm going to double check this, and then maybe issue a pull request with the updated code. I have one unrelated question, that is is there any way to view the songs individually versus using albums or artists (with their individual track images)?

Thanks,
vyoln

from diffuse.

vyoln avatar vyoln commented on June 2, 2024

I have more updates! It seems like OPUS file support is really unstable, as it only worked that one time and not anymore. I'm not sure what is wrong, as I hadn't changed any of the source code. I will keep looking into it in the time being, but for now OPUS files are basically not working.

Thanks,
vyoln

from diffuse.

vyoln avatar vyoln commented on June 2, 2024

I believe I have found the solution. I will list the code changes I have made to get OPUS support (it makes the OPUS file act like an OGG file but not change any extensions)

common.ts:

// ...

  switch (audioId) {
    case "mp3": return "mp3";
    case "mpeg": return "mp3";

    case "mp4a-latm": return "m4a";
    case "mp4": return "m4a";
    case "x-m4a": return "m4a";

    case "flac": return "flac";
    case "x-flac": return "flac";
    case "ogg": return "ogg";

    case "wav": return "wav";
    case "wave": return "wav";

    case "webm": return "webm";

    case "opus": return "ogg"; // Line added
  }
}

// ... (there is nothing changed after this)

Pick.elm:

-- ...

musicFileRegex : Regex.Regex
musicFileRegex =
    "\\.(mp3|mp4|m4a|flac|ogg|wav|webm|opus)$" -- "opus" added here
        |> Regex.fromStringWith { caseInsensitive = True, multiline = False }
        |> Maybe.withDefault Regex.never

Please test this on your own computer and see if they work, as I'm still not too sure if they 100% work.

Thanks again,
vyoln

from diffuse.

icidasset avatar icidasset commented on June 2, 2024

Thanks for all the notes.

How do playing songs work in Diffuse/what files/libraries do the playing?

It just uses the browser's <audio> element.
See https://github.com/icidasset/diffuse/blob/main/src/Javascript/audio-engine.ts#L81

So yeah it mostly depends on the browser I'd say.
There's always the small possibility that it's a server or Diffuse issue though, eg. Google Drive sometimes messes up mime types.

have one unrelated question, that is is there any way to view the songs individually versus using albums or artists (with their individual track images)?

There's no cover view for individual tracks at the moment, just the regular list view.

Please test this on your own computer and see if they work, as I'm still not too sure if they 100% work.

Will do at some point 👍 What browser and source type are you using? And is the playback now working better?

from diffuse.

icidasset avatar icidasset commented on June 2, 2024

Live on https://nightly.diffuse.sh/

from diffuse.

vyoln avatar vyoln commented on June 2, 2024

I tested this with my Amazon S3 bucket, and it was not working. After further inspection, I realized that line 51 in common.ts (case "opus": return "opus";) was supposed to be case "opus": return "ogg";. If you do this, then line 68 in common.ts (case "opus": return "audio/opus";) is also not necessary.

Thanks once again,
vyoln

from diffuse.

icidasset avatar icidasset commented on June 2, 2024

Thanks for testing this @vyoln !

I'm not entirely sure what the correct solution here is since the opus and ogg mime types are used interchangeably. But I'll do some more testing to make sure it works, including trying out your solution. Could you send me an opus file to test with? 🙏 Just to be sure I'm seeing the same results as you are. You can mail it to [email protected] if you don't want to link it here.

By the way, sorry if you already know this, but if you were testing on nightly.diffuse.sh, be sure to click the update button on the settings page and check the build timestamp to make sure you are on the latest version.

from diffuse.

icidasset avatar icidasset commented on June 2, 2024

Thanks! Found out what the issue is, apparently Chromium doesn't like it when you set the audio element type to audio/opus 🙈 The file you provided now gets scanned and played 👍 Although the scanning takes forever because I think it's missing the correct metadata.

from diffuse.

vyoln avatar vyoln commented on June 2, 2024

Thanks for your response! How do you think it could process faster and get the metadata?

Thanks again,
vyoln

from diffuse.

icidasset avatar icidasset commented on June 2, 2024

I should test with other opus files to be sure, but I think if the opus file had all the required metadata it should process faster. That's things like the track title, artist, album, track nr, etc. The file you sent me didn't have any of that.

from diffuse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.