MP4文件中没有音频 – Android

我正在使用MP4ParserMergeAudioVideo将新音频添加到MP4文件中。 该库曾说过使用.wav文件,如果我在目录中保存一个.wav文件,并将audiofile的名称作为example.m4a ,我得到一个文件未找到exception。 所以我将文件更改为.m4a音频文件。 代码如下。

 findViewById(R.id.append).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String root = Environment.getExternalStorageDirectory().toString(); Log.e("",""+root); String audio = root + "/download/"+"mymovieaudio.m4a"; String video = root + "/download/"+"My_Movie.mp4"; String output = root + "/download/ouput.mp4"; mux(video, audio, output); } }); 

多路复用function是这样的

 public boolean mux(String videoFile, String audioFile, String outputFile) { Movie video; try { video = new MovieCreator().build(videoFile); } catch (RuntimeException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } Movie audio; try { audio = new MovieCreator().build(audioFile); } catch (IOException e) { e.printStackTrace(); return false; } catch (NullPointerException e) { e.printStackTrace(); return false; } Track audioTrack = audio.getTracks().get(0); video.addTrack(audioTrack); Container out = new DefaultMp4Builder().build(video); FileOutputStream fos; try { fos = new FileOutputStream(outputFile); } catch (FileNotFoundException e) { e.printStackTrace(); return false; } BufferedWritableFileByteChannel byteBufferByteChannel = new BufferedWritableFileByteChannel(fos); try { out.writeContainer(byteBufferByteChannel); byteBufferByteChannel.close(); fos.close(); } catch (IOException e) { e.printStackTrace(); return false; } return true; } 

我成功地将output.mp4文件放入我设备的下载目录中。 问题是它没有任何音频。 请帮忙。 提前致谢。