一套rk3588 rtsp服务器推流的 github 方案及记录 -03(完结)

opencv 解码记录

解码库使用的时候发现瑞芯微以前做过解码库对ffmpeg和gstreamer的支持
然后最近实在不想再调试Rtsp浪费时间了,就从这中间找了一个比较快的方案

ffmpeg 带硬解码库编译

编译流程参考文献
https://blog.csdn.net/T__zxt/article/details/123424359
编译的ffmpeg是这个版本
https://github.com/jjm2473

安装了下面这些东西:

sudo apt-get -y install \autoconf \automake \build-essential \cmake \git-core \libass-dev \libfreetype6-dev \libsdl2-dev \libtool \libva-dev \libvdpau-dev \libvorbis-dev \libxcb1-dev \libxcb-shm0-dev \libxcb-xfixes0-dev \pkg-config \texinfo \wget \zlib1g-dev

编译选项参考的是这哥们的语句:
https://www.reddit.com/r/OrangePI/comments/14f725v/comment/jpcezy2/?context=3
下面这句话,哪个不能用删哪个,一定要有的是 --enable-rkmpp

./configure --enable-nonfree --enable-gpl --enable-version3 --enable-libx264 --enable-libdrm --enable-rkmpp --enable-librtmp --enable-shared --enable-static --enable-librga --enable-libx265 --enable-libmp3lame --enable-libpulse --enable-openssl --enable-libopus --enable-libvorbis
# 我最后用的 应该是sudo apt-get -y install   autoconf   automake   build-essential   cmake   git-core   libass-dev   libfreetype6-dev   libsdl2-dev   libtool   libva-dev   libvdpau-dev   libvorbis-dev   libxcb1-dev   libxcb-shm0-dev   libxcb-xfixes0-dev   pkg-config   texinfo   wget   zlib1g-dev  
./configure --enable-nonfree --enable-gpl --enable-version3 --enable-libx264 --enable-libdrm --enable-rkmpp  --enable-shared --enable-static --enable-librga --enable-libx265  --enable-libpulse --enable-openssl --enable-libvorbis

使用板上编译的时候记得多等一会,有点慢,不要急

编译出来的结果需要使用下面的语句去看ffmpeg是否正常

ffmpeg -decoders |grep h264

如果编译之后,ffmpeg不支持,
修改

sudo vim /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
/usr/local/lib

打开之前ldd看一眼是不是所有的链接库都找到地方了

ffmpeg-rk-enc-5.1$ ldd ffmpeglinux-vdso.so.1 (0x0000007fbb328000)libavdevice.so.59 => /usr/local/lib/libavdevice.so.59 (0x0000007fbb230000)libavfilter.so.8 => /usr/local/lib/libavfilter.so.8 (0x0000007fbae60000)libavformat.so.59 => /usr/local/lib/libavformat.so.59 (0x0000007fbabe0000)libavcodec.so.59 => /usr/local/lib/libavcodec.so.59 (0x0000007fb9ae0000)libpostproc.so.56 => /usr/local/lib/libpostproc.so.56 (0x0000007fb9ac0000)libswresample.so.4 => /usr/local/lib/libswresample.so.4 (0x0000007fb9a90000)libswscale.so.6 => /usr/local/lib/libswscale.so.6 (0x0000007fb9a10000)libavutil.so.57 => /usr/local/lib/libavutil.so.57 (0x0000007fb9830000)libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007fb9790000)libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007fb95e0000)/lib/ld-linux-aarch64.so.1 (0x0000007fbb2ef000)libdrm.so.2 => /lib/aarch64-linux-gnu/libdrm.so.2 (0x0000007fb95b0000)libxcb.so.1 => /lib/aarch64-linux-gnu/libxcb.so.1 (0x0000007fb9570000)libxcb-shm.so.0 => /lib/aarch64-linux-gnu/libxcb-shm.so.0 (0x0000007fb9550000)libxcb-shape.so.0 => /lib/aarch64-linux-gnu/libxcb-shape.so.0 (0x0000007fb9530000)libxcb-xfixes.so.0 => /lib/aarch64-linux-gnu/libxcb-xfixes.so.0 (0x0000007fb9510000)libasound.so.2 => /lib/aarch64-linux-gnu/libasound.so.2 (0x0000007fb93f0000)libpulse.so.0 => /lib/aarch64-linux-gnu/libpulse.so.0 (0x0000007fb9390000)libSDL2-2.0.so.0 => /lib/aarch64-linux-gnu/libSDL2-2.0.so.0 (0x0000007fb91f0000)libsndio.so.7 => /lib/aarch64-linux-gnu/libsndio.so.7 (0x0000007fb91c0000)libXv.so.1 => /lib/aarch64-linux-gnu/libXv.so.1 (0x0000007fb91a0000)libX11.so.6 => /lib/aarch64-linux-gnu/libX11.so.6 (0x0000007fb9050000)libXext.so.6 => /lib/aarch64-linux-gnu/libXext.so.6 (0x0000007fb9020000)libavrkmpp.so.1 => /usr/local/lib/libavrkmpp.so.1 (0x0000007fb9000000)libva.so.2 => /lib/aarch64-linux-gnu/libva.so.2 (0x0000007fb8fc0000)libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000007fb8f90000)libssl.so.3 => /lib/aarch64-linux-gnu/libssl.so.3 (0x0000007fb8ee0000)libcrypto.so.3 => /lib/aarch64-linux-gnu/libcrypto.so.3 (0x0000007fb8af0000)liblzma.so.5 => /lib/aarch64-linux-gnu/liblzma.so.5 (0x0000007fb8ab0000)librockchip_mpp.so.1 => /lib/aarch64-linux-gnu/librockchip_mpp.so.1 (0x0000007fb88b0000)libvorbis.so.0 => /lib/aarch64-linux-gnu/libvorbis.so.0 (0x0000007fb8870000)libvorbisenc.so.2 => /lib/aarch64-linux-gnu/libvorbisenc.so.2 (0x0000007fb87b0000)libx264.so.163 => /lib/aarch64-linux-gnu/libx264.so.163 (0x0000007fb8560000)libx265.so.199 => /lib/aarch64-linux-gnu/libx265.so.199 (0x0000007fb82a0000)librga.so.2 => /lib/aarch64-linux-gnu/librga.so.2 (0x0000007fb8270000)libva-drm.so.2 => /lib/aarch64-linux-gnu/libva-drm.so.2 (0x0000007fb8250000)libva-x11.so.2 => /lib/aarch64-linux-gnu/libva-x11.so.2 (0x0000007fb8230000)libvdpau.so.1 => /lib/aarch64-linux-gnu/libvdpau.so.1 (0x0000007fb8210000)libXau.so.6 => /lib/aarch64-linux-gnu/libXau.so.6 (0x0000007fb81f0000)libXdmcp.so.6 => /lib/aarch64-linux-gnu/libXdmcp.so.6 (0x0000007fb81d0000)libpulsecommon-15.99.so => /usr/lib/aarch64-linux-gnu/pulseaudio/libpulsecommon-15.99.so (0x0000007fb8140000)libdbus-1.so.3 => /lib/aarch64-linux-gnu/libdbus-1.so.3 (0x0000007fb80e0000)libXcursor.so.1 => /lib/aarch64-linux-gnu/libXcursor.so.1 (0x0000007fb80c0000)libXinerama.so.1 => /lib/aarch64-linux-gnu/libXinerama.so.1 (0x0000007fb80a0000)libXi.so.6 => /lib/aarch64-linux-gnu/libXi.so.6 (0x0000007fb8070000)libXfixes.so.3 => /lib/aarch64-linux-gnu/libXfixes.so.3 (0x0000007fb8050000)libXrandr.so.2 => /lib/aarch64-linux-gnu/libXrandr.so.2 (0x0000007fb8030000)libXss.so.1 => /lib/aarch64-linux-gnu/libXss.so.1 (0x0000007fb8010000)libXxf86vm.so.1 => /lib/aarch64-linux-gnu/libXxf86vm.so.1 (0x0000007fb7ff0000)libgbm.so.1 => /lib/aarch64-linux-gnu/libgbm.so.1 (0x0000007fb7fd0000)libwayland-egl.so.1 => /lib/aarch64-linux-gnu/libwayland-egl.so.1 (0x0000007fb7fb0000)libwayland-client.so.0 => /lib/aarch64-linux-gnu/libwayland-client.so.0 (0x0000007fb7f90000)libwayland-cursor.so.0 => /lib/aarch64-linux-gnu/libwayland-cursor.so.0 (0x0000007fb7f70000)libxkbcommon.so.0 => /lib/aarch64-linux-gnu/libxkbcommon.so.0 (0x0000007fb7f10000)libdecor-0.so.0 => /lib/aarch64-linux-gnu/libdecor-0.so.0 (0x0000007fb7ef0000)libbsd.so.0 => /lib/aarch64-linux-gnu/libbsd.so.0 (0x0000007fb7ec0000)libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007fb7c90000)libogg.so.0 => /lib/aarch64-linux-gnu/libogg.so.0 (0x0000007fb7c70000)libnuma.so.1 => /lib/aarch64-linux-gnu/libnuma.so.1 (0x0000007fb7c40000)libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007fb7c10000)libsndfile.so.1 => /lib/aarch64-linux-gnu/libsndfile.so.1 (0x0000007fb7b80000)libX11-xcb.so.1 => /lib/aarch64-linux-gnu/libX11-xcb.so.1 (0x0000007fb7b60000)libsystemd.so.0 => /lib/aarch64-linux-gnu/libsystemd.so.0 (0x0000007fb7a80000)libasyncns.so.0 => /lib/aarch64-linux-gnu/libasyncns.so.0 (0x0000007fb7a60000)libapparmor.so.1 => /lib/aarch64-linux-gnu/libapparmor.so.1 (0x0000007fb7a30000)libXrender.so.1 => /lib/aarch64-linux-gnu/libXrender.so.1 (0x0000007fb7a10000)libwayland-server.so.0 => /lib/aarch64-linux-gnu/libwayland-server.so.0 (0x0000007fb79e0000)libexpat.so.1 => /lib/aarch64-linux-gnu/libexpat.so.1 (0x0000007fb79a0000)libffi.so.8 => /lib/aarch64-linux-gnu/libffi.so.8 (0x0000007fb7980000)libmd.so.0 => /lib/aarch64-linux-gnu/libmd.so.0 (0x0000007fb7960000)libFLAC.so.8 => /lib/aarch64-linux-gnu/libFLAC.so.8 (0x0000007fb7910000)libopus.so.0 => /lib/aarch64-linux-gnu/libopus.so.0 (0x0000007fb78a0000)libzstd.so.1 => /opt/ros/humble/lib/libzstd.so.1 (0x0000007fb7810000)liblz4.so.1 => /lib/aarch64-linux-gnu/liblz4.so.1 (0x0000007fb77e0000)libcap.so.2 => /lib/aarch64-linux-gnu/libcap.so.2 (0x0000007fb77c0000)libgcrypt.so.20 => /lib/aarch64-linux-gnu/libgcrypt.so.20 (0x0000007fb76d0000)libgpg-error.so.0 => /lib/aarch64-linux-gnu/libgpg-error.so.0 (0x0000007fb7690000)

至此,编译好了一个支持硬件解码的ffmpeg,记得make install ,然后去编译opencv,让opencv支持ffmpeg

opencv编译带硬解码ffmpeg

原来的opencv是这样的:

OpenCV FFmpeg version: 
General configuration for OpenCV 4.5.5 =====================================Version control:               unknownPlatform:Timestamp:                   2023-09-25T04:22:20ZHost:                        Linux 5.10.110-rockchip-rk3588 aarch64CMake:                       3.22.1CMake generator:             Unix MakefilesCMake build tool:            /usr/bin/gmakeConfiguration:               ReleaseCPU/HW features:Baseline:                    NEON FP16C/C++:Built as dynamic libs?:      YESC++ standard:                11C++ Compiler:                /usr/bin/c++  (ver 11.4.0)C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUGC++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUGC Compiler:                  /usr/bin/ccC flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUGC flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUGLinker flags (Release):      -Wl,--gc-sections -Wl,--as-needed  Linker flags (Debug):        -Wl,--gc-sections -Wl,--as-needed  ccache:                      NOPrecompiled headers:         NOExtra dependencies:          dl m pthread rt3rdparty dependencies:OpenCV modules:To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo python3 stitching ts video videoioDisabled:                    worldDisabled by dependency:      -Unavailable:                 java python2Applications:                tests perf_tests appsDocumentation:               NONon-free algorithms:         NOGUI:                           QT5QT:                          YES (ver 5.15.3 )QT OpenGL support:         YES (Qt5::OpenGL 5.15.3)GTK+:                        YES (ver 3.24.33)GThread :                  YES (ver 2.72.4)GtkGlExt:                  NOOpenGL support:              YES (/usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so)VTK support:                 YES (ver 9.1.0)Media I/O: ZLib:                        /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)JPEG:                        /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)WEBP:                        /usr/lib/aarch64-linux-gnu/libwebp.so (ver encoder: 0x020f)PNG:                         /lib/libpng.so (ver 1.6.37)TIFF:                        /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.3.0)JPEG 2000:                   OpenJPEG (ver 2.4.0)OpenEXR:                     /usr/lib/aarch64-linux-gnu/libImath-2_5.so /usr/lib/aarch64-linux-gnu/libIlmImf-2_5.so /usr/lib/aarch64-linux-gnu/libIex-2_5.so /usr/lib/aarch64-linux-gnu/libHalf-2_5.so /usr/lib/aarch64-linux-gnu/libIlmThread-2_5.so (ver 2_5)HDR:                         YESSUNRASTER:                   YESPXM:                         YESPFM:                         YESVideo I/O:DC1394:                      YES (2.2.6)FFMPEG:                      YESavcodec:                   YES (58.134.100)avformat:                  YES (58.76.100)avutil:                    YES (56.70.100)swscale:                   YES (5.9.100)avresample:                NOGStreamer:                   YES (1.20.3)v4l/v4l2:                    YES (linux/videodev2.h)Parallel framework:            pthreadsTrace:                         YES (with Intel ITT)Other third-party libraries:Lapack:                      NOEigen:                       YES (ver 3.4.0)Custom HAL:                  YES (carotene (ver 0.0.1))Protobuf:                    build (3.19.1)OpenCL:                        YES (no extra features)Include path:                /home/orangepi/opencv-4.5.5/3rdparty/include/opencl/1.2Link libraries:              Dynamic loadPython 3:Interpreter:                 /usr/bin/python3 (ver 3.10.12)Libraries:                   /usr/lib/aarch64-linux-gnu/libpython3.10.so (ver 3.10.12)numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.21.5)install path:                lib/python3.10/dist-packages/cv2/python-3.10Python (for build):            /usr/bin/python2.7Java:                          ant:                         NOJNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/includeJava wrappers:               NOJava tests:                  NOInstall to:                    /usr/local

opencv 4.5.5来讲,这个ffmpeg太新了,编译不过。只能以毒攻毒,去下了opencv4.8.0
回头把这个打包上传到csdn资源,防止它小更新不能用
4.8.0是编译通过的
一样也是板端编译,cmake-gui配置,然后去build文件夹下面 make make install
参考文献:
https://blog.csdn.net/Flag_ing/article/details/109508374
注意 ,如果使用qt,一定要把qt勾选,否则在qt里运行会报错
还有opencl他也不是自动勾选的
在这里插入图片描述

在这里插入图片描述

其他的应该随意
然后去创建工程使用、测试opencv是不是能正常用

测试代码

// RTSP Server#include "xop/RtspServer.h"
#include "net/Timer.h"
#include <thread>
#include <memory>
#include <iostream>
#include <string>#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>// 编码库 
#include <encoder.h>
// 解码库
#include <decoder.h>
// 海康拉流库
#include "HCNetSDK.h"
#include <chrono>
#include "yolo.h"
// 查看264 二进制 文件
#include <sstream>
#include <fstream>using namespace std;
using namespace cv;
// 定义一个缓冲池结构体
struct Buffer {Mat buf1;Mat buf2;
};// 定义互斥锁
std::mutex mymutex;
Buffer matBuf;
VideoCapture videocapture;
int captureOpen = 0;
/*** @brief 读图* * @return Mat */
Mat captureThread()
{string rtspIN =   "rtsp://admin:s745112822@192.168.2.110:554/h264/ch0/main/av_stream";if (captureOpen == 0 ){	videocapture.open(rtspIN,CAP_FFMPEG);captureOpen = 1;//打开图像// capture.open(url);}while (1){//加锁mymutex.lock();// buf2->buf1if(matBuf.buf1.empty())videocapture.read(matBuf.buf1); else if(matBuf.buf2.empty())videocapture.read(matBuf.buf2);else{matBuf.buf1 = matBuf.buf2;videocapture.read(matBuf.buf2);}// 没有读到数据 网络问题 重启rtspif(matBuf.buf1.empty()){videocapture.release();videocapture.open(rtspIN,CAP_FFMPEG);}//读图成功// imgready = true;//解锁mymutex.unlock();xop::Timer::Sleep(10);}
}void writeCharPointerToFile(const char* data, std::size_t size, const std::string& filename) {// 打开文件std::ofstream file(filename, ios::binary);// 检查文件是否成功打开if (!file.is_open()) {std::cerr << "无法打开文件: " << filename << std::endl;return;}// 写入数据file.write(data, size);// 关闭文件file.close();
}bool IsKeyFrame(const char* data, uint32_t size)
{if (size > 4) {//0x67:sps ,0x65:IDR, 0x6: SEIif (data[4] == 0x67 || data[4] == 0x65 || data[4] == 0x6 || data[4] == 0x27) {return true;}}return false;
}
// encoder e ;void SendFrameThread(xop::RtspServer* rtsp_server, xop::MediaSessionId session_id, int& clients);int main(int argc, char **argv)
{	// 读图线程 thread t1(captureThread);int clients = 1;std::string ip = "0.0.0.0";std::string rtsp_url = "rtsp://127.0.0.1:5514/live";// e.init();std::shared_ptr<xop::EventLoop> event_loop(new xop::EventLoop());  std::shared_ptr<xop::RtspServer> server = xop::RtspServer::Create(event_loop.get());if (!server->Start(ip, 5514)) {return -1;}#ifdef AUTH_CONFIGserver->SetAuthConfig("-_-", "admin", "12345");
#endifxop::MediaSession *session = xop::MediaSession::CreateNew("live"); // url: rtsp://ip/livesession->AddSource(xop::channel_0, xop::H264Source::CreateNew()); session->AddSource(xop::channel_1, xop::AACSource::CreateNew(44100,2));// session->startMulticast(); /* 开启组播(ip,端口随机生成), 默认使用 RTP_OVER_UDP, RTP_OVER_RTSP */session->AddNotifyConnectedCallback([] (xop::MediaSessionId sessionId, std::string peer_ip, uint16_t peer_port){printf("RTSP client connect, ip=%s, port=%hu \n", peer_ip.c_str(), peer_port);});session->AddNotifyDisconnectedCallback([](xop::MediaSessionId sessionId, std::string peer_ip, uint16_t peer_port) {printf("RTSP client disconnect, ip=%s, port=%hu \n", peer_ip.c_str(), peer_port);});std::cout << "URL: " << rtsp_url << std::endl;xop::MediaSessionId session_id = server->AddSession(session); //server->removeMeidaSession(session_id); /* 取消会话, 接口线程安全 */std::thread thread(SendFrameThread, server.get(), session_id, std::ref(clients));thread.detach();while(1) {xop::Timer::Sleep(100);}getchar();return 0;
}void SendFrameThread(xop::RtspServer* rtsp_server, xop::MediaSessionId session_id, int& clients)
{       encoder e;// decoder d;// cv::VideoCapture *videocapture = new cv::VideoCapture(0);// std::string rtspIN = "rtsp://admin:s745112822@192.168.2.110:554/h264/ch1/sub/av_stream";// yolo处理// char* modelname = "/home/orangepi/code/realsense/cap2/yolov5s-640-640.rknn";// yolo yolo5;// yolo5.load_model(modelname);//   yolo5.model_init();
//  decoder相关 结果回传// d.init();std::vector<cv::Mat> resultArray;int lenofmat = 0;
//  encoder相关 内存拷贝int size = 0;char* buffer ;cv::Mat colorBar;int i = 0;while(1){if(clients > 0) /* 会话有客户端在线, 发送音视频数据 */{{     xop::AVFrame videoFrame = {0};// opencv 拿图 后续需要优化auto start_time = std::chrono::high_resolution_clock::now();			// videocapture->read(colorBar); // 拿图 while(matBuf.buf1.empty());mymutex.lock();colorBar = matBuf.buf1;matBuf.buf1 = matBuf.buf2;matBuf.buf2.release();mymutex.unlock();auto end_time1 = std::chrono::high_resolution_clock::now();// d.poststream("264stream pointer",lenofmat,resultArray);// printf("width is %d, height is %d",colorBar.rows,colorBar.cols);// yolo 处理// yolo5.load_Mat(colorBar);// yolo5.run();// colorBar = yolo5.getPicResult();auto end_time2 = std::chrono::high_resolution_clock::now();if(0==i){// 第一帧有sps信息 给他两帧拼一起char *buffer1;int size1;e.init(buffer1,size1);videoFrame.size = size1;e.postAframe(colorBar,buffer,size);videoFrame.size += size;					videoFrame.buffer.reset(new uint8_t[videoFrame.size]);memcpy(videoFrame.buffer.get(), buffer1, size1);memcpy(videoFrame.buffer.get()+size1, buffer, size);i++;}		else{e.postAframe(colorBar,buffer,size);videoFrame.size = size;  // 视频帧大小 videoFrame.buffer.reset(new uint8_t[videoFrame.size]);memcpy(videoFrame.buffer.get(), buffer, videoFrame.size);}auto end_time3 = std::chrono::high_resolution_clock::now();auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time1 - start_time);cout<<"===============================A==frame================================================="<<endl;cout << "decode mat took: " << duration.count() <<"ms\r\n";duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time2 - end_time1);cout << "rknn took: " << duration.count() <<"ms\r\n";duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time3 - end_time2);cout << "encode took: " << duration.count() <<"ms\r\n";videoFrame.type = IsKeyFrame(buffer, size) ? xop::VIDEO_FRAME_I : xop::VIDEO_FRAME_P;// videoFrame.type = 0; // 建议确定帧类型。I帧(xop::VIDEO_FRAME_I) P帧(xop::VIDEO_FRAME_P)videoFrame.timestamp = xop::H264Source::GetTimestamp(); // 时间戳, 建议使用编码器提供的时间戳// writeCharPointerToFile((char *)videoFrame.buffer.get(), videoFrame.size,  "filename.txt");		rtsp_server->PushFrame(session_id, xop::channel_0, videoFrame); //送到服务器进行转发, 接口线程安全/*//获取一帧 H264, 打包xop::AVFrame videoFrame = {0};videoFrame.type = 0; // 建议确定帧类型。I帧(xop::VIDEO_FRAME_I) P帧(xop::VIDEO_FRAME_P)videoFrame.size = video frame size;  // 视频帧大小 videoFrame.timestamp = xop::H264Source::GetTimestamp(); // 时间戳, 建议使用编码器提供的时间戳videoFrame.buffer.reset(new uint8_t[videoFrame.size]);                    memcpy(videoFrame.buffer.get(), video frame data, videoFrame.size);					rtsp_server->PushFrame(session_id, xop::channel_0, videoFrame); //送到服务器进行转发, 接口线程安全*/}{				/*//获取一帧 AAC, 打包xop::AVFrame audioFrame = {0};audioFrame.type = xop::AUDIO_FRAME;audioFrame.size = audio frame size;  /* 音频帧大小 audioFrame.timestamp = xop::AACSource::GetTimestamp(44100); // 时间戳audioFrame.buffer.reset(new uint8_t[audioFrame.size]);                    memcpy(audioFrame.buffer.get(), audio frame data, audioFrame.size);rtsp_server->PushFrame(session_id, xop::channel_1, audioFrame); // 送到服务器进行转发, 接口线程安全*/}		}// xop::Timer::Sleep(20);  /* 实际使用需要根据帧率计算延时! */}videocapture.release();e.deinit((MPP_RET)0);// d.deinit();// yolo5.deinit();}

至此 一帧图片怎么都能推出去了

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/226279.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

2023年12月27日学习记录_加入噪声

目录 1、今日计划学习内容2、今日学习内容1、add noise to audio clipssignal to noise ratio(SNR)加入 additive white gaussian noise(AWGN)加入 real world noises 2、使用kaggel上的一个小demo&#xff1a;CNN模型运行时出现的问题调整采样率时出现bug 3、明确90dB下能否声…

每日一题--------求数字的每⼀位之和

大家好今天的每日一题又来了&#xff0c;有啥不对的请在评论区留言哦 文章目录 目录 文章目录 求数字的每⼀位之和 题⽬描述&#xff1a; 输⼊⼀个整数m&#xff0c;求这个整数m的每⼀位之和&#xff0c;并打印。 一、解题思路 我们可以通过不断获取该整数的个位数&#xff0c…

Redis中RDB和AOF

Redis中RDB和AOF 定时间间隔执行数据集的时间快照&#xff0c;把某一时刻数据和妆容以文件的形式写到磁盘上&#xff0c;也就是快照。 配置文件 如果是普通安装方式可以跳过&#xff0c;如果是docker安装&#xff0c;需要到官网下载redis.conf配置文件到本地&#xff0c;地址…

接口自动化测试问题汇总

本篇文章分享几个接口自动化用例编写过程遇到的问题总结&#xff0c;希望能对初次探索接口自动化测试的小伙伴们解决问题上提供一小部分思路。 sql语句内容出现错误 空格&#xff1a;由于有些字段判断是变量&#xff0c;需要将sql拼接起来&#xff0c;但是在拼接字符串时没有…

2022 年全国职业院校技能大赛高职组云计算正式赛卷第二场-容器云

2022 年全国职业院校技能大赛高职组云计算赛项试卷 云计算赛项第二场-容器云 目录 2022 年全国职业院校技能大赛高职组云计算赛项试卷 【赛程名称】云计算赛项第二场-容器云 【任务 1】容器云平台搭建[5 分] 【任务 2】容器云应用部署&#xff1a; Docker Compose 编排部署[7.0…

9_js_dom编程进阶3

Dom节点删除和复制操作事件加强讲解 1. 节点操作 1.1 删除节点 Node.removeChild() 方法从 DOM 中删除一个子节点。返回删除的节点。 child 是要移除的那个子节点。 node 是child的父节点。 PS&#xff1a;只能由父节点删除子节点 课堂案例&#xff1a;1.节点操作之删除节…

【深度学习】各领域常用的损失函数汇总(2024最新版)

目录 1、L1 损失、平均绝对误差&#xff08;L1 Loss、Mean Absolute Error&#xff0c;MAE&#xff09; 2、L2 损失、均方误差&#xff08;L2 Loss、Mean Squared Error&#xff0c;MSE&#xff09; 3、交叉熵损失&#xff08;Cross-Entropy Loss&#xff09; 4、混合损失&…

VuePress、VuePress-theme-hope 搭建个人博客 1【快速上手】 —— 防止踩坑篇

vuePress官网地址 &#x1f449; 首页 | VuePress 手动安装 这一章节会帮助你从头搭建一个简单的 VuePress 文档网站。如果你想在一个现有项目中使用 VuePress 管理文档&#xff0c;从步骤 3 开始。 步骤 1: 创建并进入一个新目录 mkdir vuepress-starter cd vuepress-star…

基于鸿蒙OS开发一个前端应用

创建JS工程&#xff1a;做鸿蒙应用开发到底学习些啥&#xff1f; 若首次打开DevEco Studio&#xff0c;请点击Create Project创建工程。如果已经打开了一个工程&#xff0c;请在菜单栏选择File > New > Create Project来创建一个新工程。选择HarmonyOS模板库&#xff0c…

在微服务中如何实现全链路的金丝雀发布?

目录 1. 什么金丝雀发布&#xff1f;它有什么用&#xff1f; 2.如何实现全链路的金丝雀发布 2.1 负载均衡模块 2.2 网关模块 2.3 服务模块 2.3.1 注册为灰色服务实例 2.3.2 设置负载均衡器 2.3.3 传递灰度发布标签 2.4 其他代码 2.4.1 其他业务代码 2.4.2 pom.xml 关…

TrustZone之可信操作系统

有许多可信内核&#xff0c;包括商业和开源的。一个例子是OP-TEE&#xff0c;最初由ST-Ericsson开发&#xff0c;但现在是由Linaro托管的开源项目。OP-TEE提供了一个功能齐全的可信执行环境&#xff0c;您可以在OP-TEE项目网站上找到详细的描述。 OP-TEE的结构如下图所示&…

申请sectigo和certum的IP证书注意事项

IP数字证书可以为只有公网IP地址的站点提供网站传输信息加密服务&#xff0c;一方面可以消除用户在浏览器访问网站时的“不安全”提示&#xff0c;另一方面现在主流浏览器会优先收录安装了数字证书的网站&#xff0c;为公网IP地址网站安装IP证书有利于提升网站SEO&#xff08;搜…

数据结构学习 Leetcode474 一和零

关键词&#xff1a;动态规划 01背包 一个套路&#xff1a; 01背包&#xff1a;空间优化之后dp【target1】&#xff0c;遍历的时候要逆序遍历完全背包&#xff1a;空间优化之后dp【target1】&#xff0c;遍历的时候要正序遍历 目录 题目&#xff1a; 思路&#xff1a; 复杂…

Seata 中封装了四种分布式事务模式,分别是: AT 模式, TCC 模式, Saga 模式, XA 模式,

文章目录 seata概述Seata 中封装了四种分布式事务模式&#xff0c;分别是&#xff1a;AT 模式&#xff0c;TCC 模式&#xff0c;Saga 模式&#xff0c;XA 模式&#xff0c; 今天我们来聊聊seata seata 概述 在微服务架构下&#xff0c;由于数据库和应用服务的拆分&#xff0c…

Vue3-27-路由-路径参数的简单使用

什么是路径参数 在路由配置中&#xff0c;可以将【参数】放在【路由路径】中&#xff0c; 从而实现&#xff0c;同一个 路由&#xff0c;同一个组件&#xff0c;因路径参数不同&#xff0c;可以渲染出不同的内容。特点 &#xff1a; 1、当携带不同路径参数的路由相互跳转时&am…

React 路由

引言 在我们之前写的页面当中&#xff0c;用我们的惯用思维去思考的话&#xff0c;可能会需要写很多的页面&#xff0c;例如做一个 tab 栏&#xff0c;我们可能会想每个选项都要对应一个 HTML 文件&#xff0c;这样会很麻烦&#xff0c;甚至不友好&#xff0c;我们把这种称为 …

把这些软件测试经典面试题!全背下来,拿offer就像喝水一样!

1、什么是兼容性测试&#xff1f;兼容性测试侧重哪些方面&#xff1f; 兼容测试主要是检查软件在不同的硬件平台、软件平台上是否可以正常的运行&#xff0c;即是通常说的软件的可移植性。兼容的类型&#xff0c;如果细分的话&#xff0c;有平台的兼容&#xff0c;网络兼容&am…

SpingBoot的项目实战--模拟电商【2.登录】

&#x1f973;&#x1f973;Welcome Huihuis Code World ! !&#x1f973;&#x1f973; 接下来看看由辉辉所写的关于SpringBoot电商项目的相关操作吧 目录 &#x1f973;&#x1f973;Welcome Huihuis Code World ! !&#x1f973;&#x1f973; 一.功能需求 二.代码编写 …

Illustrator脚本 #015 自动角线

这是一个在画板上自动生成辅助线和角线的脚本&#xff0c;只要单击最右边按钮运行脚本即可。 绿色的为参考线及出血线。 #target "Illustrator" var settings {addTrim : true,addBleedGuide : true,addCenterGuide : true,addCover : false,overlapAlert : false,…

GameFi 2024年或将迎来新的爆发!

在数字时代&#xff0c;游戏已经不仅仅是一种娱乐方式&#xff0c;更是一种跨越现实和虚拟界限的全球性文化现象。而游戏金融&#xff08;GameFi&#xff09;正是这场数字革命的下一个巨大风潮。 随着科技的不断发展和创新&#xff0c;2024年&#xff0c;GAMEFI&#xff08;Gam…