简体   繁体   中英

Playing back 3gp audio recorded in Android Cordova elsewhere

I would like to be able to record audio on a mobile device, in a Cordova app, then play it back on desktop computers in web applications. However, I'm running into some nasty codec issues.

According to the Cordova docs:

Android devices record audio in Adaptive Multi-Rate format. The specified file should end with a .amr extension.

This seems wrong. According to the info here , .amr files should have headers that start with:

#!AMR.4

However, audio files from my Nexus 7 have headers like this:

....ftyp3gp4....

Which seems to indicate they should have .3gp extensions.

Furthermore, I don't think there is native browser support (outside of Cordova), for either format. I found a JavaScript amr playback library , however it cannot convert .3gp files (ie the files android produces). I'm betting a similar approach could be used to decode .3gp files, however it seems like a daunting task to take on. I'm hoping to avoid that. If someone else would like to do it I would be forever grateful.

If there is no way to change the format that the Cordova Media API produces, a decoder will be necessary. A pure JavaScript decoding solution would be ideal, a flash converter would be almost as good. The other possibilities I've considered have some issues:

One possibility is to use another app to do the conversion. For example, ffmpeg for android . I would like to avoid that because launching intents from Cordova requires a plug-in that Phonegap Build doesn't provide, and the user would have to deal with installing and operating another app.

Another possibility is to do decoding in the cloud. I don't want to run any of my own web services if possible. I've tried encoding.com and was able to successfully convert one of my audio files into a mp4, however they don't yet have Dropbox file watch support. And if the audio files need to be encrypted before reaching the could, for example because of HIPAA, then cloud decoding becomes really complicated, if not impossible.

Please help. Thank you.

The problem is that there are not many encoding codecs included in Android. If you look at this table you can see what is available pre Android 4.1. Phonegap uses AMR-NB as the encoding type in a 3gpp container.

My recommendation to you is to decode in the cloud.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM