wangrong
2025-01-23 02819b5c047bb354b0ef2374e7c6a6ac4bbd5bba
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
#pragma once
 
#include "vp_record_task.h"
 
namespace vp_nodes {
    // video record task, each task instance responsible for recording only 1 video file.
    // create multi instances if multi videos need to be record at the same time, and maintain these tasks in a list.
    class vp_video_record_task: public vp_record_task {
    private:
        // video writer
        cv::VideoWriter video_writer;
        // gst template
        std::string gst_template = "appsrc ! videoconvert ! x264enc bitrate=%d ! mp4mux ! filesink location=%s";
        
        int frames_already_record = -1;
        int frames_need_record = 0;
        int bitrate;
        int fps;
        int record_video_duration;
        int pre_record_video_duration;
 
    protected:
        // define how to record video
        virtual void record_task_run() override;
        // retrive .mp4 as file extension 
        virtual std::string get_file_ext() override;
    public:
        vp_video_record_task(int channel_index, 
                        std::deque<std::shared_ptr<vp_objects::vp_frame_meta>> pre_record_frames, 
                        std::string file_name_without_ext,
                        std::string save_dir,
                        bool auto_sub_dir,
                        bool osd,
                        vp_objects::vp_size resolution_w_h,
                        int bitrate,
                        int fps,
                        int pre_record_video_duration,
                        int record_video_duration,
                        std::string host_node_name = "host_node_not_specified",
                        bool auto_start = true);
        ~vp_video_record_task();
    };
}