1、android上录音AAC/MP3格式,未成功
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合并在一起,很好用。
xxxxxxxxxx
1
public static void main(String[] args) throws FileNotFoundException, IOException { 2
3
/*Movie m = new Movie(); 4
MP3TrackImpl mp3Track = new MP3TrackImpl(new FileDataSourceImpl("D:/tracks/test__mp3.mp3")); 5
m.addTrack(mp3Track); 6
AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl("D:/tracks/aac-sample.aac")); 7
m.addTrack(aacTrack); 8
Container out = new DefaultMp4Builder().build(m); 9
FileOutputStream fos = new FileOutputStream(new File( 10
"D:/tracks/test__mp3.mp4")); 11
FileChannel fc = fos.getChannel(); 12
out.writeContainer(fc); 13
fos.close();*/ 14
15
// mp4音视频合成 16
try { 17
Movie countVideo = MovieCreator.build("D:/tracks/test__mp3.mp4"); 18
Movie countAudioEnglish = MovieCreator 19
.build("D:/tracks/test_ount_out.mp4"); 20
Track audioTrackEnglish = countAudioEnglish.getTracks().get(0); 21
countVideo.addTrack(audioTrackEnglish); 22
Container out = new DefaultMp4Builder().build(countVideo); 23
FileOutputStream fos = new FileOutputStream(new File( 24
"D:/tracks/test_out______.mp4")); 25
out.writeContainer(fos.getChannel()); 26
fos.close(); 27
} catch (IOException e) { 28
e.printStackTrace(); 29
} 30
}3、通过FFMPEG PCM、WAV转mp4。看代码是通过ffmpeg命令转码,ffmpeg支持转码,应该都可以实现,可先用命令试试资源。
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();
}WAV转AAC命令==ffmpeg -i aec_out.wav -strict -2 -b:a 32k -y abc.aac(代码实现可以参考ffmpeg支持windows和linux库源码)
4、录音MP3格式
通过lame实现,没有库源码,有android源码










