登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
AI 队友
登录
注册
代码拉取完成,页面将自动刷新
仓库状态说明
开源项目
>
OpenHarmony
>
OpenHarmony 教程指南
&&
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
1.4K
Star
7.6K
Fork
8.1K
OpenHarmony
/
docs
关闭
代码
Issues
1352
Pull Requests
581
Wiki
统计
流水线
服务
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
开发画像分析
我知道了,不再自动展开
更新失败,请稍后重试!
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
[Bug]: 相机预览流下发native编码颜色不对
已完成
#IB4M1E
shoxgov
创建于
2024-11-15 14:18
### 发生了什么问题? api=11, js是相机双预览流,通过imageReceiver返回的image.ComponentType.JPEG格式流下发到natvie,能编码,但是对端解码后颜色不对,没有彩色 跟https://gitee.com/openharmony/docs/issues/I99F0P?from=project-issue这个问题一样,画面颜色不对,黑白,有4个格的偏彩色 ### 期望行为是什么? 编码正常,颜色可正常显示 ### 如何复现该缺陷 环境是Openharmony4.1 api=11 sdk是fullsdk js层代码 let size: image.Size = { height: this.cameraH, width: this.cameraW } this.imageReceiver = image.createImageReceiver(size, image.ImageFormat.JPEG, 4); this.imageReceiver.on('imageArrival', this.imageReceiverCallback); async initCamera(surfaceId: string) { logger.info(this.tag, 'initCamera') await this.releaseCamera() this.cameraManager = camera.getCameraManager(this.context) logger.info(this.tag, 'getCameraManager') this.cameras = this.cameraManager.getSupportedCameras();////获取支持指定的相机设备对象 logger.info(this.tag, `get cameras ${this.cameras.length}`) if (this.cameras.length === 0) { logger.info(this.tag, 'cannot get cameras') return } this.openEncoder = false; let cameraDevice = this.cameras[0] this.cameraOutputCapability = this.cameraManager.getSupportedOutputCapability(cameraDevice,camera.SceneMode.NORMAL_PHOTO);//查询相机设备支持的输出能力 let previewProfile = this.cameraOutputCapability.previewProfiles[0]; // 预览流2--用来录像 let previewProfilesRecorder = this.cameraOutputCapability.previewProfiles[0]; this.previewOutput = this.cameraManager.createPreviewOutput(previewProfile, surfaceId);////通过相机管理器创建预览输出对象-//surfaceId从XComponent组件获取 logger.info(this.tag, 'createPreviewOutput2 surfaceId='+surfaceId) // 创建 预览流2 录像输出对象 let imageReceiverSurfaceId = await this.imageReceiver.getReceivingSurfaceId(); logger.info(this.tag, 'imageReceiverSurfaceId ='+imageReceiverSurfaceId) let previewOutputRecorder = this.cameraManager.createPreviewOutput(previewProfilesRecorder, imageReceiverSurfaceId); this.cameraInput = this.cameraManager.createCameraInput(cameraDevice); logger.info(this.tag, 'createCameraInput') this.cameraInput.open() logger.info(this.tag, 'createPreviewOutput'); this.captureSession = this.cameraManager.createCaptureSession();//创建CaptureSession实例 logger.info(this.tag, 'createCaptureSession') this.captureSession.beginConfig();//开始配置会话 logger.info(this.tag, 'beginConfig'); this.captureSession.addInput(this.cameraInput);//将cameraInput加入会话 this.captureSession.addOutput(this.previewOutput);//将预览输出加入会话 // 把 录像预览流 加入到会话 this.captureSession.addOutput(previewOutputRecorder); await this.captureSession.commitConfig();//提交配置信息 await this.captureSession.start();//开始输出 logger.info(this.tag, 'captureSession start') } //图像获取到后回调 imageReceiverCallback = () => { this.imageReceiver.readNextImage((err: BusinessError, nextImage: image.Image) => { nextImage.getComponent(image.ComponentType.JPEG, (err: BusinessError, imgComponent: image.Component) => { if (err || imgComponent === undefined) { logger.error(this.tag, "receiveImage--getComponent -error:" + err + " imgComponent:" + imgComponent); return; } if (imgComponent.byteBuffer as ArrayBuffer) { let buffer = imgComponent.byteBuffer; let len = buffer.byteLength; uaNapi.writeVideo(buffer,len)//这里是下发到native nextImage.release() } else { logger.debug(this.tag, "receiveImage--byteBuffer -error:" + " imgComponent.byteBuffer:" + imgComponent.byteBuffer); return; } } navtive-------------层 static OH_AVCodec* videoEnc; // 配置视频帧宽度(必须) static int32_t width = 640; // 配置视频帧高度(必须) static int32_t height = 480; // 配置视频像素格式(必须) /** * yuv 420 planar ---- AV_PIXEL_FORMAT_YUVI420 = 1,死机 * NV12. yuv 420 semiplanar. ---- AV_PIXEL_FORMAT_NV12 = 2, * NV21. yvu 420 semiplanar.------ AV_PIXEL_FORMAT_NV21 = 3,黑屏 * format from surface. ------ AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,死机 * RGBA8888 ------- AV_PIXEL_FORMAT_RGBA = 5,//4格图像 */ constexpr OH_AVPixelFormat DEFAULT_PIXELFORMAT = AV_PIXEL_FORMAT_NV12; static int32_t widthStride = 0; static int32_t heightStride = 0; /// // 配置视频帧速率 double frameRate = 30.0; // 配置视频YUV值范围标志 bool rangeFlag = false; // 配置视频原色 int32_t primary = static_cast<int32_t>(OH_ColorPrimary::COLOR_PRIMARY_BT709); // 配置传输特性 int32_t transfer = static_cast<int32_t>(OH_TransferCharacteristic::TRANSFER_CHARACTERISTIC_BT709); // 配置最大矩阵系数 int32_t matrix = static_cast<int32_t>(OH_MatrixCoefficient::MATRIX_COEFFICIENT_IDENTITY); // 配置编码Profile --- AVC_PROFILE_BASELINE = 0, AVC_PROFILE_HIGH = 4, AVC_PROFILE_MAIN = 8 int32_t profile = static_cast<int32_t>(OH_AVCProfile::AVC_PROFILE_BASELINE); // 配置编码比特率模式 int32_t rateMode = static_cast<int32_t>(OH_VideoEncodeBitrateMode::CBR); // 配置关键帧的间隔,单位为毫秒 int32_t iFrameInterval = 1500; // 配置比特率 int64_t bitRate = 3000000; // 配置编码质量 int64_t quality = 0; /** * 注意 配置非必须参数错误时,会返回AV_ERR_INVAILD_VAL错误码。但OH_VideoEncoder_Configure()不会失败,而是使用默认值继续执行。 */ static void setEncodeConfig(){ OH_AVFormat *format = OH_AVFormat_Create(); OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, width); OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, height); OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, DEFAULT_PIXELFORMAT); OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, frameRate); OH_AVFormat_SetIntValue(format, OH_MD_KEY_RANGE_FLAG, rangeFlag); OH_AVFormat_SetIntValue(format, OH_MD_KEY_COLOR_PRIMARIES, primary); OH_AVFormat_SetIntValue(format, OH_MD_KEY_TRANSFER_CHARACTERISTICS, transfer); OH_AVFormat_SetIntValue(format, OH_MD_KEY_MATRIX_COEFFICIENTS, matrix); // OH_AVFormat_SetIntValue(format, OH_MD_KEY_I_FRAME_INTERVAL, iFrameInterval); // 支持动态请求IDR帧 // OH_AVFormat_SetIntValue(format, OH_MD_KEY_REQUEST_I_FRAME, true); OH_AVFormat_SetIntValue(format, OH_MD_KEY_PROFILE, profile); OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, rateMode); OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitRate); //只有当OH_MD_KEY_BITRATE = CQ时,才需要配置OH_MD_KEY_QUALITY if (rateMode == static_cast<int32_t>(OH_VideoEncodeBitrateMode::CQ)) { OH_AVFormat_SetIntValue(format, OH_MD_KEY_QUALITY, quality); } int32_t ret = OH_VideoEncoder_Configure(videoEnc, format); if (ret != AV_ERR_OK) {// 异常处理 LOGE("setEncodeConfig OH_VideoEncoder_Configure err: %{public}d", ret); } OH_AVFormat_Destroy(format); } /** 创建解码器 * */ static void createVideoEncoder(void (*p_callback)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data,OH_AVCodecBufferAttr *attr, void *userData)){ isFirstFrame = true; // 通过codec name创建编码器,应用有特殊需求,比如选择支持某种分辨率规格的编码器,可先查询capability,再根据codec name创建编码器。 OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true); const char *codecName = OH_AVCapability_GetName(capability); videoEnc = OH_VideoEncoder_CreateByName(codecName); //第二种方法 // 通过MIME TYPE创建编码器,只能创建系统推荐的特定编解码器 涉及创建多路编解码器时,优先创建硬件编码器实例,硬件资源不够时再创建软件编码器实例 // OH_AVCodec *videoEnc = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC); // 配置异步回调,调用 OH_VideoEncoder_RegisterCallback()接口 // OH_AVCodecCallback cb = {&OnError, &OnStreamChanged, &OnNeedInputBuffer, &OnNewOutputBuffer}; // int32_t ret = OH_VideoEncoder_RegisterCallback(videoEnc, cb, NULL); // NULL:用户特定数据userData为空 //异步回调 OH_AVCodecAsyncCallback cb = {&OnError, &OnStreamChanged, &OnNeedInputData, p_callback}; int32_t ret = OH_VideoEncoder_SetCallback(videoEnc, cb, NULL); // NULL:用户特定数据userData为空 if (ret != AV_ERR_OK) {// 异常处理 LOGE("createVideoEncoder OH_VideoEncoder_RegisterCallback err: %{public}d", ret); } // 5.2 注册随帧参数回调 // OH_VideoEncoder_OnNeedInputParameter inParaCb = OnNeedInputParameter; // OH_VideoEncoder_RegisterParameterCallback(videoEnc, inParaCb, nullptr); // NULL:用户特定数据userData为空 setEncodeConfig(); } ////这里是js下发的数据,在这里填充 static OH_AVErrCode pushEncoderFrameBuffer(void* data, int32_t size){ //当上层的待编码的数据传过来时 std::lock_guard<std::mutex> lock(queueMutex_); if(indexQueue.size() <= 0){ LOGE("indexQueue is empty"); return AV_ERR_NO_MEMORY; } if (widthStride == width) { // 处理文件流得到帧的长度,再将需要编码的数据写入到对应index的buffer中 } else { // 如果跨距不等于宽,需要调用者按照跨距进行偏移,具体可参考以下示例 // LOGE("pushEncoderFrameBuffer widthStride =%{public}d",widthStride); } uint32_t index = indexQueue.front(); auto buffer = inBufferQueue.front(); //从队列中拿出buffer OH_AVCodecBufferAttr info; if(!running){//结束了,发送结束标记EOS info.size = 0; info.offset = 0; info.pts = 0; info.flags = AVCODEC_BUFFER_FLAGS_EOS; OH_VideoEncoder_PushInputData(videoEnc, index, info); LOGE("send data EOS"); nofifyPushBufferFinish(); return AV_ERR_OK; } info.size = size; info.offset = 0; info.pts = timestamp; timestamp += 50; //拷贝数据 memcpy(OH_AVMemory_GetAddr(buffer), data, OH_AVMemory_GetSize(buffer)); //将buffer 推给native video encoder去编码 //这里调用的是buffer模式的发送数据3.2 release分支需要增加此接口并导出 OH_AVErrCode ret = OH_VideoEncoder_PushInputData(videoEnc,index,info); indexQueue.pop(); inBufferQueue.pop(); return ret; } ### 其他补充信息  图片一张是相机预览正常画面,一张黑白的编码后对端解码显示的,细看的话黑白画面是正常的,就是覆盖的彩色不正常,对端设备是正常的 预览流createImageReceiver选格式只能ImageFormat.JPEG,其他YUV_Y直接报错崩溃,分辨率是640*480 返回帧的数据 len:1228800,rowStride=640,pixelStride=1 OH_Video OH_AVPixelFormat DEFAULT_PIXELFORMAT = AV_PIXEL_FORMAT_NV12;除了AV_PIXEL_FORMAT_RGBA和NV12可以选,其他的均是崩溃或者死机重启,能显示的图片画面都是一样的,颜色不对, ### 版本或分支信息 - [ ] master - [ ] 5.0-Beta1 - [x] Release 4.1 - [ ] Release 4.0 - [ ] Release 3.2
### 发生了什么问题? api=11, js是相机双预览流,通过imageReceiver返回的image.ComponentType.JPEG格式流下发到natvie,能编码,但是对端解码后颜色不对,没有彩色 跟https://gitee.com/openharmony/docs/issues/I99F0P?from=project-issue这个问题一样,画面颜色不对,黑白,有4个格的偏彩色 ### 期望行为是什么? 编码正常,颜色可正常显示 ### 如何复现该缺陷 环境是Openharmony4.1 api=11 sdk是fullsdk js层代码 let size: image.Size = { height: this.cameraH, width: this.cameraW } this.imageReceiver = image.createImageReceiver(size, image.ImageFormat.JPEG, 4); this.imageReceiver.on('imageArrival', this.imageReceiverCallback); async initCamera(surfaceId: string) { logger.info(this.tag, 'initCamera') await this.releaseCamera() this.cameraManager = camera.getCameraManager(this.context) logger.info(this.tag, 'getCameraManager') this.cameras = this.cameraManager.getSupportedCameras();////获取支持指定的相机设备对象 logger.info(this.tag, `get cameras ${this.cameras.length}`) if (this.cameras.length === 0) { logger.info(this.tag, 'cannot get cameras') return } this.openEncoder = false; let cameraDevice = this.cameras[0] this.cameraOutputCapability = this.cameraManager.getSupportedOutputCapability(cameraDevice,camera.SceneMode.NORMAL_PHOTO);//查询相机设备支持的输出能力 let previewProfile = this.cameraOutputCapability.previewProfiles[0]; // 预览流2--用来录像 let previewProfilesRecorder = this.cameraOutputCapability.previewProfiles[0]; this.previewOutput = this.cameraManager.createPreviewOutput(previewProfile, surfaceId);////通过相机管理器创建预览输出对象-//surfaceId从XComponent组件获取 logger.info(this.tag, 'createPreviewOutput2 surfaceId='+surfaceId) // 创建 预览流2 录像输出对象 let imageReceiverSurfaceId = await this.imageReceiver.getReceivingSurfaceId(); logger.info(this.tag, 'imageReceiverSurfaceId ='+imageReceiverSurfaceId) let previewOutputRecorder = this.cameraManager.createPreviewOutput(previewProfilesRecorder, imageReceiverSurfaceId); this.cameraInput = this.cameraManager.createCameraInput(cameraDevice); logger.info(this.tag, 'createCameraInput') this.cameraInput.open() logger.info(this.tag, 'createPreviewOutput'); this.captureSession = this.cameraManager.createCaptureSession();//创建CaptureSession实例 logger.info(this.tag, 'createCaptureSession') this.captureSession.beginConfig();//开始配置会话 logger.info(this.tag, 'beginConfig'); this.captureSession.addInput(this.cameraInput);//将cameraInput加入会话 this.captureSession.addOutput(this.previewOutput);//将预览输出加入会话 // 把 录像预览流 加入到会话 this.captureSession.addOutput(previewOutputRecorder); await this.captureSession.commitConfig();//提交配置信息 await this.captureSession.start();//开始输出 logger.info(this.tag, 'captureSession start') } //图像获取到后回调 imageReceiverCallback = () => { this.imageReceiver.readNextImage((err: BusinessError, nextImage: image.Image) => { nextImage.getComponent(image.ComponentType.JPEG, (err: BusinessError, imgComponent: image.Component) => { if (err || imgComponent === undefined) { logger.error(this.tag, "receiveImage--getComponent -error:" + err + " imgComponent:" + imgComponent); return; } if (imgComponent.byteBuffer as ArrayBuffer) { let buffer = imgComponent.byteBuffer; let len = buffer.byteLength; uaNapi.writeVideo(buffer,len)//这里是下发到native nextImage.release() } else { logger.debug(this.tag, "receiveImage--byteBuffer -error:" + " imgComponent.byteBuffer:" + imgComponent.byteBuffer); return; } } navtive-------------层 static OH_AVCodec* videoEnc; // 配置视频帧宽度(必须) static int32_t width = 640; // 配置视频帧高度(必须) static int32_t height = 480; // 配置视频像素格式(必须) /** * yuv 420 planar ---- AV_PIXEL_FORMAT_YUVI420 = 1,死机 * NV12. yuv 420 semiplanar. ---- AV_PIXEL_FORMAT_NV12 = 2, * NV21. yvu 420 semiplanar.------ AV_PIXEL_FORMAT_NV21 = 3,黑屏 * format from surface. ------ AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,死机 * RGBA8888 ------- AV_PIXEL_FORMAT_RGBA = 5,//4格图像 */ constexpr OH_AVPixelFormat DEFAULT_PIXELFORMAT = AV_PIXEL_FORMAT_NV12; static int32_t widthStride = 0; static int32_t heightStride = 0; /// // 配置视频帧速率 double frameRate = 30.0; // 配置视频YUV值范围标志 bool rangeFlag = false; // 配置视频原色 int32_t primary = static_cast<int32_t>(OH_ColorPrimary::COLOR_PRIMARY_BT709); // 配置传输特性 int32_t transfer = static_cast<int32_t>(OH_TransferCharacteristic::TRANSFER_CHARACTERISTIC_BT709); // 配置最大矩阵系数 int32_t matrix = static_cast<int32_t>(OH_MatrixCoefficient::MATRIX_COEFFICIENT_IDENTITY); // 配置编码Profile --- AVC_PROFILE_BASELINE = 0, AVC_PROFILE_HIGH = 4, AVC_PROFILE_MAIN = 8 int32_t profile = static_cast<int32_t>(OH_AVCProfile::AVC_PROFILE_BASELINE); // 配置编码比特率模式 int32_t rateMode = static_cast<int32_t>(OH_VideoEncodeBitrateMode::CBR); // 配置关键帧的间隔,单位为毫秒 int32_t iFrameInterval = 1500; // 配置比特率 int64_t bitRate = 3000000; // 配置编码质量 int64_t quality = 0; /** * 注意 配置非必须参数错误时,会返回AV_ERR_INVAILD_VAL错误码。但OH_VideoEncoder_Configure()不会失败,而是使用默认值继续执行。 */ static void setEncodeConfig(){ OH_AVFormat *format = OH_AVFormat_Create(); OH_AVFormat_SetIntValue(format, OH_MD_KEY_WIDTH, width); OH_AVFormat_SetIntValue(format, OH_MD_KEY_HEIGHT, height); OH_AVFormat_SetIntValue(format, OH_MD_KEY_PIXEL_FORMAT, DEFAULT_PIXELFORMAT); OH_AVFormat_SetDoubleValue(format, OH_MD_KEY_FRAME_RATE, frameRate); OH_AVFormat_SetIntValue(format, OH_MD_KEY_RANGE_FLAG, rangeFlag); OH_AVFormat_SetIntValue(format, OH_MD_KEY_COLOR_PRIMARIES, primary); OH_AVFormat_SetIntValue(format, OH_MD_KEY_TRANSFER_CHARACTERISTICS, transfer); OH_AVFormat_SetIntValue(format, OH_MD_KEY_MATRIX_COEFFICIENTS, matrix); // OH_AVFormat_SetIntValue(format, OH_MD_KEY_I_FRAME_INTERVAL, iFrameInterval); // 支持动态请求IDR帧 // OH_AVFormat_SetIntValue(format, OH_MD_KEY_REQUEST_I_FRAME, true); OH_AVFormat_SetIntValue(format, OH_MD_KEY_PROFILE, profile); OH_AVFormat_SetIntValue(format, OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE, rateMode); OH_AVFormat_SetLongValue(format, OH_MD_KEY_BITRATE, bitRate); //只有当OH_MD_KEY_BITRATE = CQ时,才需要配置OH_MD_KEY_QUALITY if (rateMode == static_cast<int32_t>(OH_VideoEncodeBitrateMode::CQ)) { OH_AVFormat_SetIntValue(format, OH_MD_KEY_QUALITY, quality); } int32_t ret = OH_VideoEncoder_Configure(videoEnc, format); if (ret != AV_ERR_OK) {// 异常处理 LOGE("setEncodeConfig OH_VideoEncoder_Configure err: %{public}d", ret); } OH_AVFormat_Destroy(format); } /** 创建解码器 * */ static void createVideoEncoder(void (*p_callback)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data,OH_AVCodecBufferAttr *attr, void *userData)){ isFirstFrame = true; // 通过codec name创建编码器,应用有特殊需求,比如选择支持某种分辨率规格的编码器,可先查询capability,再根据codec name创建编码器。 OH_AVCapability *capability = OH_AVCodec_GetCapability(OH_AVCODEC_MIMETYPE_VIDEO_AVC, true); const char *codecName = OH_AVCapability_GetName(capability); videoEnc = OH_VideoEncoder_CreateByName(codecName); //第二种方法 // 通过MIME TYPE创建编码器,只能创建系统推荐的特定编解码器 涉及创建多路编解码器时,优先创建硬件编码器实例,硬件资源不够时再创建软件编码器实例 // OH_AVCodec *videoEnc = OH_VideoEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC); // 配置异步回调,调用 OH_VideoEncoder_RegisterCallback()接口 // OH_AVCodecCallback cb = {&OnError, &OnStreamChanged, &OnNeedInputBuffer, &OnNewOutputBuffer}; // int32_t ret = OH_VideoEncoder_RegisterCallback(videoEnc, cb, NULL); // NULL:用户特定数据userData为空 //异步回调 OH_AVCodecAsyncCallback cb = {&OnError, &OnStreamChanged, &OnNeedInputData, p_callback}; int32_t ret = OH_VideoEncoder_SetCallback(videoEnc, cb, NULL); // NULL:用户特定数据userData为空 if (ret != AV_ERR_OK) {// 异常处理 LOGE("createVideoEncoder OH_VideoEncoder_RegisterCallback err: %{public}d", ret); } // 5.2 注册随帧参数回调 // OH_VideoEncoder_OnNeedInputParameter inParaCb = OnNeedInputParameter; // OH_VideoEncoder_RegisterParameterCallback(videoEnc, inParaCb, nullptr); // NULL:用户特定数据userData为空 setEncodeConfig(); } ////这里是js下发的数据,在这里填充 static OH_AVErrCode pushEncoderFrameBuffer(void* data, int32_t size){ //当上层的待编码的数据传过来时 std::lock_guard<std::mutex> lock(queueMutex_); if(indexQueue.size() <= 0){ LOGE("indexQueue is empty"); return AV_ERR_NO_MEMORY; } if (widthStride == width) { // 处理文件流得到帧的长度,再将需要编码的数据写入到对应index的buffer中 } else { // 如果跨距不等于宽,需要调用者按照跨距进行偏移,具体可参考以下示例 // LOGE("pushEncoderFrameBuffer widthStride =%{public}d",widthStride); } uint32_t index = indexQueue.front(); auto buffer = inBufferQueue.front(); //从队列中拿出buffer OH_AVCodecBufferAttr info; if(!running){//结束了,发送结束标记EOS info.size = 0; info.offset = 0; info.pts = 0; info.flags = AVCODEC_BUFFER_FLAGS_EOS; OH_VideoEncoder_PushInputData(videoEnc, index, info); LOGE("send data EOS"); nofifyPushBufferFinish(); return AV_ERR_OK; } info.size = size; info.offset = 0; info.pts = timestamp; timestamp += 50; //拷贝数据 memcpy(OH_AVMemory_GetAddr(buffer), data, OH_AVMemory_GetSize(buffer)); //将buffer 推给native video encoder去编码 //这里调用的是buffer模式的发送数据3.2 release分支需要增加此接口并导出 OH_AVErrCode ret = OH_VideoEncoder_PushInputData(videoEnc,index,info); indexQueue.pop(); inBufferQueue.pop(); return ret; } ### 其他补充信息  图片一张是相机预览正常画面,一张黑白的编码后对端解码显示的,细看的话黑白画面是正常的,就是覆盖的彩色不正常,对端设备是正常的 预览流createImageReceiver选格式只能ImageFormat.JPEG,其他YUV_Y直接报错崩溃,分辨率是640*480 返回帧的数据 len:1228800,rowStride=640,pixelStride=1 OH_Video OH_AVPixelFormat DEFAULT_PIXELFORMAT = AV_PIXEL_FORMAT_NV12;除了AV_PIXEL_FORMAT_RGBA和NV12可以选,其他的均是崩溃或者死机重启,能显示的图片画面都是一样的,颜色不对, ### 版本或分支信息 - [ ] master - [ ] 5.0-Beta1 - [x] Release 4.1 - [ ] Release 4.0 - [ ] Release 3.2
评论 (
4
)
登录
后才可以发表评论
状态
已完成
待办的
进行中
已完成
已拒绝
负责人
未设置
标签
bug
waiting_for_assign
未设置
项目
未立项任务
未立项任务
里程碑
未关联里程碑
未关联里程碑
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
未关联
分支 (
-
)
标签 (
-
)
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
预计工期
(小时)
参与者(2)
其他
1
https://gitee.com/openharmony/docs.git
git@gitee.com:openharmony/docs.git
openharmony
docs
docs
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册