From 02819b5c047bb354b0ef2374e7c6a6ac4bbd5bba Mon Sep 17 00:00:00 2001
From: wangrong <wangrong@shsening.com>
Date: 星期四, 23 一月 2025 11:42:36 +0800
Subject: [PATCH] add sample
---
nodes/vp_rtsp_ffmpeg_src_node.h | 36 ++++++++++++++++++++++--------------
1 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/nodes/vp_rtsp_ffmpeg_src_node.h b/nodes/vp_rtsp_ffmpeg_src_node.h
index 4331ff6..ea20c91 100644
--- a/nodes/vp_rtsp_ffmpeg_src_node.h
+++ b/nodes/vp_rtsp_ffmpeg_src_node.h
@@ -1,33 +1,41 @@
#pragma once
#include <string>
+#include <vector>
+#include <sstream>
+#include <iostream>
#include "vp_src_node.h"
-namespace vp_nodes {
+namespace vp_nodes
+{
// rtsp source node, receive video stream via rtsp protocal.
// example:
// rtsp://admin:admin12345@192.168.77.110:554/
- class vp_rtsp_ffmpeg_src_node: public vp_src_node {
+ class vp_rtsp_ffmpeg_src_node : public vp_src_node
+ {
private:
/* data */
- std::string ffmpeg_template = "ffmpeg -hwaccel cuda -i %s -f %s -pix_fmt %s pipe:%s" ;
+ std::string ffprobe_template = "ffprobe -v error -select_streams v:0 -show_entries stream=width,height,r_frame_rate -of csv=p=0 %s";
cv::VideoCapture rtsp_capture;
- std::vector<int> initialize_stream_properties() ;
+ std::vector<int> initialize_stream_properties();
+ int start_ffmpeg_thread(const std::string &rtsp_url, int width, int height);
+
protected:
// re-implemetation
virtual void handle_run() override;
+
public:
- vp_rtsp_ffmpeg_src_node(std::string node_name,
- int channel_index,
- std::string rtsp_url,
- float resize_ratio = 1.0,
- int skip_interval = 0,
- bool use_gpu = false,
- std::string ffmpeg_format = "rawvideo", // other options: avi/mp4/mov/mkv/flv/gif/h264/hevc
- std::string ffmpeg_pix_fmt= "yuv420p");
+ vp_rtsp_ffmpeg_src_node(std::string node_name,
+ int channel_index,
+ std::string rtsp_url,
+ float resize_ratio = 1.0,
+ int skip_interval = 0,
+ bool use_gpu = false,
+ std::string ffmpeg_format = "rawvideo", // other options: avi/mp4/mov/mkv/flv/gif/h264/hevc
+ std::string ffmpeg_pix_fmt = "bgr24"); // yuv420p 甯﹀灏忎竴鍗婏紝浣嗗仛detection 鏃惰繕闇�瑕佽浆鎹㈡垚bgr24
~vp_rtsp_ffmpeg_src_node();
virtual std::string to_string() override;
@@ -37,8 +45,8 @@
bool use_gpu = false;
std::string ffmpeg_format = "rawvideo";
- std::string ffmpeg_pix_fmt = "yuv420p";
+ std::string ffmpeg_pix_fmt = "bgr24";
// 0 means no skip
int skip_interval = 0;
};
-}
\ No newline at end of file
+}
--
Gitblit v1.9.1