danlg / lgen

lgen
MIT License
2 stars 1 forks source link

Sound file should be saved as mp3 or compressed file format not wav #54

Open danlg opened 9 years ago

danlg commented 9 years ago

{ _id: ObjectId("55f9336f7c18d65261265888"), filename: "1442395009171.wav", contentType: "application/octet-stream", length: 133120, chunkSize: 2097152, uploadDate: ISODate("2015-09-16T09:16:34.285Z"), aliases: [ "1442395009171.wav" ], metadata: null, md5: "388ce91689596ec82177fe9a68fd5982" }

https://app.compose.io/little-genius-education-limited/deployments/mongo-do-london-dev1/mongodb/databases/genie/collections/cfs_gridfs.sounds.files/documents?find%5Bquery%5D=%7B%7D&limit=10&skip=20

danlg commented 9 years ago

good summary here http://superuser.com/questions/244819/size-comparison-wav-versus-mp3. Lowering the bit rate may be a first good quick win.

"It depends on the bitrate you select when you convert the .wav to .mp3. For some basic stats, ripping a CD to MP3, you start out with:

2 channels of 16bit audio at 44.1KHz = 2 x 16 x 44,100 = 1,411,200 bits/sec, or 172kbyte/sec. Traditionally, wav->mp3 conversions were done at 128kbit, or 16kbyte/sec. So, 172 / 16 = 10.75:1 compression.

Voice recordings don't need the full 16/44.1 recording spectrum, since human voices generally max out at 8khz mono. For telephone quality, it's 8bit @ 8khz mono, or about 8kbyte/s. Compressed to mp3 at an appropriate bit rate (figuring a normal 10:1 ratio), you end up with 0.8kbyte/sec, or 819.2bytes/sec."

danlg commented 9 years ago

Seems wav only for iOS. See also MediaRecorder.AudioEncoder.ACC https://github.com/cfjedimaster/Cordova-Examples and https://github.com/cfjedimaster/Cordova-Examples/blob/eb9f85f68f67f612f3ab05d4059c84a281196308/mysoundboard/www/templates/new.html https://github.com/cfjedimaster/Cordova-Examples/blob/a00aa8304ca5bc2f6cb099d48d00a2dd3266548e/mysoundboard/www/js/controllers.js

danlg commented 9 years ago

http://developer.android.com/reference/android/media/MediaRecorder.AudioEncoder.html

danlg commented 9 years ago

other encoding may be possible for Android AAC_ELD or VORBIS, see bit rate also but priority is IOS Wav and check the encoding for Android if compressed

image

mike623 commented 9 years ago

I m using cordova-plugin-media which forked by me

https://github.com/mike623/cordova-plugin-media

and have a look to here, for android, I already used acc as encoding. But for ios, It only support wav for recording

https://github.com/mike623/cordova-plugin-media/blob/master/src/android/AudioPlayer.java#L145

danlg commented 9 years ago

Yes I have seen that thank you. These comment are for my reference.