编码不能输入surface,编码surface模式,是编码这边给个surface出去,外部往surface里填充8bit或10bit流,填充10bit流时,在config阶段,OH\_MD\_KEY\_PROFILE要配成HEVC\_PROFILE\_MAIN\_10级别。填充8bit流时,不配置会走默认,输入是几bit流,输出就是几bit流。int32_t VideoEncoder::Configure(const SampleInfo &sampleInfo) { OH_AVFormat *format = OH_AVFormat_Create(); CHECK_AND_RETURN_RET_LOG(format != nullptr, AVCODEC_SAMPLE_ERR_ERROR, "AVFormat create failed"); OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, sampleInfo.videoWidth); OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, sampleInfo.videoHeight); OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, sampleInfo.frameRate); OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, sampleInfo.pixelFormat); OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, CBR); OH_AVFormat_SetIntValue(format, OH_MD_KEY_BITRATE, sampleInfo.bitrate); OH_AVFormat_SetIntValue(format, OH_MD_KEY_PROFILE, sampleInfo.hevcProfile); if (sampleInfo.isHDRVivid) { OH_AVFormat_SetIntValue(format, OH_MD_KEY_I_FRAME_INTERVAL, 100); // 100: I_FRAME_INTERVAL } AVCODEC_SAMPLE_LOGI("====== VideoEncoder config ======"); AVCODEC_SAMPLE_LOGI("%{public}d*%{public}d, %{public}.1ffps", sampleInfo.videoWidth, sampleInfo.videoHeight, sampleInfo.frameRate); // 1024: ratio of kbps to bps AVCODEC_SAMPLE_LOGI("BitRate Mode: %{public}d, BitRate: %{public}" PRId64 "kbps", VBR, sampleInfo.bitrate / 1024); AVCODEC_SAMPLE_LOGI("====== VideoEncoder config ======"); int ret = OH_VideoEncoder_Configure(encoder_, format); CHECK_AND_RETURN_RET_LOG(ret == AV_ERR_OK, AVCODEC_SAMPLE_ERR_ERROR, "Config failed, ret: %{public}d", ret); OH_AVFormat_Destroy(format); format = nullptr; return AVCODEC_SAMPLE_ERR_OK; }
编码不能输入surface,编码surface模式,是编码这边给个surface出去,外部往surface里填充8bit或10bit流,填充10bit流时,在config阶段,OH\_MD\_KEY\_PROFILE要配成HEVC\_PROFILE\_MAIN\_10级别。填充8bit流时,不配置会走默认,输入是几bit流,输出就是几bit流。