Combining mp4 and mp3 on Android with FFmpeg
I am developing a video capture application in Android. My goal is to merge the captured video file with the given mp3 file. I am using FFmpeg to merge files. The recording is done using the Android.Media platform. If now I try to combine the files as described here:
How to mux mp3 and mp4 files in Android
I get an error: avcodec_open2() error -1: Could not open video codec.
Is there a way to convert the captured video file to a readable version for FFmpeg? Or is there any other way to solve this problem?
i Don't want to shoot video with FFmpeg because it will be difficult and not clean (in my opinion)
Hope any body can help :) thanks in advance.
I Capture as shown in android DOC:
http://developer.android.com/guide/topics/media/camera.html
and this is how I am trying to combine
FrameGrabber grabber1 = new FFmpegFrameGrabber(videoPath);
FrameGrabber grabber2 = new FFmpegFrameGrabber(audioPath);
grabber1.start();
grabber2.start();
FrameRecorder recorder = new FFmpegFrameRecorder(OutputPath,grabber1.getImageWidth(), grabber1.getImageHeight(), 2);
recorder.setFormat("mp4");
recorder.setVideoQuality(1);
recorder.setFrameRate(grabber1.getFrameRate());
recorder.setSampleRate(grabber2.getSampleRate());
recorder.start();
Frame frame1, frame2 = null;
long timestamp = -2;
int count = 0;
boolean isFirstTime = false;
boolean isFirstCheck = true;
while ((frame1 = grabber1.grabFrame())!=null) {
//frame1 = grabber1.grabFrame();
frame2 = grabber2.grabFrame();
recorder.record(frame1);
recorder.record(frame2);
}
recorder.stop();
grabber1.stop();
grabber2.stop();
}catch (org.bytedeco.javacv.FrameGrabber.Exception e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
source to share
No one has answered this question yet
See similar questions:
or similar: