build for android
Hi!
Do you have plans to release the codec for android? Could you please provide approximate date of the release?
Thanks.
We are planning to build this for Android, but I do not have any dates for when that will be done.
The code that is here may be close to building for Android already since you could set USE_ASM=No in the make system and it would use the C versions for those functions.
Yeah, we are planning to have auot build/test on Android/iOS soon.
Thanks for your comments, I'm also looking forward to an android build
Hallo,
I tried out the android build but the encoding didn't work for me. I'm not sure if I'm using the source in the right way, so please correct me if I'm not.
This is the part where I initialize the encoder, which works fine.
CreateSVCEncoder(&encoder);
SEncParamBase param;
memset(¶m, 0, sizeof(SEncParamBase));
param.fMaxFrameRate = (float) frame_rate;
param.iPicWidth = dest_size;
param.iPicHeight = dest_size;
param.iTargetBitrate = 5000000;
param.iInputCsp = videoFormatI420;
if ((*encoder)->Initialize(encoder, ¶m) != 0) {
throwJavaException(env, "java/lang/IOException",
"Couldn't initialize encoder.");
return;
}
The actually problem seems the encoding part, where I'm not sure how to access the data in the proper way. The input I'm using is the Android camera preview which is normally in yuv nv21 format and so I convert it with the libyuv library to I420 (this works, generated a jpeg file). Then I encode the frame
EVideoFrameType frameType = (*encoder)->EncodeFrame(encoder, scaled_i420,
&info);
if (frameType != videoFrameTypeInvalid && frameType != videoFrameTypeSkip) {
int i;
for (i = 0; i < info.iLayerNum; i++) {
SLayerBSInfo layerInfo = info.sLayerInfo[i];
int layerSize = 0;
int j;
for (j = 0; j < layerInfo.iNalCount; j++)
layerSize += layerInfo.iNalLengthInByte[j];
fwrite(layerInfo.pBsBuf, 1, layerSize, outfile);
LOG("written %d bytes.", layerSize);
}
return JNI_TRUE;
}
The EncodeFrame Methode returns not videoFrameTypeInvalid, but the calculated layerSize is only about 400 to 430 bytes, which is too small. So it seems some data are missing or I just used it wrong. But i looked into the source of the command line tool and there is it used in the same way. So, what I'm doing wrong? Thanks in advance
Hi klaus-steiner: I checked your code and didn't find any wrong. I aslo run the test code on android, the output bitstream is correct. Could you get the lastest code from cisco/master branch and run it again? thanks a lot!
Thanks for the answer ruil2. I followed your advise and checked out the latest code, but still the same issue. the encoded h264 file has only about 80 KB (10 seconds movie, 480x480 resolution). The problem is that I cannot use the test code for android, because it takes only a file from the sd card as input. I want to encode the frames from the camera directly, without creating a file first. but maybe you could take a look at the whole code. I created a repository: https://github.com/klaus-steiner/SplotsVideoRecorder
Could you also upload the h264 file?
I uploaded the output into the test directory in my repository.
the h264 file can be decoded correctly. But the reconstruct frames (220 frames) are green screen. Because all frames are green screen, the output size is very small. Could you check your capture moudle or color space conversion module firstly?
ok thank you, i going to check this.
I'm now getting an output in black and white when I convert the frames with the libyuv library to nv21 and leaving the iColorFormat flag of the SSourcePicture variable to videoFormatI420. But when I change the iColorFormat flag to videoFormatNV12 the output is again just green. So is there a naming issue or are there differences between the codec color formats and the fourcc ones? Another questions I would like to ask is which functionality has the PauseFrame() function?
- openh264 encoder doesn't support videoFormatNV12 input currently.You can try the below format as input.
videoFormatI420: videoFormatYV12: videoFormatYUY2: videoFormatYVYU: videoFormatUYVY: videoFormatRGB: videoFormatBGR: videoFormatBGRA: videoFormatRGBA: videoFormatARGB: videoFormatABGR: - Could you convert the frames to I420 format? It also will save some computation in encoder. 3.PauseFrame() is used in realtime application, which needs to output one IDR frame.
Hey ruil2, sry for the late answer but I think I now fixed the colorspace issue. It seems that libyuv has the U and V planes in the I420 format in reverse order. Now I getting the right output :).
Is there any other format beside I420 really supported as input? I'm asking because I see this code:
int CWelsH264SVCEncoder::EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) {
...
if (kpSrcPic->iColorFormat != videoFormatI420)
return cmInitParaError;
...