93
- 收藏
- 点赞
- 分享
- 举报
调用ss_mpi_venc_create_chn接口,报错0xa0088007。参数非法
#include <stdio.h>
#include <string.h>
#include "ot_common.h"
#include "ot_common_venc.h"
#include "ss_mpi_vb.h"
#include "ss_mpi_sys.h"
#include "ss_mpi_venc.h"
#define OT_ALIGN_UP(x, a) ((((x) + ((a) - 1)) / (a)) * (a))
// 创建1920x1080 H264编码通道的示例
int create_1080p_h264_venc_channel(void)
{
td_s32 ret;
printf("=== 1920x1080 H264 VENC Channel Creation ===\n");
// 1. 初始化VB (Video Buffer) - 1920x1080需要更大的buffer
printf("Step 1: Initialize VB...\n");
ot_vb_cfg vb_cfg = {0};
vb_cfg.max_pool_cnt = 1;
// 计算1920x1080 YUV420一帧的大小: 1920*1080*1.5 = 3,110,400字节 ≈ 3.1MB
// 建议设置稍大一些,比如4MB,并增加块数量
vb_cfg.common_pool[0].blk_size = 1920 * 1080 * 3 / 2 * 3 / 2; // 约4.5MB
vb_cfg.common_pool[0].blk_cnt = 4; // 4个块
ret = ss_mpi_vb_set_cfg(&vb_cfg);
if (ret != TD_SUCCESS) {
printf("VB SetCfg failed: 0x%x\n", ret);
return ret;
}
ret = ss_mpi_vb_init();
if (ret != TD_SUCCESS) {
printf("VB Init failed: 0x%x\n", ret);
return ret;
}
// 2. 初始化系统
printf("Step 2: Initialize SYS...\n");
ret = ss_mpi_sys_init();
if (ret != TD_SUCCESS) {
printf("SYS Init failed: 0x%x\n", ret);
ss_mpi_vb_exit();
return ret;
}
// 3. 配置编码通道属性
printf("Step 3: Configure channel attributes...\n");
ot_venc_chn_attr chn_attr = {0};
// 3.1 设置编码基本属性
chn_attr.venc_attr.type = OT_PT_H264; // H.264编码
chn_attr.venc_attr.max_pic_width = 1920; // 最大宽度
chn_attr.venc_attr.max_pic_height = 1080; // 最大高度
chn_attr.venc_attr.pic_width = 1920; // 实际宽度
chn_attr.venc_attr.pic_height = 1080; // 实际高度
chn_attr.venc_attr.is_by_frame = TD_TRUE;
// 计算缓冲区大小 (YUV420: width * height * 1.5)
// 对于1920x1080: 1920*1080*1.5 = 3,110,400字节
// 建议设置稍大一些,并考虑编码开销
chn_attr.venc_attr.buf_size = OT_ALIGN_UP(1920 * 1080 * 3 / 4, 64);
// 设置profile (0: baseline, 1: main, 2: high)
// 1080p通常使用main或high profile
chn_attr.venc_attr.profile = 1; // main profile
// 按帧获取码流
chn_attr.venc_attr.is_by_frame = TD_TRUE;
// 设置H.264特有属性
chn_attr.venc_attr.h264_attr.rcn_ref_share_buf_en = TD_FALSE; // 不启用共享缓冲区
chn_attr.venc_attr.h264_attr.frame_buf_ratio = 70; // 使用默认值
// 3.2 设置码率控制属性 - CBR模式
chn_attr.rc_attr.rc_mode = OT_VENC_RC_MODE_H264_CBR;
// 填充CBR参数
chn_attr.rc_attr.h264_cbr.gop = 30; // I帧间隔 (30帧一个I帧)
chn_attr.rc_attr.h264_cbr.stats_time = 1; // 统计时间(秒)
chn_attr.rc_attr.h264_cbr.src_frame_rate = 30; // 输入帧率
chn_attr.rc_attr.h264_cbr.dst_frame_rate = 30; // 输出帧率
chn_attr.rc_attr.h264_cbr.bit_rate = 4000; // 码率 4Mbps (对于1080p30比较合理)
// 3.3 设置GOP属性 - NORMAL_P模式
chn_attr.gop_attr.gop_mode = OT_VENC_GOP_MODE_NORMAL_P;
chn_attr.gop_attr.normal_p.ip_qp_delta = -2; // I帧QP比P帧小2 (I帧质量更好)
// 打印配置信息
printf("\nChannel Configuration:\n");
printf(" Resolution: %dx%d\n", chn_attr.venc_attr.pic_width, chn_attr.venc_attr.pic_height);
printf(" Codec: H.264\n");
printf(" Profile: %s\n", chn_attr.venc_attr.profile == 0 ? "Baseline" :
chn_attr.venc_attr.profile == 1 ? "Main" : "High");
printf(" Bitrate: %d Kbps\n", chn_attr.rc_attr.h264_cbr.bit_rate);
printf(" Frame rate: %d fps\n", chn_attr.rc_attr.h264_cbr.dst_frame_rate);
printf(" GOP: %d\n", chn_attr.rc_attr.h264_cbr.gop);
printf(" GOP Mode: NORMAL_P\n");
printf(" I/P QP Delta: %d\n", chn_attr.gop_attr.normal_p.ip_qp_delta);
printf(" Buffer Size: %u bytes\n", chn_attr.venc_attr.buf_size);
// 4. 创建编码通道 (通道号0)
printf("\nStep 4: Creating VENC channel 0...\n");
ret = ss_mpi_venc_create_chn(0, &chn_attr);
if (ret == TD_SUCCESS) {
printf("✓ SUCCESS: VENC channel 0 created successfully!\n");
// 5. 这里可以进行编码操作...
printf(" Channel is ready for encoding\n");
printf(" You can now send frames and get encoded streams\n");
// 示例:保持通道一段时间,然后销毁
printf("\nWaiting 2 seconds (simulating encoding)...\n");
sleep(2);
// 6. 销毁通道
printf("Step 5: Destroying channel...\n");
ss_mpi_venc_destroy_chn(0);
printf("✓ Channel destroyed\n");
} else {
printf("✗ FAILED: VENC create failed with error: 0x%x\n", ret);
// 错误码解析
if (ret == 0xa0088007) {
printf(" Error: OT_ERR_VENC_ILLEGAL_PARAM (Illegal parameter)\n");
printf(" Possible issues:\n");
printf(" 1. Buffer size too small for 1080p\n");
printf(" 2. Unsupported resolution or profile\n");
printf(" 3. Invalid bitrate value\n");
}
}
// 7. 清理系统资源
printf("\nStep 6: Cleaning up system resources...\n");
ss_mpi_sys_exit();
ss_mpi_vb_exit();
printf("✓ System resources released\n");
return ret;
}
int main(int argc, char *argv[])
{
printf("=== H264 1080p Encoder Test ===\n");
// 运行示例
td_s32 ret = create_1080p_h264_venc_channel();
if (ret == TD_SUCCESS) {
printf("\n=== TEST PASSED ===\n");
} else {
printf("\n=== TEST FAILED ===\n");
}
return (ret == TD_SUCCESS) ? 0 : 1;
}
请帮忙看看
我来回答
回答3个
时间排序
认可量排序
认可1
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片
相关问答
-
2025-04-19 11:37:03
-
2026-01-13 18:14:32
-
2020-05-20 16:37:36
-
2025-02-11 11:59:39
-
2018-04-18 14:50:55
-
2025-02-13 15:42:34
-
2019-07-12 18:29:38
-
sample_venc运行报错[sample_comm_get_stream_from_one_channl]-2626: ss_mpi_venc_query_status chn[0] failed12025-11-21 11:32:54
-
2020-07-22 17:24:15
-
2025-01-06 18:27:15
-
2024-12-30 11:24:22
-
2016-08-01 09:32:42
-
2024-12-20 17:21:23
-
2020-03-17 18:14:42
-
2022-11-02 20:17:05
-
2020-07-23 17:45:58
-
2019-08-30 09:57:03
-
2013-12-13 17:48:20
-
2025-08-28 16:25:46
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
10hi35169dv500平台使用http协议推拉流UVC摄像头,帧率问题
-
10hi3516cv610关于YOLO优化和调优问题
-
10hi_mpi_vpss_get_chn_frame err:0xa0078016报错
-
5gk7205v200(hisi3516ev200)如何接入b656?
-
30pipe管道创建失败
-
10atc转换模型失败
-
20拍摄静止画面显示正常,拍摄运动的画面出现马赛克显示
-
100hi3516cv610 通过易百纳官方SDK中编译出的uboot env kernel,移植到自己的工程中,MPP初始化时出现内核拷贝数据到用户端时出现错误导致内核进入pain模式进而时内核重启
-
5hisi3519 gs2972 bt1120 转sdi 无法正常显示问题
-
5hisi3516cv610 + gc4336p 夜晚很模糊
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认

微信扫码分享
QQ好友