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

Android Chrome mobile doesn't play the recorded file #28

Closed
diegomesata opened this issue Jul 22, 2015 · 17 comments
Closed

Android Chrome mobile doesn't play the recorded file #28

diegomesata opened this issue Jul 22, 2015 · 17 comments

Comments

@diegomesata
Copy link

Hello, I'm testing the example on Chrome mobile Android 5.0, it records ok, but I can't play the recorded file.

According to this doc http://developer.android.com/guide/appendix/media-formats.html .ogg files can be played on android.

Do you have any idea?

Thank you

@chris-rudmin
Copy link
Owner

The page you linked says android 5+ supports opus in an mkv container. The library is
returning opus in an ogg container.

On Wed, 22 Jul 2015 at 11:15 Diego Mesa notifications@github.com wrote:

Hello, I'm testing the example on Chrome mobile Android 5.0, it records
ok, but I can't play the recorded file.

According to this doc
http://developer.android.com/guide/appendix/media-formats.html .ogg files
can be played on android.

Do you have any idea?

Thank you


Reply to this email directly or view it on GitHub
#28.

@chris-rudmin
Copy link
Owner

To make playback work, you could decode the file using oggopusDecoder.js and playback the raw PCM.

@alexthewilde
Copy link

@chris-rudmin I've been trying to make this work using oggopusDecoder.js as you suggested, but with no success. Could you provide a small example how this could be achieved in combination with an <audio> tag? That'd be absolutely fantastic.

@chris-rudmin
Copy link
Owner

@alexthewilde To playback in an <audio> tag, will be multi-part process:

  1. Decode the audio using the decoder
  2. Convert Float32 PCM to INT16 and put into WAV RIFF container
  3. Playback wav blobURI in audio tag.

I'll try to post some code samples later on when I get some time.
If you don't need the audio tag, it will be simpler to playback from audio buffers using the web audio API.

@alexthewilde
Copy link

@chris-rudmin I've been researching this issue a bit more and found hpr.dogphilosophy.net/test/. This test shows that .ogg works natively on Android/mobile Chrome, i.e. without being in a mkv container.

Please have a look at this demo: http://jsfiddle.net/pm84nsdh/3/
The second audio example has been created using your Opus Recorder and it unfortunately doesn't play back in mobile Chrome. As you can see both files are served from the same server and have proper perms etc.

Can you spot any difference in these two ogg files which causes the one to play but not the other?

@chris-rudmin
Copy link
Owner

Yes, the difference is one file is Vorbis encoded the other is Opus encoded. Ogg is just the container.

https://wiki.xiph.org/OggOpus
http://www.vorbis.com/
http://www.pitivi.org/manual/codecscontainers.html

@alexthewilde
Copy link

@chris-rudmin thanks for clarifying!

@chris-rudmin
Copy link
Owner

@alexthewilde Don't despair though, decoding the ogg is not hard. I'll try and post an example tonight.

@chris-rudmin
Copy link
Owner

Made an example page to decode the file to wav audio. Hope this helps

https://github.com/chris-rudmin/DecodeToWav
http://rawgit.com/chris-rudmin/DecodeToWav/master/example.html

@alexthewilde
Copy link

@chris-rudmin that's super helpful, cheers! I guess I can make it work from there.

@chris-rudmin
Copy link
Owner

@alexthewilde if you are reading the file from the server I think you can do it like this to get an arraybuffer:

var oReq = new XMLHttpRequest();
oReq.open("GET", "/myfile.ogg", true);
oReq.responseType = "arraybuffer";
...

@diegomesata
Copy link
Author

How may time can you record in android chrome? I record about 10s and the browser crash down!

@chris-rudmin
Copy link
Owner

@diegomesata Never tried in mobile. I would assume you are limited by device resources (memory). If you are saving the file to the server in the end, you could try and stream the data as it is encoded instead of storing locally. To do this, you should override recorder.onPageEncoded()

@chris-rudmin
Copy link
Owner

@diegomesata If you could leave me a stack trace, or whatever error you get, it might be helpful. Perhaps it is something we can fix.

@diegomesata
Copy link
Author

@chris-rudmin today browser doesn't crash down, sorry for the false alarm. At server side what library could I use to decode the ogg to wav?

Edit: My server side is c#. Could it be https://github.com/ioctlLR/NVorbis?

@chris-rudmin
Copy link
Owner

@diegomesata Personally, I like sox. I think you can run command line stuff in c#. If so you also have the choice of opus-tools.

@diegomesata
Copy link
Author

Thank you for all your help, opus-tools converts the file to wav without problem, but with sox I got: sox.exe FAIL formats: no handler for detected file type `opus'

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

3 participants