Page 1 of 1

用RKMPI 实例的程序修改成一个录制视频保存的功能,出来没数据

Posted: 2024-06-04 3:02
by 牛腩焖薯仔
日志如下:
# ./luckfox_rtsp_opencv3
rkaiq log level ff0
ID: 0, sensor_name is m00_b_sc3336 4-0030, iqfiles is /etc/iqfiles
rk_aiq_uapi2_sysctl_init/prepare succeed
rk_aiq_uapi2_sysctl_start succeed
rockit log path (null), log_size = 0, can use export rt_log_path=, export rt_log_size= change
log_file = (nil)
RTVersion 00:01:54-353 {dump :064} ------------------------------- --------------------------
RTVersion 00:01:54-358 {dump :065} rockit version: git-8cb4d25b8 T ue Feb 28 11:12:39 2023 +0800
RTVersion 00:01:54-358 {dump :066} rockit building: built- 2023-02 -28 15:23:19
RTVersion 00:01:54-358 {dump :067} ------------------------------- --------------------------
(null) 00:01:54-358 {log_level_init :203}

please use echo name=level > /tmp/rt_log_level set log level
name: all cmpi mb sys vdec venc rgn vpss vgs tde avs wbc vo vi ai ao aenc adec
log_level: 0 1 2 3 4 5 6

rockit default level 4, can use export rt_log_level=x, x=0,1,2,3,4,5,6 change
(null) 00:01:54-360 {read_log_level :093} text is all=4
(null) 00:01:54-360 {read_log_level :095} module is all, log_level is 4
RKSockServer 00:01:54-363 {initNetServer :088} bind failed, reason: Address al ready in use
(null) 00:01:54-367 {monitor_log_level :144} #Start monitor_log_level thread , arg:(nil)
RTIsp3x 00:01:54-375 {ispInitDevice :208} sensor name = m00_b_sc3336 4-00 30
RTIsp3x 00:01:54-377 {ispInitDevice :211} sensor_index = 0
RTIsp3x 00:01:54-383 {ispInitDevice :208} sensor name = m00_b_sc3336 4-00 30
RTIsp3x 00:01:54-386 {ispInitDevice :211} sensor_index = 0
vi_dev_init
RKViDev 00:01:54-395 {vi_set_dev_attr :440} VI_DEV_ATTR_S all parameter res erved
=== VI ATTRS INFO: ===
devId : 0
chnId : 0
buffcnt: 0
buffSize: 0
width: 0
height: 0
Maxwidth: 0
Maxwidth: 0
streaming: 0
RKViChn 00:01:54-403 {prepareRuntime :334} ------------------------------- --------------------------
RKViChn 00:01:54-403 {prepareRuntime :336} vi version: 1.86, name:vvi
RKViChn 00:01:54-405 {prepareRuntime :337} rockit-ko version: vmpi:fb2eed2 be49e
RKViChn 00:01:54-405 {prepareRuntime :338} rockit-ko building: -2023-02-09 -11:04:49
RKViChn 00:01:54-405 {prepareRuntime :339} ------------------------------- --------------------------
RKViChn 00:01:54-406 {prepareRuntime :358} mb pool create success, MBCnt= 2
cmpi 00:01:54-407 {createRuntime :546} [non-WRAP MODE]: buff size = 51 8400
RTIsp3x 00:01:54-410 {ispInitDevice :208} sensor name = m00_b_sc3336 4-00 30
RTIsp3x 00:01:54-413 {ispInitDevice :211} sensor_index = 0
RTDeviceV4L2 00:01:54-416 {open :138} open video name(/dev/video11)
RKViChn 00:01:54-419 {setFrameRate :1153} [vi] dev(0) ch(0) illegal para m s32SrcFrameRate(0) s32DstFrameRate(0)
RTDeviceV4L2 00:01:54-421 {ispCameraInfo :549} current device:/dev/video11 isn 't compatible(cap:0x84201000) device,memoryType:4, retry:0
RTDeviceV4L2 00:01:54-424 {ispInitFormat :726} ioctl VIDIOC_S_FMT OK
RKViChn 00:01:54-424 {start :813} =========== vi Start startRunti me ===========
RTDeviceV4L2 00:01:54-424 {ispStreamOn :440} do ispStreamOn start
RTDeviceV4L2 00:01:54-444 {ispStreamOn :493} do ispStreamOn done
vpss_init
=== 0 ===
rga_api version 1.9.1_[0]
venc_init
MpiAdapterEncode 00:01:54-479 {ma_encode_create :1653} ringbuf buf_size 520192
=== 1 ===
====RK_MPI_SYS_Bind vpss0 to venc0====

main.cc程序
/*****************************************************************************
* | Author : 测试1
* | Function :
* | Info :
*
*----------------
* | This version: V1.0
* | Date : 2024-06-03
* | Info : Basic version
*
******************************************************************************/

#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <pthread.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/poll.h>
#include <time.h>
#include <unistd.h>
#include <vector>

#include "rtsp_demo.h"
#include "luckfox_mpi.h"

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main(int argc, char *argv[]) {
RK_S32 s32Ret = 0;

int sX,sY,eX,eY;
int width = 720;
int height = 480;


// rkaiq init
RK_BOOL multi_sensor = RK_FALSE;
const char *iq_dir = "/etc/iqfiles";
rk_aiq_working_mode_t hdr_mode = RK_AIQ_WORKING_MODE_NORMAL;
SAMPLE_COMM_ISP_Init(0, hdr_mode, multi_sensor, iq_dir);
SAMPLE_COMM_ISP_Run(0);

// rkmpi init
if (RK_MPI_SYS_Init() != RK_SUCCESS) {
RK_LOGE("rk mpi sys init fail!");
return -1;
}


// vi init
vi_dev_init();
vi_chn_init(0, width, height);

// vpss init
vpss_init(0, width, height);

// venc init
RK_CODEC_ID_E enCodecType = RK_VIDEO_ID_AVC;
venc_init(0, width, height, enCodecType);

//bind vpss to venc
MPP_CHN_S stSrcChn, stDestChn;
stSrcChn.enModId = RK_ID_VPSS;
stSrcChn.s32DevId = 0;
stSrcChn.s32ChnId = 0;

stDestChn.enModId = RK_ID_VENC;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = 0;
printf("====RK_MPI_SYS_Bind vpss0 to venc0====\n");
s32Ret = RK_MPI_SYS_Bind(&stSrcChn, &stDestChn);
if (s32Ret != RK_SUCCESS) {
RK_LOGE("bind vpss to venc failed");
return -1;
}
// 打开文件以保存编码后的视频流
FILE* fp = fopen("/mnt/sdcard/video/output.h264", "wb");
if (!fp) {
perror("fopen");
return -1;
}

while(1)
{
VENC_STREAM_S stFrame;
// 获取编码后的流并保存到文件
s32Ret = RK_MPI_VENC_GetStream(0, &stFrame, -1);
if (s32Ret == RK_SUCCESS) {
void* pData = RK_MPI_MB_Handle2VirAddr(stFrame.pstPack->pMbBlk);

if(fwrite(pData, 1, stFrame.pstPack->u32Len, fp) != stFrame.pstPack->u32Len){
perror("fwrite");
RK_MPI_VENC_ReleaseStream(0, &stFrame);
break;
}
RK_MPI_VENC_ReleaseStream(0,&stFrame);
}
else{
printf("RK_MPI_VENC_GetStream failed,s32Ret=%d\n",s32Ret);
}



}
//
fclose(fp);


RK_MPI_SYS_UnBind(&stSrcChn, &stDestChn);

RK_MPI_VI_DisableChn(0, 0);
RK_MPI_VI_DisableDev(0);

RK_MPI_VPSS_StopGrp(0);
RK_MPI_VPSS_DestroyGrp(0);

SAMPLE_COMM_ISP_Stop(0);

RK_MPI_VENC_StopRecvFrame(0);
RK_MPI_VENC_DestroyChn(0);


RK_MPI_SYS_Exit();

return 0;
}

Re: 用RKMPI 实例的程序修改成一个录制视频保存的功能,出来没数据

Posted: 2024-06-04 3:21
by Luckfox Taylor
    源码.png

    Re: 用RKMPI 实例的程序修改成一个录制视频保存的功能,出来没数据

    Posted: 2024-06-04 3:23
    by 牛腩焖薯仔
    Luckfox Taylor wrote: 2024-06-04 3:21
      源码.png
      我是想问这个运行卡在
      ====RK_MPI_SYS_Bind vpss0 to venc0====
      不动是我的程序问题还是板子内存问题

      Re: 用RKMPI 实例的程序修改成一个录制视频保存的功能,出来没数据

      Posted: 2024-07-05 7:01
      by simon
      牛腩焖薯仔 wrote: 2024-06-04 3:23
      Luckfox Taylor wrote: 2024-06-04 3:21
        源码.png
        我是想问这个运行卡在
        ====RK_MPI_SYS_Bind vpss0 to venc0====
        不动是我的程序问题还是板子内存问题
        我也遇到了一样的问题,请问你解决了吗?是如何解决的?