¿Cómo combinar múltiples archivos de audio en un momento específico con un archivo de vídeo en android?

Lo que quiero hacer es fusionar múltiples archivos de audio a un archivo de video a tiempo específico en mi proyecto android.

Por ejemplo, con dos archivos de audio: a1 con 5 segundos de longitud, a2 con 5 segundos de longitud y vídeo V1 con 20 segundos de longitud. Así que quiero fusionar audio a1 a video V1 en el tiempo 00: 01s a 00: 05s, audio a2 a video V1 a tiempo 00: 10s a 00: 15s. "Mezclar" aquí me refiero al archivo de vídeo se añadirá voz en off de los archivos de audio a1 y a2 en el momento específico, no añadir.

Después de buscar en torno a Google y StackOverflow, he encontrado la biblioteca Mp4Parser, pero por desgracia, sólo puedo fusionar totalmente la pista de audio a pista de vídeo. Mi pregunta es cómo fusionarlo en un momento específico y de varias pistas de audio?

Aquí está el código que usé:

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); List<Track> tracks = new ArrayList<Track>(); tracks.add(video.getTracks().get(0)); tracks.add(audioTrack); video.setTracks(tracks); 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; } private static class BufferedWritableFileByteChannel implements WritableByteChannel { private static final int BUFFER_CAPACITY = 1000000; private boolean isOpen = true; private final OutputStream outputStream; private final ByteBuffer byteBuffer; private final byte[] rawBuffer = new byte[BUFFER_CAPACITY]; private BufferedWritableFileByteChannel(OutputStream outputStream) { this.outputStream = outputStream; this.byteBuffer = ByteBuffer.wrap(rawBuffer); } @Override public int write(ByteBuffer inputBuffer) throws IOException { int inputBytes = inputBuffer.remaining(); if (inputBytes > byteBuffer.remaining()) { dumpToFile(); byteBuffer.clear(); if (inputBytes > byteBuffer.remaining()) { throw new BufferOverflowException(); } } byteBuffer.put(inputBuffer); return inputBytes; } @Override public boolean isOpen() { return isOpen; } @Override public void close() throws IOException { dumpToFile(); isOpen = false; } private void dumpToFile() { try { outputStream.write(rawBuffer, 0, byteBuffer.position()); } catch (IOException e) { throw new RuntimeException(e); } } } 

Cualquier ayuda sería muy apreciar! Muchas gracias.

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.