Monitoring video pre-recording method, electronic equipment and storage medium
By detecting whether the video surveillance device is connected to an SD card and choosing to use an SD card or memory for pre-recording according to the detection results, the memory pre-recording strategy is optimized, and the problems of low storage efficiency and short pre-recording time in the existing technology are solved, and a longer pre-recording time and efficient use of storage resources are achieved.
Patent Information
- Application Number
- CN202510342295.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-06-10
AI Technical Summary
The existing cloud storage video pre-recording function has low storage efficiency and short pre-recording time, which makes it impossible to meet users' needs for pre-recording time, affecting user experience.
By detecting whether the video surveillance device is connected to the SD card, if connected, use the SD card for pre-recording, otherwise use memory for pre-recording, and optimize the memory pre-recording strategy to store I frames at intervals of 3-6 seconds.
It can provide a long recording time before preset events occur without an SD card, improving user experience and storage resource usage efficiency.
Smart Images

Figure CN120128667A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video surveillance, and particularly to a method for pre-recording surveillance videos, an electronic device, and a computer-readable storage medium. Background Art
[0002] The video pre-recording function of cloud storage means that in a video surveillance system, the device can not only store video data in the cloud but also pre-record video content for a certain period in advance. This function enables users to quickly view the video data after a specific event occurs and also look back at the video data before the specific event, so as to better understand the cause and effect of the specific event and improve the effectiveness and security of video surveillance. Currently, the realization of the cloud storage video pre-recording function is mainly based on two pre-recording methods, namely SD (Secure Digital Card, a widely used flash memory storage card mainly for storing data) card video pre-storage and memory fast pre-recording.
[0003] When performing SD card video pre-storage, a pre-recording space is usually allocated separately on the SD card to support long-term recording. When the pre-recording space is full, the system will overwrite the previous video data. However, this method depends on the presence of the SD card. Without an SD card, the device cannot perform pre-recording, which limits its use in different application scenarios. In addition, the separately allocated pre-recording space will also cause waste of storage space because video files are usually large, and the pre-recording space may occupy storage resources that could have been used to store regular videos for a longer time, thus reducing the overall storage efficiency.
[0004] When performing memory fast pre-recording, the device directly uses the memory as a pre-recording data buffer, and the pre-recording duration is only 1 - 2 seconds. Since video surveillance devices are usually embedded devices and the memory of embedded devices is limited, it can basically only store 1 to 2 I-frame (key frame) groups, and one I-frame group is about 1 second, so ultimately only 1 - 2 seconds of video data can be recorded. It can be seen that due to the limitation of the memory storage space, this pre-recording method results in an extremely short pre-recording duration and cannot meet the user's demand for the pre-recording duration, thus affecting the user experience.
[0005] In summary, the existing two pre-recording methods each have certain defects and still need to be optimized to improve the storage efficiency and pre-recording duration. Summary of the Invention
[0006] In view of this, the present invention proposes a method for pre-recording surveillance videos, an electronic device, and a computer-readable storage medium, aiming to solve the problems of low storage efficiency and short pre-recording duration existing in traditional pre-recording methods.
[0007] To solve the above problems, the present invention adopts the following technical solutions:
[0008] In a first aspect, the present invention proposes a method for pre-recording surveillance videos, including:
[0009] Start the video surveillance device and detect whether the video surveillance device is connected to an SD card;
[0010] If it is confirmed that the SD card is connected and the connection status of the SD card is stable, use the SD card to store the video data recorded by the video surveillance device, and use the preset video data storage area of the SD card as the pre-recorded data storage area for the video data;
[0011] If it is confirmed that the SD card is not connected, use the memory of the video surveillance device as the pre-recorded data buffer area for caching the video data recorded by the video surveillance device; wherein, the pre-recorded data buffer area caches the video data according to the rule of storing one key frame every preset period, and the preset period is 3 - 6 seconds;
[0012] In response to detecting a preset event, start the video pre-recording function and read the video data from the pre-recorded data storage area or the pre-recorded data buffer area to form pre-recorded video data.
[0013] Further, the reading of the video data from the pre-recorded data buffer area includes:
[0014] Obtain a first pre-recording duration, and determine the actual pre-recording duration according to the first pre-recording duration and the maximum pre-recording duration currently supported by the memory; wherein, the first pre-recording duration is calculated based on the available capacity of the memory and the currently executing tasks when starting the video surveillance device; the maximum pre-recording duration is the longest pre-recording duration that the circular buffer of the pre-recorded data buffer area can currently support when detecting the preset event; when the maximum pre-recording duration is not less than the first pre-recording duration, the actual pre-recording duration is equal to the first pre-recording duration; when the maximum pre-recording duration is less than the first pre-recording duration, the actual pre-recording duration is equal to the maximum pre-recording duration;
[0015] Read the video data from the pre-recorded data buffer area according to the determined actual pre-recording duration.
[0016] Further, the reading of the video data from the pre-recorded data buffer area according to the determined actual pre-recording duration includes:
[0017] Obtain the occurrence time of the preset event, and use the occurrence time as the end time of the pre-recorded video data.
[0018] Read the video data with a duration equal to the actual pre-recording duration from the pre-recorded data buffer; wherein, the start time of the pre-recorded video data is equal to the end time minus the actual pre-recording duration.
[0019] Further, the reading of the video data from the pre-recorded data storage area includes: obtaining a preset second pre-recording duration, and reading the video data from the pre-recorded data storage area according to the preset second pre-recording duration.
[0020] Further, the reading of the video data from the pre-recorded data storage area according to the preset second pre-recording duration includes:
[0021] Obtain the occurrence time of the preset event, and locate a segment of video data corresponding to the time period closest to the occurrence time stored in the pre-recorded data storage area;
[0022] Starting from the located segment of video data, read the video data with a duration equal to the preset second pre-recording duration in the pre-recorded data storage area; wherein, the start time of the pre-recorded video data is equal to the occurrence time minus the preset second pre-recording duration, and the end time of the pre-recorded video data is the occurrence time.
[0023] Further, the preset events include: a preset motion event detected by a camera or an infrared sensor, a preset sound event detected by a sound sensor, and a preset access control switch event detected by an access control sensor.
[0024] Further, after starting the video monitoring device, it further includes:
[0025] Detect whether a connection is established between the video monitoring device and the cloud storage server;
[0026] If it is confirmed that the connection is established and the connection is in a stable state, then after starting the video pre-recording function, send the pre-recorded video data to the cloud storage server through the connection;
[0027] If it is confirmed that the connection is established and the connection is in an interrupted state, re-establish the connection between the video monitoring device and the cloud storage server, and until it is confirmed that the connection is in a stable state again; when the connection is in a stable state again, then after starting the video pre-recording function, send the pre-recorded video data to the cloud storage server through the re-established connection;
[0028] If it is confirmed that the connection is not established, establish the connection between the video monitoring device and the cloud storage server, and confirm that the connection is in a stable state; when the connection is in a stable state, after starting the video pre-recording function, send the pre-recorded video data to the cloud storage server through the established connection.
[0029] Further, after the preset event is monitored, it further includes:
[0030] Obtain a preset video recording duration and the occurrence time of the preset event; wherein, the preset video recording duration is 3 - 90 seconds;
[0031] Use the occurrence time as the start time of the video data recording, and continuously record video data for a duration of the preset video recording duration, and at the same time send the recorded video data to the cloud storage server in real time; wherein, a connection is established between the cloud storage server and the video monitoring device and the connection is in a stable state, and the end time of the video data is equal to the occurrence time plus the preset video recording duration.
[0032] In a second aspect, the present invention further provides an electronic device, the electronic device is an embedded device, including:
[0033] A memory for storing program instructions; and
[0034] A processor for executing the program instructions to implement the steps of the pre-recording method of the monitoring video as described above.
[0035] In a third aspect, the present invention further provides a computer-readable storage medium, the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the pre-recording method of the monitoring video as described above are implemented.
[0036] Compared with the prior art, the beneficial effects of the present invention are as follows: A method for pre-recording surveillance videos, an electronic device, and a computer-readable storage medium, including: starting a video surveillance device and detecting whether the video surveillance device is connected to an SD card; if it is confirmed that the SD card is connected and the connection state of the SD card is stable, using the SD card to store the video data recorded by the video surveillance device, and using the preset video data storage area of the SD card as the pre-recorded data storage area for the video data; if it is confirmed that the SD card is not connected, using the memory of the video surveillance device as the pre-recorded data buffer area for caching the video data recorded by the video surveillance device; wherein, the pre-recorded data buffer area caches the video data according to the rule of storing one key frame at every preset period, and the preset period is 3 - 6 seconds; in response to detecting a preset event, starting the video pre-recording function and reading the video data from the pre-recorded data storage area or the pre-recorded data buffer area to form pre-recorded video data. It can be seen that this pre-recording mechanism can automatically detect whether the video surveillance device is equipped with an SD card, and intelligently select to use the SD card or the memory for pre-recording according to the detection result. When the device inserts an SD card, using the original video data storage area of the SD card as the pre-recorded data storage area, avoiding the need to specially allocate storage space for the video pre-recording function, thereby improving the overall storage efficiency. When the device does not insert an SD card, the memory pre-recording method is adopted. This method optimizes the storage strategy of I frames, storing I frames at intervals of 3 - 6 seconds in the memory. Through this optimization, the effective duration of pre-recording can be increased, making the pre-recording duration exceed 1 - 2 seconds, thus meeting the user's requirements for the pre-recording duration. That is, in both cases of having and not having an SD card, a longer recording duration before the preset event can be provided, thereby enhancing the user's experience and optimizing the use of storage resources to ensure the efficiency and practicality of video surveillance. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. Moreover, throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0038] Figure 1 It is a flowchart of the first embodiment of the method for pre-recording surveillance videos of the present invention;
[0039] Figure 2 It is a flowchart of the second embodiment of the method for pre-recording surveillance videos of the present invention;
[0040] Figure 3 It is a flowchart of the third embodiment of the method for pre-recording surveillance videos of the present invention;
[0041] Figure 4Schematic flowchart of the fourth embodiment of the pre-recording method for the monitoring video of the present invention;
[0042] Figure 5 Schematic flowchart of the fifth embodiment of the pre-recording method for the monitoring video of the present invention;
[0043] Figure 6 Schematic diagram of the structure of an electronic device in the hardware operating environment related to the solution of the embodiment of the present invention. Detailed implementation manners
[0044] Next, the solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts belong to the scope of protection of the present invention.
[0045] It should be noted that if there are directional indications (such as up, down, left, right, front, back...) involved in the embodiments of the present invention, the directional indications are only used to explain the relative positional relationship and movement conditions between components in a specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indications will also change accordingly.
[0046] In addition, if there are descriptions such as "first", "second", etc. involved in the embodiments of the present invention, the descriptions of "first", "second", etc. are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions between various embodiments can be combined with each other, but it must be based on the fact that those of ordinary skill in the art can implement them. When the combination of technical solutions appears to be contradictory or unable to be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0047] Please refer to Figure 1 as shown, which is a schematic flowchart of the first embodiment of the pre-recording method for the monitoring video of the present invention.
[0048] In this embodiment, the pre-recording method for the monitoring video includes:
[0049] Step S100: Start the video monitoring device and detect whether the video monitoring device is connected to the SD card.
[0050] Specifically, video surveillance devices are usually embedded devices, which are characterized by high performance and low power consumption and can operate stably in various environments. This device integrates functions such as image processing, data storage, and network transmission, and can capture and transmit video data in real time. In addition, with the development of technology, many embedded video surveillance devices also have intelligent analysis functions, such as face recognition, motion detection, and abnormal behavior analysis, further improving the efficiency and accuracy of security surveillance.
[0051] Specifically, the method for detecting whether the video surveillance device is connected to an SD card includes a hardware detection method and a file system detection method. Among them, the hardware detection method is to detect whether there is a card inserted into the SD card slot through the internal circuit when the device starts. Usually, the device will check the presence of the SD card during the power-on self-check stage. The file system detection method is to attempt to access the file system of the SD card on the premise that the SD card has been inserted. If the files or directories on the SD card can be successfully read, it means that the SD card is connected. Through these two detection methods, the video surveillance device can effectively detect the connection status of the SD card and adjust the storage scheme of the pre-recorded video data according to the detection result.
[0052] Step S200: If it is confirmed that the SD card is connected and the connection status of the SD card is stable, use the SD card to store the video data recorded by the video surveillance device, and use the preset video data storage area of the SD card as the pre-recorded data storage area for the video data.
[0053] Specifically, during the monitoring process, the video surveillance device continuously records and stores conventional video data in the preset video data storage area, and when a specific event (i.e., a preset event) occurs, it automatically extracts the video data (i.e., pre-recorded video data) within a period of time before the occurrence of the specific event. In this way, users can not only view the video data when the specific event occurs, but also review the situation before the specific event occurs, so as to more comprehensively understand the background and process of the specific event. This pre-recording mechanism ensures that important events are not missed and improves the effectiveness of video surveillance.
[0054] Specifically, whether the connection status of the SD card is stable can be confirmed by the following methods:
[0055] Access the file system: Try to access the file system of the SD card and read the files or directories on the SD card. If it can be successfully read, it means that the connection status of the SD card is stable.
[0056] Data writing test: Conduct a simple data writing test and try to write data to the SD card. If the writing is successful and there is no error prompt, it means that the connection status of the SD card is stable.
[0057] Regular status check: Regularly check the read and write speed and error rate of the SD card. If there are no read and write errors within a certain period of time, it indicates that the connection status of the SD card is stable.
[0058] Through one or more of the above methods, the stability of the SD card connection status can be effectively confirmed, thus ensuring the normal operation of the video surveillance device.
[0059] Step S300: If it is confirmed that the SD card is not connected, use the memory of the video surveillance device as a pre-recorded data buffer for caching the video data recorded by the video surveillance device.
[0060] Among them, the pre-recorded data buffer caches the video data according to the rule of storing one key frame every preset period, and the preset period is 3 - 6 seconds.
[0061] Specifically, the preset period can be 3 seconds, 4 seconds, 5 seconds, or 6 seconds. By extending the storage interval of key frames, longer pre-recording can be achieved within limited storage space. This means that even when the memory storage resources are limited, users can still obtain video data before a specific event for a longer time. This design effectively extends the pre-recording duration, improves the playback experience, and can ensure the complete recording of important events.
[0062] Step S400: In response to detecting a preset event, start the video pre-recording function and read the video data from the pre-recorded data storage area or the pre-recorded data buffer to form pre-recorded video data.
[0063] Specifically, the pre-recorded data storage area stores the video data recorded by the video surveillance device. These video data are processed and stored in the SD card. The pre-recorded data buffer stores the video data temporarily recorded by the video surveillance device within a certain period before the preset event occurs. These video data are usually recorded in real time to quickly obtain the images before the preset event occurs. The data in the pre-recorded data buffer is not stored for a long time but is used for quick access in the short term. The formation of pre-recorded video data enables users to more quickly locate the situation before a specific event when viewing the surveillance video, thus enhancing the practicality of video surveillance. By reading the pre-recorded video data and combining it with the video data recorded after the specific event, a complete video file can be formed. This video file not only includes the images during the specific event but also covers the key scenes before the specific event, helping users to more comprehensively understand the background and process of the specific event. Especially in the field of security surveillance, obtaining the video data before and after an event can effectively help users better analyze and handle potential security threats.
[0064] Compared with the prior art, the pre-recording method of surveillance videos according to the embodiments of the present invention provides an efficient pre-recording mechanism that can automatically detect whether an SD card is equipped in a video surveillance device and intelligently select to use the SD card or the memory for pre-recording according to the detection result. When an SD card is inserted into the device, the original video data storage area of the SD card is used as the pre-recorded data storage area, avoiding the need to allocate storage space specifically for the video pre-recording function, thereby improving the overall storage efficiency. When the device does not have an SD card inserted, the memory pre-recording method is adopted. This method optimizes the storage strategy of I-frames, storing I-frames at intervals of 3 - 6 seconds in the memory. Through this optimization, the effective pre-recording duration can be increased, making the pre-recording duration exceed 1 - 2 seconds, thus meeting the user's requirements for the pre-recording duration. That is, in both cases with and without an SD card, a relatively long recording duration before the preset event can be provided, thereby enhancing the user experience and optimizing the use of storage resources to ensure the efficiency and practicality of video surveillance.
[0065] Please refer to Figure 2 shown, which is a schematic flowchart of the second embodiment of the pre-recording method of surveillance videos of the present invention.
[0066] This embodiment elaborates in detail on the process of pre-recording through the memory compared with other embodiments of the pre-recording method of surveillance videos.
[0067] In this embodiment, in step S400, the reading of video data from the pre-recorded data buffer includes:
[0068] Step S411: Obtain the first pre-recording duration and determine the actual pre-recording duration according to the first pre-recording duration and the maximum pre-recording duration currently supported by the memory.
[0069] Among them, the first pre-recording duration is calculated based on the available capacity of the memory and the tasks currently being executed when the video surveillance device is started; the maximum pre-recording duration is the longest pre-recording duration that the circular buffer of the pre-recorded data buffer can currently support when the preset event is detected; when the maximum pre-recording duration is not less than the first pre-recording duration, the actual pre-recording duration is equal to the first pre-recording duration; when the maximum pre-recording duration is less than the first pre-recording duration, the actual pre-recording duration is equal to the maximum pre-recording duration.
[0070] Specifically, under normal circumstances, the video surveillance device stores regular video recording data in the SD card; when the SD card is not inserted, the video surveillance device does not perform regular video recording, but uses in-memory pre-recording. When the video pre-recording function is activated, it means that the video surveillance device needs to record pre-recorded video data and store it in the pre-recorded data buffer so that the video data can be read from the pre-recorded data buffer later. Therefore, it is required that the video surveillance device with in-memory pre-recording has high response speed and real-time processing performance to ensure that important events can be captured and stored in a timely manner.
[0071] Specifically, the calculation of the first pre-recording duration is mainly based on the available capacity of the memory and the tasks currently being executed. First, evaluate the total capacity of the current memory and subtract the occupied memory to determine the available memory capacity. Then, evaluate the memory required for the tasks currently being executed, including the memory occupied by the running applications and services. Next, subtract the memory required for the tasks from the available memory capacity to obtain the memory capacity available for pre-recording. Again, determine the amount of memory required per second of recording according to the video coding format and resolution. Finally, use the formula: pre-recording duration = available memory for pre-recording / memory required per second to calculate the first pre-recording duration. The calculation of the maximum pre-recording duration is similar to that of the first pre-recording duration, and will not be elaborated with examples here.
[0072] Specifically, the capacity of the memory is usually smaller than that of the SD card. Therefore, when pre-recording in the memory, the video surveillance device needs to cache the recording data within a limited space. This may result in a relatively short pre-recording duration, especially when the memory is occupied by other processes. The video surveillance device may adjust the pre-recording duration according to the real-time monitoring requirements and the memory usage situation to ensure that as much important recording data as possible can be saved when a preset event occurs. This dynamic adjustment method enables the video surveillance device to flexibly respond to different monitoring requirements and capture important events as much as possible even without an external storage medium such as an SD card. That is to say, the first pre-recording duration and the maximum pre-recording duration may be dynamically adjusted according to the change of the system load to ensure that the pre-recording of the recording data can still be effectively carried out under limited resources. Generally speaking, the memory management mechanism of the device will adopt different strategies in different operation stages. When the device is powered on, the system will first ensure the stability of startup and initialization; while in the normal operation state, if a preset event is triggered, the system will optimize the resource allocation according to the actual situation to support the longest pre-recording duration. Therefore, the first pre-recording duration is set to ensure that the video surveillance device can quickly capture the preset event while starting up normally. The maximum pre-recording duration is the longest recording time that the system can support based on the current memory usage situation and the resource management strategy in the normal operation state. According to the dynamic change of the system resources, it is possible that the maximum pre-recording duration is greater than or less than the first pre-recording duration. However, between the first pre-recording duration and the maximum pre-recording duration, usually the smaller value is selected as the actual pre-recording duration to balance performance and stability, ensuring that the video surveillance device can effectively capture important events under various operating conditions and reducing the risk of recording failure of the pre-recorded video data due to system load changes or other unforeseen factors.
[0073] Step S412: Obtain the occurrence time of the preset event and use the occurrence time as the end time of the pre-recorded video data.
[0074] Step S413: According to the determined actual pre-recording duration, read the video data with a duration of the actual pre-recording duration from the pre-recorded data buffer.
[0075] Wherein, the start time of the pre-recorded video data is equal to the end time minus the actual pre-recording duration.
[0076] The following explains the determination process of the start time and the end time of the pre-recorded video data in the memory pre-recording in two cases:
[0077] 1. The case where the maximum pre-recording duration is not less than the first pre-recording duration:
[0078] Assumption: The occurrence time of the preset event: 10:10:10;
[0079] The first pre-recording duration: 5s (the range of the first pre-recording duration is 1 - 10s);
[0080] The maximum pre-recording duration: 8s;
[0081] Then: The actual pre-recording duration: 5s;
[0082] The start time of the pre-recorded video data: 10:10:05 (5s before the preset event occurs);
[0083] The end time of the pre-recorded video data: 10:10:10;
[0084] The preset video duration: 60s (continue to record for 1 minute after the event occurs);
[0085] The video recording time after the preset event: 10:11:10;
[0086] The duration of the entire video file: 65s.
[0087] 2. The situation where the maximum pre-recording duration is less than the first pre-recording duration:
[0088] Assume: The occurrence time of the preset event: 10:10:10;
[0089] The first pre-recording duration: 5s (the range of the first pre-recording duration is 1 - 10s);
[0090] The maximum pre-recording duration: 4s;
[0091] Then: The actual pre-recording duration: 4s;
[0092] The start time of the pre-recorded video data: 10:10:06 (4s before the preset event occurs);
[0093] The end time of the pre-recorded video data: 10:10:10;
[0094] The preset video duration: 60s (continue to record for 1 minute after the event occurs);
[0095] The video recording time after the preset event: 10:11:10;
[0096] The duration of the entire video file: 64s.
[0097] It can be seen that by setting the selection mechanism for the actual pre-recording duration, the video surveillance device can flexibly adjust the pre-recording duration according to the memory storage conditions, ensuring that important surveillance information can be effectively captured in various situations. This design improves the adaptability and reliability of the video surveillance device and meets the video surveillance requirements in different scenarios.
[0098] The pre-recording method of the monitoring video according to the embodiment of the present invention solves the problem of too short pre-recording duration of the existing cloud storage video data, improves the user experience, and is applicable to constant power devices and low-power devices that support video recording under low power consumption.
[0099] Please refer to Figure 3 As shown, it is a schematic flowchart of the third embodiment of the pre-recording method of the monitoring video of the present invention.
[0100] Compared with other embodiments of the pre-recording method of the monitoring video, this embodiment details the process of pre-recording through the SD card.
[0101] In this embodiment, in step S400, the reading of the video data from the pre-recording data storage area includes:
[0102] Step S421: Obtain a preset second pre-recording duration.
[0103] Specifically, when using the SD card for pre-recording, a fixed pre-recording duration (i.e., the preset second pre-recording duration) is usually set according to requirements. This fixed pre-recording duration can ensure that video data within a certain time range is saved when a preset event occurs. Since the capacity of the SD card is generally larger than that of the memory, the preset second pre-recording duration is usually longer than the first pre-recording duration.
[0104] Step S422: Obtain the occurrence time of the preset event, and locate a segment of video data corresponding to the time period closest to the occurrence time stored in the pre-recording data storage area.
[0105] Specifically, a segment of video data corresponding to the time period closest to the occurrence time refers to the latest segment of video data that has been recorded and stored on the SD card by the video monitoring device before the preset event occurs. Since the video monitoring device continuously records and stores regular video data, when the preset event occurs, the video monitoring device can quickly locate a segment of video data before the preset event without a complex search or screening process. This fast positioning mechanism can effectively improve the response speed, simplify the operation process, and ensure that the required pre-recorded video data can be obtained in a timely manner at a critical moment.
[0106] Step S423: Starting from the located segment of video data, read video data with a duration of the preset second pre-recording duration in the pre-recording data storage area.
[0107] Among them, the start time of the pre-recorded video data is equal to the occurrence time minus the preset second pre-recording duration, and the end time of the pre-recorded video data is the occurrence time.
[0108] The determination process of the start time and end time of the pre-recorded video data described in the SD card pre-recording will be described below:
[0109] Assumption: The occurrence time of the preset event: 10:10:10;
[0110] Preset second pre-recording duration: 30s (the range of the preset second pre-recording duration is 1 - 60s);
[0111] Start time of the pre-recorded video data: 10:09:40 (30s before the occurrence of the preset event);
[0112] End time of the pre-recorded video data: 10:10:10;
[0113] Preset video duration: 60s (record video for 1 minute after the event occurs);
[0114] Video recording time after the preset event: 10:11:10;
[0115] Duration of the entire video file: 90s.
[0116] The pre-recording method of the monitoring video in the embodiment of the present invention provides a pre-recording scheme that combines an SD card and memory, and can provide recording for a long time before a specific event in both cases of having an SD card and not having an SD card, and optimize the use of storage resources.
[0117] Please refer to Figure 4 as shown, which is a schematic flowchart of the fourth embodiment of the pre-recording method of the monitoring video of the present invention.
[0118] In this embodiment, compared with other embodiments of the pre-recording method of the monitoring video, a step of sending the pre-recorded video data to the cloud storage server is added.
[0119] In this embodiment, in step S100, after starting the video monitoring device, it further includes:
[0120] Step S501: Detect whether a connection is established between the video monitoring device and the cloud storage server.
[0121] Specifically, the detection method for whether a connection is established between the video monitoring device and the cloud storage server can be to send a data packet to the IP address of the cloud storage server using a network tool (such as the ping command in the command line). If a response can be received, it indicates that the network connection between the video monitoring device and the cloud storage server is available; it can also be to directly monitor the log file of the video monitoring device to check whether there are records of successful or failed connections to understand the connection status between the video monitoring device and the cloud storage server.
[0122] Step S502: If it is confirmed that the connection is established and the connection is in a stable state, after starting the video pre-recording function, the pre-recorded video data is sent to the cloud storage server through the connection.
[0123] Specifically, the situation corresponding to this step is that the connection state between the video surveillance device and the cloud storage server is stable and the data transmission is smooth, and the video surveillance device can upload video data in real time. In this connection state, the connection management policy is to periodically monitor the connection state to ensure stable operation at all times.
[0124] Step S503: If it is confirmed that the connection is established and the connection is in an interrupted state, re-establish the connection between the video surveillance device and the cloud storage server and wait until it is confirmed that the connection is in a stable state again; when the connection is in a stable state again, after starting the video pre-recording function, the pre-recorded video data is sent to the cloud storage server through the re-established connection.
[0125] Specifically, the situation corresponding to this step is that although the connection between the video surveillance device and the cloud storage server has been established, due to network instability, server failure or other reasons, the connection is in an interrupted state. Measures need to be taken to re-establish the connection to ensure the smooth upload of video data. In this connection state, the connection management policy is to perform a reconnection attempt in a timely manner when the connection is interrupted and monitor the success or failure of the reconnection process.
[0126] Step S504: If it is confirmed that the connection is not established, establish the connection between the video surveillance device and the cloud storage server and confirm that the connection is in a stable state; when the connection is in a stable state, after starting the video pre-recording function, the pre-recorded video data is sent to the cloud storage server through the established connection.
[0127] Specifically, the situation corresponding to this step is that due to network failure, configuration error, server unavailability or other reasons, no connection is established between the video surveillance device and the cloud storage server, and an immediate attempt needs to be made to establish a connection to ensure that the video surveillance device can communicate with the cloud storage server. In this connection state, the connection management policy is to quickly take measures to establish a connection and confirm its stability when the connection is not established.
[0128] It should be noted that Step S502, Step S503 and Step S504 are descriptions of the pre-recorded video data sending strategies for the video surveillance device and the cloud storage server in different connection states. According to different connection states, corresponding sending measures are taken to ensure the stability and effectiveness of the pre-recorded video data in network transmission. There is no sequential order among Step S502, Step S503 and Step S504, and any one of them can be selected for implementation according to the actual situation.
[0129] The pre-recording method of surveillance video in the embodiments of the present invention is an improved pre-recording method, including the following innovations:
[0130] 1. Use of SD card in combination with memory: When the video surveillance device is equipped with an SD card, the original video data storage area of the SD card is used as the pre-recorded data storage area, avoiding the need to allocate a dedicated storage space for the pre-recording function. When the video surveillance device does not insert an SD card, the memory pre-recording method is adopted.
[0131] 2. Optimization of memory pre-recording: The memory pre-recording method optimizes the storage strategy of I-frames, storing video data in the memory at an interval of one I-frame per 4 seconds, avoiding the limitation that only 1 to 2 I-frames can be stored per second in traditional memory pre-recording. Through this optimization, the pre-recording duration can be extended from 1 - 2 seconds to 4 seconds, significantly improving the effective pre-recording duration and enhancing the user experience.
[0132] 3. Flexible pre-recording without SD card: When the video surveillance device does not insert an SD card, pre-recording can still be performed through the memory, without affecting the enabling of the video pre-recording function. This pre-recording method provides flexible pre-recording capabilities, enabling the video surveillance device to efficiently perform pre-recording even without an SD card, ensuring the continuity and reliability of the monitoring task.
[0133] Please refer to Figure 5 as shown, which is a schematic flowchart of the fifth embodiment of the pre-recording method of surveillance video of the present invention.
[0134] In this embodiment, compared with other embodiments of the pre-recording method of surveillance video, a step of sending the recorded video data to the cloud storage server in real time after a preset event occurs is added.
[0135] In this embodiment, in step S400, after the preset event is monitored, the following steps are further included:
[0136] Step S431: Obtain the preset video duration and the occurrence time of the preset event.
[0137] Among them, the preset video duration is 3 - 90 seconds.
[0138] Specifically, the preset video duration refers to the time length of the video data continuously recorded by the video surveillance device after the preset event occurs. After the preset event occurs, continuously recording the subsequent video data with the preset video duration can ensure that the video surveillance device continuously captures the changes in the surrounding environment, providing comprehensive monitoring coverage. Combining the subsequent video data with the pre-recorded video data can form a complete event record for later investigation and analysis.
[0139] In some embodiments of the present application, the preset events include: preset motion events detected by a camera or an infrared sensor, preset sound events detected by a sound sensor, and preset access control switch events detected by an access control sensor.
[0140] Specifically, detecting preset motion events by a camera or an infrared sensor is applicable to scenarios such as intrusion detection in a monitored area and personnel activity monitoring, and can effectively improve the security prevention ability.
[0141] Detecting preset sound events by a sound sensor is applicable to places that require sound monitoring, such as stores and residences, and can give timely reminders in case of emergencies.
[0142] Detecting preset access control switch events by an access control sensor is applicable to places that require strict access control, such as office buildings and laboratories, and can effectively prevent unauthorized access.
[0143] The detection mechanisms of these preset events make the video monitoring device more intelligent and flexible, and can respond to various potential security threats in real time. By integrating multiple sensors, the video monitoring device can provide more comprehensive security protection, ensuring effective monitoring and management of the environment.
[0144] Step S432: Use the occurrence time as the start time of the video recording data, continuously record video recording data for the preset recording duration, and simultaneously send the recorded video recording data to the cloud storage server in real time.
[0145] Wherein, a connection is established between the cloud storage server and the video monitoring device and the connection is in a stable state, and the end time of the video recording data is equal to the occurrence time plus the preset recording duration.
[0146] Specifically, sending the recorded video recording data to the cloud storage server in real time can help users access the latest video recording data anytime and anywhere without waiting for the video recording data transmission to complete. This is particularly important for security events that require quick response. The real-time sending method can also reduce the delay of video recording data transmission, ensuring that the monitoring system can quickly provide relevant evidence in case of specific emergencies and helping users make timely decisions.
[0147] The implementation process of the pre-recording method of the monitoring video of the present invention is described in detail below, specifically as follows:
[0148] 1. Start the video monitoring device
[0149] When the video monitoring device starts, it will first check the presence and status of the storage device to determine whether an SD card is available.
[0150] If there is an SD card, the video surveillance device will use the SD card for regular video recording storage.
[0151] If there is no SD card, the video surveillance device will use the memory as a buffer for pre-recorded data.
[0152] 2. Storage Device Check
[0153] Check whether the video surveillance device has an SD card.
[0154] If there is an SD card: The video surveillance device will continue to check the connection status with the cloud storage server and use the SD card for regular video recording storage.
[0155] If there is no SD card: The video surveillance device will use the memory as a buffer for pre-recorded data, start calculating the pre-recording duration (i.e., the first pre-recording duration), and prepare to upload the video data.
[0156] 3. Connection Status Check with Cloud Storage Server
[0157] Check whether the video surveillance device can establish a connection with the cloud storage server to ensure that video data can be uploaded. And it is necessary to ensure that the network connection between the video surveillance device and the cloud storage server is continuous and stable to support the upload of video data.
[0158] 4. Preset Event Trigger Check
[0159] The video surveillance device continuously monitors the event source (such as preset events detected through sensors or motion detection). Once a preset event is detected and triggered, it immediately activates the video pre-recording function and real-time streaming recording. At this time, the video surveillance device needs to have a fast response mechanism to be able to respond to the trigger of the preset event within a short time.
[0160] 5. Obtain Pre-recording Duration
[0161] Once a preset event is triggered, the video surveillance device obtains the maximum pre-recording duration according to the configuration or directly uses the preset second pre-recording duration. Usually, the preset second pre-recording duration should be set according to the user's needs and the device's performance, and the range can be set between a few seconds and dozens of seconds, and it can flexibly support multiple pre-recording duration options (such as 5 seconds, 10 seconds, 30 seconds, etc.).
[0162] 6. Calculate Pre-recording Start Time
[0163] According to the occurrence time of the preset event and the determined pre-recording duration, calculate the start time of cloud storage pre-recording, that is, trace back to a certain time point before the occurrence of the preset event as the start time of cloud storage pre-recording.
[0164] If there is an SD card: Use the video data in the SD card for pre-recording.
[0165] If there is no SD card: The system will calculate an appropriate start time for pre-recording based on the maximum pre-recording duration of the memory.
[0166] 7. Process pre-recorded video data
[0167] According to the calculated start time, the video surveillance device reads pre-recorded video data from the pre-recorded data storage area or the pre-recorded data buffer:
[0168] If there is an SD card: Read pre-recorded video data from the SD card. After reading sufficient pre-recorded video data from the SD card, it is also necessary to ensure that it can be uploaded to the cloud storage server.
[0169] If there is no SD card: Use the first pre-recorded duration or the maximum pre-recorded duration for pre-recording. Cache the video data before the preset event trigger in the memory until the determined pre-recorded duration is reached.
[0170] 8. Complete the upload of pre-recorded video data
[0171] Regardless of whether the pre-recorded video data is from the SD card or the memory, the video surveillance device needs to upload the pre-recorded video data to the cloud storage server. The upload process must ensure the integrity and reliability of the pre-recorded video data. The video surveillance device should be able to handle the situation where the upload of pre-recorded video data fails and be able to automatically retry.
[0172] 9. Obtain video data after the preset event
[0173] Obtain the preset video duration after the preset event is triggered. This preset video duration is usually set by the user and may be 5 seconds, 10 seconds, 1 minute, etc. The user can flexibly configure the preset video duration after the preset event is triggered, and the video surveillance device can automatically start and stop recording video data according to this preset video duration.
[0174] 10. Real-time stream upload
[0175] Once the preset event is triggered, the video surveillance device will continuously perform real-time stream recording and upload the recorded video data to the cloud storage server in real time until the preset video duration is reached. The upload method of the real-time stream also needs to ensure the continuity of the recorded video data, avoid frame loss and delay, to ensure the integrity of the recorded video data.
[0176] 11. Upload completed
[0177] Once the upload of the video data after the preset event is completed, the video surveillance device will return to the standby state, ready to respond to the trigger of the next preset event at any time. The video surveillance device should immediately return to the normal standby state after the upload is completed to ensure that it can respond to new preset events at any time.
[0178] 12. Repeat the process
[0179] The video surveillance device should have an efficient loop mechanism to ensure that it can return to the standby state within a short time and be ready to handle the next preset event.
[0180] The pre-recording method of the surveillance video in the embodiments of the present invention has the following advantages:
[0181] 1. Solve the problem of insufficient SD card space: The present invention no longer needs to reserve SD card space specifically for the video pre-recording function. By using the existing video data for pre-recording, the storage resources are effectively saved.
[0182] 2. Improve the memory pre-recording duration: By optimizing the memory storage strategy, an I-frame is stored every 4 seconds, greatly improving the pre-recording duration (the pre-recording duration of traditional memory pre-recording is only 1-2 seconds). This improvement extends the recording time before the preset event is triggered and significantly enhances the user experience.
[0183] 3. Enhance the flexibility of the device: Whether the video surveillance device is inserted with an SD card or not, the video pre-recording function can be realized. Especially when the SD card is missing or damaged, the video surveillance device can still perform pre-recording through the memory, improving the reliability and stability of the video surveillance device.
[0184] 4. Reduce the hardware requirements: The present invention reduces the dependence on hardware resources by optimizing the memory usage, and does not require additional storage space for pre-recording, reducing the hardware cost.
[0185] The following are the embodiments of the electronic device provided by the present invention. The embodiments of the electronic device and the embodiments of the above-mentioned pre-recording method of the surveillance video belong to the same concept. For the details not described in detail in the embodiments of the electronic device, reference can be made to the embodiments of the above-mentioned pre-recording method of the surveillance video.
[0186] Please refer to Figure 6 as shown, which is a schematic structural diagram of an electronic device in the hardware operating environment related to the embodiment solution of the present invention.
[0187] In this embodiment, an electronic device, the electronic device is an embedded device, including:
[0188] A memory 1005 for storing program instructions; and
[0189] A processor 1001 for executing the program instructions to implement the steps of the pre-recording method of the surveillance video as described above.
[0190] The electronic device in the embodiments of the present invention can be a computing device such as a desktop computer, a notebook, a palm computer, and a server. As Figure 6As shown in the figure, the electronic device may include: a processor 1001 (such as a CPU), a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display) and an input unit, such as a keyboard (Keyboard). Optionally, the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0191] Those skilled in the art can understand that Figure 6 the structure of the electronic device shown in the figure does not constitute a limitation on the electronic device, and it may include more or fewer components than shown in the figure, or combine some components, or have different component arrangements.
[0192] As Figure 6 shown, the memory 1005, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a computer program.
[0193] In Figure 6 the electronic device shown in the figure, the network interface 1004 is mainly used to connect to the background server and perform data communication with the background server; the user interface 1003 is mainly used to connect to the client (user side) and perform data communication with the client; and the processor 1001 can be used to call the computer program stored in the memory 1005. When the computer program is called and executed by the processor 1001, the steps of the above-mentioned method for pre-recording monitoring videos are implemented.
[0194] The following is an embodiment of the computer-readable storage medium provided by the present invention. The embodiment of the computer-readable storage medium and the embodiments of the above-mentioned method for pre-recording monitoring videos and the electronic device belong to the same concept. For the details not described in detail in the embodiment of the computer-readable storage medium, reference may be made to the embodiments of the above-mentioned method for pre-recording monitoring videos and the electronic device.
[0195] In this embodiment, a computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the above-mentioned method for pre-recording monitoring videos are implemented.
[0196] The electronic device and computer-readable storage medium of the present invention can both implement the steps of the above-mentioned pre-recording method for surveillance videos. Therefore, they at least have all the beneficial effects brought by the technical solutions of the embodiments of the steps of the above-mentioned pre-recording method for surveillance videos, which will not be elaborated one by one here.
[0197] The above are only partial or preferred embodiments of the present invention. Whether in terms of text or drawings, they cannot limit the scope of protection of the present invention. Any equivalent structural transformation made using the content of the specification and drawings of the present invention under the overall concept of the present invention, or any direct / indirect application in other related technical fields is included in the scope of protection of the present invention.
[0198] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0199] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of the flows and / or blocks in the flowchart and / or block diagram can also be implemented. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0200] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including instruction means, and the instruction means implements the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0201] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide means for implementing the functions in the flowFigure 1 One process or multiple processes and / or boxes Figure 1 Steps of the functions specified in one box or multiple boxes
[0202] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the above embodiments, those of ordinary skill in the art should understand that modifications or equivalent replacements can still be made to the specific implementation manners of the present invention. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention shall be covered by the protection scope of the claims of the present invention.
Claims
1. A method for pre-recording a surveillance video, characterized in that: include: Start the video surveillance device and detect whether the video surveillance device is connected to the SD card; If it is confirmed that the SD card is connected and the connection state of the SD card is stable, the SD card is used to store the video data recorded by the video surveillance device, and the video data storage area preset on the SD card is used as the pre-recorded data storage area for the video data; If it is confirmed that the SD card is not connected, the memory of the video surveillance device is used as a pre-recorded data buffer area for caching the video data recorded by the video surveillance device; wherein the pre-recorded data buffer area caches the video data according to a rule of storing a key frame at each preset period, and the preset period is 3-6 seconds; In response to monitoring a preset event, a video pre-recording function is started and video data is read from the pre-recorded data storage area or the pre-recorded data buffer area to form pre-recorded video data.
2. The method for pre-recording surveillance video according to claim 1, characterized in that: The step of reading the video data from the pre-recorded data buffer area includes: Obtain a first pre-recording duration, and determine an actual pre-recording duration according to the first pre-recording duration and the maximum pre-recording duration currently supported by the memory; wherein the first pre-recording duration is calculated according to the available capacity of the memory and the currently executed task when the video surveillance device is started; the maximum pre-recording duration is the longest pre-recording duration that the ring buffer serving as the pre-recording data buffer area can currently support when the preset event is monitored; when the maximum pre-recording duration is not less than the first pre-recording duration, the actual pre-recording duration is equal to the first pre-recording duration; when the maximum pre-recording duration is less than the first pre-recording duration, the actual pre-recording duration is equal to the maximum pre-recording duration; According to the determined actual pre-recording duration, the video recording data is read from the pre-recording data buffer area.
3. The method for pre-recording surveillance video according to claim 2, characterized in that: The step of reading the video data from the pre-recorded data buffer area according to the determined actual pre-recorded time includes: Obtaining the occurrence time of the preset event, and using the occurrence time as the end time of the pre-recorded video data; According to the determined actual pre-recording duration, video data having a duration equal to the actual pre-recording duration is read from the pre-recording data buffer; wherein the start time of the pre-recorded video data is equal to the end time minus the actual pre-recording duration.
4. The method for pre-recording surveillance video according to claim 1, characterized in that: The reading of the video data from the pre-recorded data storage area includes: obtaining a preset second pre-recording time length, and reading the video data from the pre-recorded data storage area according to the preset second pre-recording time length.
5. The method for pre-recording surveillance video according to claim 4, characterized in that: The step of reading the video data from the pre-recorded data storage area according to the preset second pre-recorded time length comprises: Obtaining the occurrence time of the preset event, and locating a section of video data corresponding to the time period closest to the occurrence time stored in the pre-recorded data storage area; Starting from the located section of video data, video data with a duration equal to the preset second pre-recording duration is read from the pre-recorded data storage area; wherein the start time of the pre-recorded video data is equal to the occurrence time minus the preset second pre-recording duration, and the end time of the pre-recorded video data is the occurrence time.
6. The method for pre-recording surveillance video according to claim 1, characterized in that: The preset events include: preset motion events detected by a camera or an infrared sensor, preset sound events detected by a sound sensor, and preset access control switch events detected by an access control sensor.
7. The method for pre-recording surveillance video according to claim 1, characterized in that: After the video surveillance device is started, the method further includes: Detecting whether a connection is established between the video surveillance device and the cloud storage server; If it is confirmed that the connection is established and the connection is in a stable state, the pre-recorded video data is sent to the cloud storage server through the connection after the video pre-recording function is started; If it is confirmed that the connection is established and the connection is in an interrupted state, re-establish the connection between the video surveillance device and the cloud storage server until it is confirmed that the connection is in a stable state again; when the connection is in a stable state again, after starting the video pre-recording function, the pre-recorded video data is sent to the cloud storage server through the re-established connection; If it is confirmed that no connection is established, a connection is established between the video surveillance device and the cloud storage server, and it is confirmed that the connection is in a stable state; when the connection is in a stable state, the pre-recorded video data is sent to the cloud storage server through the established connection after starting the video pre-recording function.
8. The method for pre-recording surveillance video according to claim 7, characterized in that: After the preset event is monitored, the response further includes: Obtaining a preset video recording duration and the occurrence time of the preset event; wherein the preset video recording duration is 3-90 seconds; The occurrence time is used as the start time of the video data, and the video data is continuously recorded for a duration equal to the preset video duration, and the recorded video data is sent to the cloud storage server in real time; wherein, a connection is established between the cloud storage server and the video surveillance device and the connection is in a stable state, and the end time of the video data is equal to the occurrence time plus the preset video duration.
9. An electronic device, the electronic device being an embedded device, characterized in that: include: A memory for storing program instructions; as well as A processor, configured to execute the program instructions to implement the steps of the method for pre-recording a surveillance video as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the method for pre-recording a surveillance video as described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Hard disc video recording method
CN101365088A
Alarm video recording method and device
CN104408109A
External memory card processing method and related products
CN111352772A
Video pre-recording method and cloud storage system
CN111405220A
Video recording method and display device
CN116456142A