问题
My question is related to this other SO question. I am trying to record audio in iOS via Capture.captureAudio()
. It outputs an audio file that can be read on the computer but neither on iOS (iPhone 4S) nor on Android.
ffmpeg -i yields :
Input #0, caf, from 'myFile.m4a':
Duration: 00:00:07.04, start: 0.000000, bitrate: 37 kb/s
Stream #0:0: Audio: aac (aac / 0x20636161), 16000 Hz, mono, s16, 23 kb/s
If I record a file with iOS via Voice Recorder app I get from ffmpeg :
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Test.m4a':
Metadata:
major_brand : M4A
minor_version : 0
compatible_brands: M4A mp42isom
creation_time : 2017-04-03 19:01:32
date : 2017-04-03T21:01:09+0200
encoder : com.apple.VoiceMemos (iPhone OS 7.1.2)
Duration: 00:00:05.15, start: 0.000000, bitrate: 67 kb/s
Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, s16, 64 kb/s
Metadata:
creation_time : 2017-04-03 19:01:32
handler_name : Core Media Audio
This file can be played on Android and iOS.
Although at first sight the mime types seem to be restrained to "amr"
/**
* Gets the available recording MimeTypes
*/
public String [] getAvailableRecordingMimeTypes(){
return new String[]{"audio/amr"};
}
a glance at the native code shows that on iOS it records as "MPEG4AAC" 16kHz.
Consequently why do I get a caf file that cannot be played on mobile ?
Any help appreciated!
回答1:
caf files are Core Audio Format files. They are just a wrapper that apple uses for its audio as it has some advantages to storing the audio "unwrapped".
The audio inside the caf wrapper is still encoded using the format that you specified. Since it is just a wrapper, it should be fast and easy to "unwrap" it. This google search for "convert caf to mp4" shows lots of results. If you are looking to do it programmatically, appropriate Google searches should yield lots of results.
来源:https://stackoverflow.com/questions/43226775/why-is-codename-one-on-ios-recording-audio-as-caf