Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to play OGG Opus on mobile devices #58

Closed
seabrus opened this issue Sep 26, 2016 · 9 comments
Closed

A way to play OGG Opus on mobile devices #58

seabrus opened this issue Sep 26, 2016 · 9 comments

Comments

@seabrus
Copy link

seabrus commented Sep 26, 2016

Hello Chris,

This is a question.

First of all, thank you very much for your package. It's really great and helpful, in particular, because it converts the output to the OGG format which is very compact. Also, your package is fast and reliable.

I've analyzed some of the most popular packages for sound recording and found that yours is one of the best or even the best one. Now I'm developing an app that is based on your package. But recently I've understood that some of potential users of my app will visit it via mobile devices and mobile browsers.

According to this list OGG Opus is supported by mobile browsers very weak. So, I need to provide such users with audio files in some other format than OGG Opus.

I've analyzed the issue #28. The approach described there is interesting but wav files are relatively large in comparision with OGG files and require much more traffic. There could be another way to solve the problem, namely, to convert OGG to the mp3 format (which has great support on the mobile devices) on the server. Now I'm considering converting all recorded OGG files into mp3 on the server using the ffmpeg library. As a result, I'll store only mp3 files in the DB.

But before to implement this approach I've decided to ask your opinion. What do you think about this way? Maybe, there are other approaches that are more efficient?

Thank you in advance.

By the way, I've considered a client-side converting OGG to mp3 but tests indicated that this process is very long and requires too much resources to be done. So I gave up that idea.

@chris-rudmin
Copy link
Owner

@seabrus I started this project initially because I wanted a web audio that was free in the monetary sense. I'm not sure you are aware, but using mp3 encoders and decoders requires a usage license (which is not cheap BTW).

If you take a look at the decoder example, you can see how to convert ogg/opus to a riff/wav format on the client which can be used in a normal audio tag. I never tried the decoder in a mobile browser so i can't say how fast it will be.

Let me know what route you take and how it works out!

@seabrus
Copy link
Author

seabrus commented Sep 26, 2016

@chris-rudmin thanks for the prompt response. Yes, I know about the mp3 license problem. But it looks like the situation has been changing and even in the USA mp3 will be free soon. I'm from the EU and most of my potential users are from the Europe too.

That said, I'll take a look at the example you mentioned.
One more idea is to convert to OGG Vorbis. No support from Safari, but Google's browsers support it.

@seabrus
Copy link
Author

seabrus commented Sep 26, 2016

AAC in a mp4 container (*.m4a) - it looks like this is the answer.
Sizes:

  • test.oga -- 313 kB (opus)
  • test.mp3 -- 387 kB
  • test.m4a -- 431 kB
  • test.wav -- 4600 kB (4.6 MB)

@chris-rudmin
Copy link
Owner

Cool. A note about the file size, if you do client side decoding of opus, the data transferred will be that of the test.oga file but will consume 4.6MB of memory on the device.

@seabrus
Copy link
Author

seabrus commented Sep 27, 2016

Hi,

1). WAV.
My app typically works with records of about 10 - 25 MB in size (OGG format) - it is about 0.5 - 1 hour of recording. These are mono records (mainly speech). Your package copes with that recording absolutely great because it is the smallest size I could achieve.

But if I convert these files into WAV (even on the client only) it will be 12 times larger, i.e., about 120 - 250 MB. Taking into accout that a typical page in my app contains several records it may be quite problematic to use this approach on the mobile devices (that said, tests should be done to check that exactly).

2). That is why I try to find another way to solve the problem. The M4A/AAC format looks as a very promising solution. It is license free. It is quite compact. So my question is: Is it possible to develop a version of your package which will convert files to this fotmat (not to the OGG Opus) on the client? I mean that everything is the same like it is now but the package produces a M4A file/blob as a result?
Such a version will be much more universal from the point of view of browsers coverage.

Have a nice day

@chris-rudmin
Copy link
Owner

@seabrus Distributing AAC files doesn't require a license but writing a decoder/encoder would require a license: https://en.wikipedia.org/wiki/Advanced_Audio_Coding#Licensing_and_patents. You might be able to compile an open source codec to javascript. Good luck!

@seabrus
Copy link
Author

seabrus commented Oct 4, 2016

@chris-rudmin I see "There is no happiness in life" :)

@chris-rudmin
Copy link
Owner

@seabrus You might be able to create a ring buffer (Web Audio Node) that loops for playback and decode just the necessary chunks into raw PCM as required. This way you don't decode all at once and don't explode the page memory as well.

@chris-rudmin
Copy link
Owner

If you setup your backend appropriately you could even serve the ogg file one page at a time allowing for very fast playback on the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants