Suppose i have 500 android bitmaps. I have to create a video at 60 frame rate with those bitmaps that means the video will be exactly 8.333 (500/60) seconds in length. I also have to add first 3 seconds of an audio repeatedly which is 10 seconds in length;
I know how to make the video with FrameRecorder but i don't know how to add the music with FrameGrabber as i mentioned.
Just add the audio frames the same way you would add video frames, but set the values in Frame.samples instead of Frame.image.
i have to use like this. how can i actually do it?
for(int i =0;i<500;i++){
recorder.record(frameFromBitmap)
// it increases the video length
// and i have to grab again the first frame if audio frame reaches 3 seconds
Frame audioFrame = grabber.grab();
recorder.record(audioFrame);
}
We can check the timestamp with getTimestamp().
Thank you very much...
i can add audio now but video length gets increased. How to solve?
Make sure getTimestamp() doesn't go over the length you want.
here is the code
for(int i = 1; i<=500; i++){
Frame videoFrame = new AndroidFrameConverter().convert(bitmap);
videoFrame.samples = frameGrabber.grabSamples().samples;
recorder.record(videoFrame);
// as i want only 3 seconds of the music repeatedly
if(frameGrabber.getTimestamp()/1000 > 3000){
frameGrabber.setTimestamp(0);
}
}
video length should be 8.333 seonds but it is alomost 12 seconds. where is the problem?
Like I said, make sure getTimestamp() never exceeds 8.333 seconds!
how can i explain you!!!!!! I have to run the loop 500 times exactly as i want to record all 500 bitmaps. If i stop the loop when grabber.getTimeStamp() exceeds 8.333s then i have to stop at before 500.
I have got the solution. thank you very much.
@ZeroOneZeroR Can you please explain the solution here?