Sandakan / Nora

An elegant music player built using Electron and React. Inspired from Oto Music for Android by Piyush Mamidwar.
https://noramusic.netlify.app
MIT License
436 stars 15 forks source link

OPUS Support (Feature Request for Nora) #242

Closed HelveticAlex closed 1 month ago

HelveticAlex commented 3 months ago

Is your feature request related to a problem? Please describe. As .OPUS is becoming increasingly relevant and serves as a direct replacement for .MP3, its absence limits the usability of the platform for users who prefer or require .OPUS for its superior efficiency and quality.

Describe the solution you'd like I would like Nora to implement support for the .OPUS audio codec..

Describe alternatives you've considered An alternative solution could be continuing to convert .OPUS files to other supported formats like .MP3 or .AAC, but this results in a loss of quality and/or increased file sizes, which is not ideal. Native .OPUS support would be a much more efficient and quality-preserving option.

Additional context Adding .OPUS support could also align Nora with modern audio standards and practices, as more devices and platforms are beginning to adopt .OPUS due to its advantages over other audio formats. This enhancement would not only improve functionality but also future-proof the platform as media standards evolve.

Sandakan commented 3 months ago

@HelveticAlex, I have tried to enable support for other codecs on Nora.

But the main problem is that chromium only comes with a handful of audio codecs to work with and I have no idea how to integrate more codecs to it.

HelveticAlex commented 3 months ago

Chromium should support Opus (and Vorbis). They themselves popularized this audio codec. Now as for the implementation, unfortunately I don't know either... but I do know that it's possible given that it's "built-in"!

https://www.chromium.org/audio-video/

Since it's an electron-based app, it should even have opus enabled by default.

<audio controls>
    <source src="path_to_audio_file.ogg" type="audio/ogg; codecs=opus">
    Your browser does not support the audio element.
</audio>

For Advanced Processing, like using an EQ or something, the Web Audio API should be enough. Opus uses "AudioContext" to decode it's thing.

async function playOpusAudio(audioUrl: string) {
    const audioContext = new AudioContext();
    const response = await fetch(audioUrl);
    const arrayBuffer = await response.arrayBuffer();
    const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);

    const source = audioContext.createBufferSource();
    source.buffer = audioBuffer;
    source.connect(audioContext.destination);
    source.start();
}

^

((Example in TypeScript, DO NOT COPY, it probably won't work with the structure of this app))

Sandakan commented 3 months ago

@HelveticAlex, It does work. But it won't support metadata editing because the package I'm using only supports mp3.

HelveticAlex commented 3 months ago

Mhmm, what about https://www.npmjs.com/package/music-metadata-browser ?

It requires a little more work, but given the number of metadata supported, it could be incredible for Nora !

Sandakan commented 3 months ago

Mhmm, what about https://www.npmjs.com/package/music-metadata-browser ?

It requires a little more work, but given the number of metadata supported, it could be incredible for Nora !

I'm already using its nodejs implementation and it only supports reading metadata.

HelveticAlex commented 3 months ago

Until finding a solution for editing the metadata, simply implementing the codec is enough (at least for my case) (and if I need to change the metadata of any files, I'll just do it with Mp3tag).

It would be a pleasure to deliver this patch as soon as possible (or the next one) !

stale[bot] commented 1 month ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.