https://github.com/turkeyzhu/AACEncoder_Android
2、通過mp4parser將AAC、h264、mp4格式合成MP4
https://code.google.com/p/mp4parser/(mp4parser源碼)
https://github.com/sannies/mp4parser(使用mp4parser合成、轉碼MP4例子,該代碼添加了其他東西,需要添加很多依賴庫(主要是aspectjrt.jar),可以刪減。
該isoviewer-1.0-RC-35.jar包將mp4parser和aspectjrt.jar合併在一起,很好用。
isoviewer-1.0-RC-35.jar資源==http://download.csdn.net/detail/smile3670/8174503
aspectjrt.jar == http://download.csdn.net/detail/smile3670/8174509
使用例子
public static void main(String[] args) throws FileNotFoundException, IOException {
/*Movie m = new Movie();
MP3TrackImpl mp3Track = new MP3TrackImpl(new FileDataSourceImpl("D:/tracks/test__mp3.mp3"));
m.addTrack(mp3Track);
AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl("D:/tracks/aac-sample.aac"));
m.addTrack(aacTrack);
Container out = new DefaultMp4Builder().build(m);
FileOutputStream fos = new FileOutputStream(new File(
"D:/tracks/test__mp3.mp4"));
FileChannel fc = fos.getChannel();
out.writeContainer(fc);
fos.close();*/
// mp4音視頻合成
try {
Movie countVideo = MovieCreator.build("D:/tracks/test__mp3.mp4");
Movie countAudioEnglish = MovieCreator
.build("D:/tracks/test_ount_out.mp4");
Track audioTrackEnglish = countAudioEnglish.getTracks().get(0);
countVideo.addTrack(audioTrackEnglish);
Container out = new DefaultMp4Builder().build(countVideo);
FileOutputStream fos = new FileOutputStream(new File(
"D:/tracks/test_out______.mp4"));
out.writeContainer(fos.getChannel());
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
3、通過FFMPEG PCM、WAV轉mp4。看代碼是通過ffmpeg命令轉碼,ffmpeg支持轉碼,應該都可以實現,可先用命令試試資源。
庫資源==http://download.csdn.net/detail/smile3670/8174611(裏邊的ffmpeg支持windows和linux)
File source = new File("D:/audio.wav");
File target = new File("D:/result.mp4");
AudioAttributes audio = new AudioAttributes();
audio.setCodec(null);
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp4");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
try {
encoder.encode(source, target, attrs);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InputFormatException e) {
e.printStackTrace();
} catch (EncoderException e) {
e.printStackTrace();
}
android編譯的ffmpeg==http://download.csdn.net/detail/smile3670/8174669
WAV轉AAC命令==ffmpeg -i aec_out.wav -strict -2 -b:a 32k -y abc.aac(代碼實現可以參考ffmpeg支持windows和linux庫源碼)
4、錄音MP3格式
通過lame實現,沒有庫源碼,有android源碼
源碼==http://download.csdn.net/detail/smile3670/8174821