Mux mp4 file with aac file

267 views
Skip to first unread message

İsmail Yıldız

unread,
Dec 17, 2015, 7:32:08 AM12/17/15
to mp4parser-discussion
Hi,
I want to use the mp4parser in an android app.
I try to mux mp4 file with aac file. But i get: java.io.IOException: Expected Start Word 0xfff

I have the following Code for recording the audio:

myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
myAudioRecorder.setAudioSamplingRate(44100);
myAudioRecorder.setAudioEncodingBitRate(96000);
myAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
myAudioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

String outputFile = "audio.aac";
myAudioRecorder.setOutputFile(outputFile);

try {
   
myAudioRecorder.prepare();
   
myAudioRecorder.start();
} catch (IllegalStateException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

Audio recording works.

And the following Code for mux mp4 with .aac
try {

   
AACTrackImpl audio = new AACTrackImpl(new FileDataSourceImpl("audio.aac"));

   
Movie movie = MovieCreator.build("video.mp4");
    movie
.addTrack(audio);

   
String outputfile = "video_with_audio.mp4";

   
Mp4Builder defaultMp4Builder = new DefaultMp4Builder();
   
Container c = defaultMp4Builder.build(movie);
    c
.writeContainer(new FileOutputStream(outputfile).getChannel());


}catch (FileNotFoundException fnfe){
    fnfe
.printStackTrace();

}catch(IOException ioe){
    ioe
.printStackTrace();
}

I get java.io.IOException: Expected Start Word 0xfff in line

AACTrackImpl audio = new AACTrackImpl(new FileDataSourceImpl("audio.aac"));


Have someone a solution for this?
Regards Ismail

Reply all
Reply to author
Forward
0 new messages