wangrong
2025-01-20 d4675814490906969a39daa3e79ac560fe705410
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
 
#include <string>
 
#include "vp_src_node.h"
 
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 {
    private:
        /* data */
        std::string ffmpeg_template = "ffmpeg -hwaccel cuda -i %s -f %s -pix_fmt %s pipe:%s" ;
        cv::VideoCapture rtsp_capture;
 
        std::vector<int> initialize_stream_properties() ;
 
    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();
 
        virtual std::string to_string() override;
 
        std::string rtsp_url;
 
        bool use_gpu = false;
 
        std::string ffmpeg_format = "rawvideo";
        std::string ffmpeg_pix_fmt = "yuv420p";
        // 0 means no skip
        int skip_interval = 0;
    };
}