Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data broken after encoded into h264 stream #3753

Open
wutakenmyname opened this issue May 12, 2024 · 0 comments
Open

data broken after encoded into h264 stream #3753

wutakenmyname opened this issue May 12, 2024 · 0 comments

Comments

@wutakenmyname
Copy link

I use openh264(tried both 2.2 and 2.4.1 release version and compiled on ubuntu) to encode 1920x1080 yuv420 frames into h264 stream and write these data into a file. But when I use VLC or potplayer to read this file, I see the data is broken kind of, I don't mean h264 data cannot be recognized. H264 data can be recognized but the frames decoded is broken. On the top of the frame there is a green block(even on first frame I mean I frame where no frames would be reffed to encode this I frame) while inputted yuv420 frames doesn't show this green block on the top of the frame so it is introduced by encoder i think. And also in some other frames there are also some abnormal things with abnormal color different from original yuv frames. And encoder params is here.
ret = WelsCreateSVCEncoder(&pEncoder);
if (ret != 0) {
mprintf("Failed to create encoder.\n");
exit(1);
}
long long event_value = 0;
SEncParamExt param;
(*pEncoder)->GetDefaultParams(pEncoder, &param);
memset(&param, 0, sizeof(SEncParamExt));
param.bEnableFrameCroppingFlag = false;
param.iUsageType = CAMERA_VIDEO_REAL_TIME;
param.iPicWidth = SPECIFIED_WIDTH;
param.iPicHeight = SPECIFIED_HEIGHT;
param.iTargetBitrate = 20000000; // 比特率
param.iRCMode = RC_BITRATE_MODE;// I tried RC_OFF_MODE and RC_QUALITY_MODE but things still bad.
param.fMaxFrameRate = 30.0f; // 最大帧率
param.iSpatialLayerNum = 1;
param.iEntropyCodingModeFlag = 0; // 设置为0,表示CABAC
param.iComplexityMode = MEDIUM_COMPLEXITY; // 设置为 LOW_COMPLEXITY

// 设置 GOP 和 B 帧参数
param.iNumRefFrame = 1; // 参考帧的数量
param.iLTRRefNum = 0; // 长期参考帧的数量
param.iMultipleThreadIdc = 1; // 线程数
param.sSpatialLayers[0].sSliceArgument.uiSliceMode = SM_SINGLE_SLICE;
param.sSpatialLayers[0].sSliceArgument.uiSliceNum = 0;
param.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = 0;
param.iMaxQp = 28;                      ///< the maximum QP encoder supports
param.iMinQp = 22;

// GOP 参数设置
param.uiIntraPeriod = 30; // 关键帧(I 帧)的周期为 30
//param.uiFrameToBeCoded = 0; //

Uploading uvc_push_stream_first_part.zip…
设置为 0,表示编码当前帧

here is 3 zip files where you can find the h264 stream file and inputed yuv420 frames to check because of the limit of file uploaded so I have divided them into 3 parts and compress them you can decompress one of them to check the file in it.
hope for your reply and if you want to talk on emails for more info, here is my email [email protected].
thanks very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant