openh264 icon indicating copy to clipboard operation
openh264 copied to clipboard

For some reasone output is 160X90 instead of 1280X720

Open tino197 opened this issue 12 years ago • 6 comments

Hi. 1)I complied the openh264 source to dll and i am dynamically (_cdecl) calling the open264 lib functions from my exe. 2)In m y code I create the encoder object. 3)I copied the ProcessEncodingSvcWithParam function from the console code and use it to init everything - i did not change anything from the defaults params that function sets. That function calls FillSpecificParameters as you know to init params. ( i did not change anything from the defaults params that function sets. I also did not add any other params) 4)I took bmp 24-bit file(1280X720) converted it to raw YUV (1280X720) and try to encode it. When sParam.iInputCsp =videoFormatI420 (as the default in the code)

And as the Console application do, i write the output to file using: fwrite(pLayerBsInfo->pBsBuf, 1, iLayerSize, pFpBs); // write pure bit stream into file

So in the end i get raw file that contains the YUV images as h264 The problem is that the encoded raw file resolution is 160X90 and not 1280X720 as the input images. Why it encodes as 160X90 and not 1280X720 as the input images?

tino197 avatar Apr 16 '14 20:04 tino197

it seems the input width and height are not correctly set. You may refer to the Main() function for how to set the width and height for detail.

huili2 avatar Apr 17 '14 05:04 huili2

Hi. main() function in the Console code, calls ProcessEncodingSvcWithParam() that calls FillSpecificParameters (sSvcParam); to init the width and height and as said, i copied the entire ProcessEncodingSvcWithParam() and FillSpecificParameters (sSvcParam); to my code.

So this is set in my code: sParam.iUsageType = CAMERA_VIDEO_REAL_TIME; sParam.fMaxFrameRate = 30.0f; // input frame rate sParam.iPicWidth = 1280; // width of picture in samples sParam.iPicHeight = 720; // height of picture in samples sParam.iTargetBitrate = 2500000; // target bitrate desired sParam.iRCMode = RC_QUALITY_MODE; // rc mode control sParam.iTemporalLayerNum = 3; // layer number at temporal level sParam.iSpatialLayerNum = 4; // layer number at spatial level sParam.bEnableDenoise = 0; // denoise control sParam.bEnableBackgroundDetection = 1; // background detection control sParam.bEnableAdaptiveQuant = 1; // adaptive quantization control sParam.bEnableFrameSkip = 1; // frame skipping sParam.bEnableLongTermReference = 0; // long term reference control sParam.iLtrMarkPeriod = 30;

sParam.iInputCsp = videoFormatI420; // color space of input sequence sParam.uiIntraPeriod = 320; // period of Intra frame sParam.bEnableSpsPpsIdAddition = 1; sParam.bPrefixNalAddingCtrl = 1; ..... the rest of your FillSpecificParameters comes here (init the 4 sParam.sSpatialLayers)

Again, you entire FillSpecificParameters as it is copied to my code. Still it encodes as 160X90 What am i missing?

tino197 avatar Apr 17 '14 10:04 tino197

Hi Tino197: From your settings, the first spatial layer resolution is 160x90. the fourth layer resolution is 1280x720. I need more details for this question. 1. How to know that "it still encodes as 160x90" ? 2. if possbile, could you send your bitstream to us?

ruil2 avatar Apr 18 '14 01:04 ruil2

Hi ruli2. I do not really know what the spatial layer do since i am new to h264 and that is why i copied the code as it is from the console application - yes the first layer set in the code is 160x90 and the fourth layer resolution is 1280x720 - as in the console applicaiton.

For your question: As said, i send the Encodeframe YUV420 images in size 1280x720 - in a loop. So each while iteration do Encodeframe on YUV420 image and then write to the same output file using this function: fwrite(pLayerBsInfo->pBsBuf, 1, iLayerSize, pFpBs); // write pure bit stream into file

So in the end i have pFpBs file that contain raw of encoded h264 images. (Output file does not contain and header and it is not hosted in a container - just pure bit stream of encoded images) I view that file using VLC software. To make VLC to open the file, i open VLC->Settings->Show All Settings->Under the Codec option, i chose Demuxers->There i set it to h264 video Demuxers.

After doing that, you can just Drag and drop the movie to VLC and it shows it. If i pause the movie and press the VLC->Tools>Media Information->Codec Tab i see the info about my file Codec: H264 - MPEG-4 AVC (part 10) (h264) Resolution: 160x90 Decoded format: Planar 4:2:0 YUV Thanks for your help.

tino197 avatar Apr 18 '14 02:04 tino197

Most of popular tools only support base layer decoding (that is 160x90 output). if you only want to output one layer with 1280x720 resolution. please update your setting as below.

sParam.iTemporalLayerNum = 1; // layer number at temporal level sParam.iSpatialLayerNum = 1; // layer number at spatial level

sParam.sSpatialLayers[0].iVideoWidth = 1280; sParam.sSpatialLayers[0].iVideoHeight = 720;

ruil2 avatar Apr 18 '14 02:04 ruil2

Thanks ruil2. Thanks solved the issue.

tino197 avatar Apr 18 '14 02:04 tino197