首先, 根据文档, 接好摄像头, 我这个硬件是旧版本的, 两条线, 记住, 镜头朝上, fpc的金手指朝上, 如果发现接好电又开不了机, 说明接反了, 赶紧拔下来.

然后下载固件, 刷这个固件

基于rkmedia_vi_double_cameras_test.c 这个例程, 进行修改
// Copyright 2020 Fuzhou Rockchip Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <assert.h>
#include <fcntl.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "common/sample_common.h"
#include "librtsp/rtsp_demo.h"
#include "rkmedia_api.h"
#include <rga/RgaApi.h>
#include <rga/rga.h>
rtsp_demo_handle g_rtsplive = NULL;
static rtsp_session_handle g_rtsp_session;
static int video_width = 1920;
static int video_height = 1080;
static int disp_width = 3840; // 720;
static int disp_height = 1080; // 1280;
static bool quit = false;
static void sigterm_handler(int sig) {
fprintf(stderr, "signal %d\n", sig);
quit = true;
}
void video_packet_cb(MEDIA_BUFFER mb) {
static RK_S32 packet_cnt = 0;
if (quit)
return;
printf("#Get packet-%d, size %zu\n", packet_cnt, RK_MPI_MB_GetSize(mb));
if (g_rtsplive && g_rtsp_session) {
rtsp_tx_video(g_rtsp_session, RK_MPI_MB_GetPtr(mb), RK_MPI_MB_GetSize(mb),
RK_MPI_MB_GetTimestamp(mb));
rtsp_do_event(g_rtsplive);
}
RK_MPI_MB_ReleaseBuffer(mb);
packet_cnt++;
}
int main(void) {
int ret = 0;
// int ui = 1;
char *iq_dir = "/oem/etc/iqfiles";
// int ch;
// CODEC_TYPE_E enCodecType = RK_CODEC_TYPE_H264;
// 初始化isp, device 0跟1
ret = SAMPLE_COMM_ISP_Init(0, RK_AIQ_WORKING_MODE_NORMAL, RK_TRUE, iq_dir);
if (ret)
return -1;
SAMPLE_COMM_ISP_Run(0);
ret = SAMPLE_COMM_ISP_Init(1, RK_AIQ_WORKING_MODE_NORMAL, RK_TRUE, iq_dir);
if (ret)
return -1;
SAMPLE_COMM_ISP_Run(1);
SAMPLE_COMM_ISP_SetFrameRate(0, 30);
SAMPLE_COMM_ISP_SetFrameRate(1, 30);
// init rtsp
g_rtsplive = create_rtsp_demo(554);
g_rtsp_session = rtsp_new_session(g_rtsplive, "/live/main_stream");
rtsp_set_video(g_rtsp_session, RTSP_CODEC_ID_VIDEO_H264, NULL, 0);
rtsp_sync_video_ts(g_rtsp_session, rtsp_get_reltime(), rtsp_get_ntptime());
RK_MPI_SYS_Init();
VI_CHN_ATTR_S vi_chn_attr;
memset(&vi_chn_attr, 0, sizeof(vi_chn_attr)

该文描述了一个使用Rockchip平台处理双摄像头视频流的示例,包括摄像头连接、固件更新、RTSP流传输、图像处理和编码。代码实现了从两个摄像头获取NV12格式的视频,经过VMIX混合后编码为H264并推送到RTSP服务器的过程。
2403

被折叠的 条评论
为什么被折叠?



