I'm using MediaCodec in an Android app to encode frames from a Usb camera and then feed that raw stream to mp4parser to create mp4(API level is 16).
Everything works really good on many devices, but i have issues with Galaxy S3 (I9300).
The problem is that when i send frames to the encoder for 1 minute, sometimes i get a very large output from the encoder.
The size range is between 2.5MB-20MB. This problem gets worse on longer clips, for example 7 minutes range is 9MB-120MB.
Is that normal?
I tried to capture the same scene, but still got different results.
The encoder settings:
Codec: OMX.SEC.AVC.Encoder
Color Format: 21
KEY_FRAME_RATE: 8.77
KEY_BIT_RATE: ~880Kbit
One more thing, when sending the frames to the encoder i'm using:
mediaVideoCodec.queueInputBuffer(inputBufferIndex, 0, FrameData.length, computePresentationTime(frameCounter), 0);
and the function
private long computePresentationTime(int frameIndex) {
return (long)(132 + (frameIndex * (1000000f / 8.77f)));
}
The encoding is done in a background thread, so i'm not sure i can use system time here, unless the producer saves the frame and time. Is that correct and what does 132 represents?
Thank you for your help.