Data processing method and device and electronic equipment
By caching and uploading video data in units of cloud storage segments, the network camera performs caching and uploading in parallel when it detects a target event, which solves the power consumption problem of the network camera while waiting to upload, and achieves efficient video data transmission and low power consumption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN MICROBT ELECTRONICS TECH CO LTD
- Filing Date
- 2024-10-25
- Publication Date
- 2026-04-28
AI Technical Summary
Network cameras are in an inactive state while waiting to upload video data, which increases power consumption and leads to unnecessary energy consumption.
Video data is cached and uploaded in units of cloud storage segments. When the network camera detects a target event, it caches the video data and adds cloud storage segments to the queue in units of GOP. Threads execute caching and uploading in parallel, generate video index files and upload them to the cloud server.
It reduces the idle waiting time of network cameras, lowers power consumption, and does not affect the overall video playback when individual cloud storage segments are lost, thus improving the efficiency and memory utilization of network cameras.
Smart Images

Figure CN121940561A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network camera technology, and in particular to a data processing method, apparatus, and electronic device. Background Technology
[0002] A network camera is a new generation of camera that combines traditional camera technology with network technology, and can be used in the field of video surveillance. After recording video, a network camera can upload the recorded video to a cloud server for users to view.
[0003] Network cameras typically feature functions such as pedestrian tracking, motion detection, and no-go zone alarms. To reduce power consumption, network cameras are in sleep mode by default. When a target event is detected, the network camera enters working mode and begins recording video of that event. After the complete video buffer of the target event is finished, it is uploaded to the cloud server. During the upload process, the camera waits for the upload result. If the upload is successful, it enters sleep mode; if the upload fails, it either re-uploads the video or discards it.
[0004] In related technologies, the process of a network camera waiting to upload data is an idle waiting process, which is an ineffective working state and increases the unnecessary power consumption of the network camera. Summary of the Invention
[0005] This invention provides a data processing method, apparatus, and electronic device that can greatly reduce the idle waiting time of network cameras and lower their power consumption.
[0006] In a first aspect, embodiments of the present invention disclose a data processing method applied to a network camera, the method comprising:
[0007] If a target event is detected, cache the video data;
[0008] Whenever cached video data constitutes a cloud storage segment, the cloud storage segment is added to the first queue, and the start time of the cloud storage segment is recorded; the cloud storage segment is in units of GOP;
[0009] When the first queue contains at least one cloud storage fragment, the cloud storage fragments in the first queue are uploaded to the cloud server sequentially.
[0010] A video index file for the target event is generated and uploaded to the cloud server. The video index file includes index entries corresponding to each cloud storage segment of the target event, and the index entries record the start time of the corresponding cloud storage segment.
[0011] Secondly, embodiments of the present invention disclose a data processing method applied to a terminal device, the method comprising:
[0012] Download a video index file of a specified target event from a cloud server; the video index file includes index entries corresponding to each cloud storage segment of the specified target event, and the index entries record the start time of the corresponding cloud storage segment; the cloud server stores the video index file of the specified target event and each cloud storage segment of the specified target event; the cloud storage segments are in units of GOP;
[0013] Based on the index entries in the video index file, download links corresponding to each cloud-stored segment of the specified target event are constructed sequentially.
[0014] Download and play each cloud storage segment of the specified target event sequentially according to the download link corresponding to each cloud storage segment of the specified target event.
[0015] Thirdly, embodiments of the present invention disclose a data processing device applied to a network camera, the device comprising:
[0016] The detection caching module is used to cache video data if a target event is detected.
[0017] The segment generation module is used to add the cloud storage segment to the first queue whenever the cached video data constitutes a cloud storage segment, and to record the start time of the cloud storage segment; the cloud storage segments are in units of GOP;
[0018] The fragment upload module is used to sequentially upload cloud storage fragments in the first queue to the cloud server when the first queue contains at least one cloud storage fragment.
[0019] An index processing module is used to generate a video index file for the target event and upload it to the cloud server. The video index file includes index entries corresponding to each cloud storage segment of the target event, and the index entries record the start time of the corresponding cloud storage segment.
[0020] Fourthly, embodiments of the present invention disclose a data processing apparatus applied to a terminal device, the apparatus comprising:
[0021] The index download module is used to download a video index file of a specified target event from a cloud server. The video index file includes index entries corresponding to each cloud storage segment of the specified target event, and the index entries record the start time of the corresponding cloud storage segment. The cloud server stores the video index file of the specified target event and each cloud storage segment of the specified target event. The cloud storage segments are in units of GOP.
[0022] The link building module is used to sequentially build download links corresponding to each cloud-stored segment of the specified target event based on the index entries in the video index file.
[0023] The download and playback module is used to download and play each cloud storage segment of the specified target event sequentially according to the download links corresponding to each cloud storage segment of the specified target event.
[0024] Fifthly, embodiments of the present invention disclose an electronic device, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, wherein the executable instruction causes the processor to perform the steps of the data processing method as described above.
[0025] The embodiments of the present invention have the following advantages:
[0026] In this embodiment of the invention, when the network camera detects a target event, it caches video data and uploads the video data to the cloud server in units of cloud storage segments. The network camera enters the upload phase as soon as it generates a cloud storage segment, with the generation and uploading of cloud storage segments occurring in parallel. The network camera generates cloud storage segments while simultaneously uploading already generated segments, with the idle waiting time being only the upload duration of the last cloud storage segment. This significantly reduces the network camera's idle waiting time and lowers its power consumption.
[0027] Furthermore, the cloud storage segments are organized in groups of pictures (GOPs). Therefore, each cloud storage segment begins with an I-frame, and all subsequent P-frames can use this I-frame as a reference frame for correct decoding, preventing situations where P-frames lack a reference frame. In other words, each cloud storage segment is valid video data and can be decoded and played independently. The loss of individual cloud storage segments will not affect the normal playback of other segments. During playback on the terminal device, it will only manifest as frame skipping due to the loss of individual frames, and will not cause the entire video to become unplayable. Attached Figure Description
[0028] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is a flowchart illustrating the steps of an embodiment of the data processing method of the present invention;
[0030] Figure 2 This is a comparative diagram showing the maximum amount of redundant data generated by re-uploading;
[0031] Figure 3 This is a schematic diagram of a time-overlapping event;
[0032] Figure 4 This is a flowchart illustrating the steps of another embodiment of the data processing method of the present invention;
[0033] Figure 5 This is a structural block diagram of an embodiment of a data processing device according to the present invention;
[0034] Figure 6 This is a structural block diagram of another embodiment of the data processing device of the present invention;
[0035] Figure 7 This is a structural block diagram of an embodiment of the data processing system of the present invention;
[0036] Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0037] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0038] The terms "first," "second," etc., used in the specification and claims of this invention are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, the first object can be one or more. Furthermore, the term "and / or" in the specification and claims is used to describe the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. In embodiments of this invention, the term "multiple" refers to two or more, and other quantifiers are similar.
[0039] Reference Figure 1 The diagram illustrates a flowchart of an embodiment of a data processing method according to the present invention. The method is applied to a network camera and may include the following steps:
[0040] Step 101: If a target event is detected, cache the video data;
[0041] Step 102: Whenever cached video data constitutes a cloud storage segment, add the cloud storage segment to the first queue and record the start time of the cloud storage segment; the cloud storage segment is in units of GOP;
[0042] Step 103: When the first queue contains at least one cloud storage fragment, upload the cloud storage fragments in the first queue to the cloud server in sequence;
[0043] Step 104: Generate a video index file for the target event and upload it to the cloud server; the video index file includes index entries corresponding to each cloud storage segment of the target event, and the index entries record the start time of the corresponding cloud storage segment.
[0044] This invention provides a data processing method applicable to network cameras to reduce unnecessary power consumption during the process of uploading video data from the network camera to a cloud server, and to save the network camera's memory resources.
[0045] In practical implementation, to reduce power consumption, the network camera can enter a sleep state when no target event is detected; enter an operating state when a target event is detected; and enter a sleep state again when the detected target event ends. In sleep state, the network camera does not cache or upload the captured video data; furthermore, in sleep state, the network camera can capture low-resolution video data. In operating state, the network camera caches video data and uploads it to the cloud server; furthermore, in operating state, the network camera can capture high-resolution video data. The low-resolution and high-resolution settings can be configured according to actual needs.
[0046] In practical implementation, the network camera may have target detection capabilities. For example, the network camera may use a target detection algorithm to detect targets in the image of the shooting scene and determine whether a target event of a specified type exists in the shooting scene; or, it may use a PIR (Passive Infrared) sensor to determine whether a target object of a specified type exists in the shooting scene.
[0047] When a network camera detects a target event, it caches video data and uploads it to a cloud server for playback by terminal devices. This embodiment of the invention does not limit the target event. For example, detecting a target object, movement of items, or area intrusion confirms the detection of a target event; the target object is a specified object, such as a person or pet.
[0048] To reduce the waiting time of network cameras during video data upload and further reduce their power consumption, this embodiment of the invention uploads video data in units of GOP (Group of Pictures). A GOP is a group of consecutive image frames (i.e., frames). Each GOP contains a certain duration of video, such as 5 seconds. The starting frame of each GOP is an I-frame, and the length of a GOP is the interval between one I-frame and the next. The length of a GOP is configurable during encoding; a longer GOP provides a higher compression ratio. I-frames are keyframes in video compression, using intra-frame compression encoding and can be decoded independently without referencing other frames.
[0049] In this embodiment of the invention, if the network camera detects a target event, it caches video data. Whenever the cached video data constitutes a cloud storage segment, the cloud storage segment is added to a first queue, and the start time of the cloud storage segment is recorded. A cloud storage segment is equivalent to a Group of Pictures (GOP). While caching video data, the network camera simultaneously uploads the cloud storage segments in the first queue to the cloud server sequentially.
[0050] In practical implementation, thread 1 can cache (i.e., record and save) the video data of the target event. Whenever the cached video data constitutes a cloud storage segment, the segment is added to the first queue. Thread 2 then sequentially sends each cloud storage segment in the first queue to the cloud server. The two threads working in parallel improve the efficiency of the network camera uploading video data and reduce its waiting time. For example, after thread 1 generates the first cloud storage segment, it adds it to the first queue, allowing it to cache the second segment. After adding the first segment to the first queue, thread 2 can then send it to the cloud server. Threads 1 and 2 work in parallel; thread 1 continuously generates cloud storage segments, and thread 2 sequentially uploads these segments to the cloud server.
[0051] It should be noted that the sequential uploading of cloud storage fragments from the first queue to the cloud server can be done in preset numbers. These preset numbers can be integers greater than or equal to 1. For example, one cloud storage fragment can be uploaded at a time, or two cloud storage fragments can be uploaded at a time, and so on.
[0052] In an optional embodiment of the present invention, the method may further include:
[0053] After the last cloud storage segment of the target event is successfully uploaded, if no other target events are detected, it enters a dormant state.
[0054] In related technologies, the video is uploaded to the cloud server only after the complete video cache of the target event is completed. From the time the network camera starts uploading video data until it enters the sleep state, it needs to wait for the entire complete video to be uploaded, resulting in a long idle wait.
[0055] In this embodiment of the invention, the upload phase can begin as soon as a cloud storage segment is generated, with the generation and uploading of cloud storage segments occurring in parallel. For uploading N (N>1) cloud storage segments, the network camera generates and uploads already generated segments simultaneously, with the idle waiting time being only the upload duration of the Nth cloud storage segment. This significantly reduces the network camera's idle waiting time and power consumption. On the network camera side, this embodiment of the invention allows uploading to begin as soon as a cloud storage segment is generated. Therefore, the network camera's idle waiting time is reduced from the time required to upload the entire complete video in related technologies to the time required to upload the last cloud storage segment.
[0056] This invention uploads video data of a target event to a cloud server in units of Group of Pictures (GOPs). To ensure that terminal devices can play these GOPs in the correct order to form a complete video, this invention records the start time of each GOP during the generation process. Based on the start time of each GOP, a video index file for the target event is generated and uploaded to the cloud server. The video index file contains index entries corresponding to each GOP of the target event, with each index entry corresponding to the start time of a GOP. Through the video index file, the GOPs of the target event can be managed, allowing for sequential playback of the GOPs to form a complete video.
[0057] This invention does not limit the specific form of the video index file. In this embodiment, the video index file contains index entries corresponding to each cloud storage segment of the target event. Each index entry corresponds to the start time of a cloud storage segment; that is, the video index file can represent the chronological order of the cloud storage segments. Of course, in specific implementations, the video index file can also represent the chronological order of the cloud storage segments in other forms. For example, the cloud storage segments can be numbered according to the order in which they were generated, and each index entry in the video index file corresponds to the number of a cloud storage segment; that is, the video index file can represent the chronological order of the cloud storage segments through the order of their numbers.
[0058] It should be noted that this invention does not limit the format of the start time recorded in the index entries for cloud storage segments. For example, the start time can be the device system time, UTC (Coordinated Universal Time), or local timezone time, etc.
[0059] In one example, when a network camera detects a target event (e.g., event 1), thread 1 starts caching video data. Assuming the time of event 1 detection is 1690958337000 (device system time), after the first cloud storage segment (e.g., segment 1) is cached, segment 1 is added to the first queue, and its start time is recorded as 1690958337000. Thread 1 then continues caching the next cloud storage segment (e.g., segment 2). Simultaneously, thread 2 uploads the cloud storage segments in the first queue to the cloud server sequentially. After segment 2 is cached, thread 1 adds segment 2 to the first queue, records its start time as 1690958340000, and then continues caching the next cloud storage segment (e.g., segment 3). This process continues in a similar manner.
[0060] Furthermore, the start time of the cloud storage segment can be the start time of the keyframe in the cloud storage segment. In this embodiment of the invention, the recorded start time is the system time of the network camera, such as 1690958337000.
[0061] This invention does not restrict the naming conventions for the cloud storage segment filenames and the video index filenames. For example, the cloud storage segment filename can be: cloud storage segment start time.gop. The target event video index filename can be: target event occurrence time.index. The target event occurrence time can be the start time of the first cloud storage segment of the target event.
[0062] Assuming that four cloud storage segments were recorded for event 1, and each cloud storage segment is named according to its start time, then event 1 includes the following four cloud storage segments: 1690958337000.gop, 1690958340000.gop, 1690958343000.gop, and 1690958346000.gop.
[0063] In this embodiment of the invention, a video index file for event 1 can be generated, denoted as "1690958337000.index". "1690958337000.index" includes index entries corresponding to each cloud storage segment of event 1, with each index entry corresponding to the start time of a cloud storage segment. If the cloud storage segment files are named according to their start times, then the filenames of each cloud storage segment of the target event can be used as index entries in the video index file of the target event. For example, the index entries in the video index file "1690958337000.index" for event 1 are shown in Table 1.
[0064] Table 1
[0065] 1690958337000.gop 1690958340000.gop 1690958343000.gop 1690958346000.gop
[0066] Alternatively, the start time of each cloud-stored segment of the target event can be used as the index entry in the video index file of the target event. For example, the index entries in the video index file "1690958337000.index" for event 1 are shown in Table 2.
[0067] Table 2
[0068] 1690958337000 1690958340000 1690958343000 1690958346000
[0069] In an optional embodiment of the present invention, generating the video index file of the target event may include:
[0070] After all cloud storage segments of the target event are successfully uploaded, a video index file for the target event is generated based on the start time of each cloud storage segment.
[0071] After all cloud-stored segments of the target event have been uploaded, a video index file for the target event can be generated and uploaded to the cloud server.
[0072] In practical implementation, the network camera can upload the video index file of the target event to a first designated path on the cloud server, and upload each cloud-stored segment of the target event to a second designated path on the cloud server. The first designated path and the second designated path can be pre-agreed fixed paths or user-defined paths, etc. Furthermore, the first designated path and the second designated path can be the same or different. The cloud server stores the video index file of the target event and each cloud-stored segment of the target event. Therefore, the terminal device can download the video index file of the target event from the cloud server, and then, by parsing the video index file, sequentially download and play each cloud-stored segment of the target event according to the index entries in the video index file, thereby enabling the playback of the complete video of the target event on the terminal device.
[0073] The cloud server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0074] Through the embodiments of the present invention, the memory resources required for network cameras to cache video data can also be reduced. Taking the aforementioned event 1 as an example, assuming that the data size of segment 1 is 1024Kb, the data size of segment 2 is 899Kb, the data size of segment 3 is 561Kb, and the data size of segment 4 is 961Kb. In related technologies, before uploading the video data of event 1, the total data size that the network camera needs to cache is 1024Kb + 899Kb + 561Kb + 961Kb = 3445Kb. After all 3445Kb of video data has been cached, it is then uploaded to the cloud server.
[0075] Using the technical solution of this invention, each cached cloud storage segment can be uploaded, and once a cloud storage segment is uploaded, the memory space occupied by that segment can be released. Therefore, in this embodiment of the invention, before uploading the video data of event 1, the total amount of data that the network camera needs to cache is only the size of the currently cached cloud storage segment and the size of the cloud storage segments that have not yet been released. For example, during the generation of segment 1, 1024Kb of memory space is gradually allocated for caching segment 1; after segment 1 is generated, it enters the first queue and begins generating segment 2. During the generation of segment 2, 899Kb of memory space is gradually allocated for caching segment 2; at this time, the total amount of data occupied by the cache is 1024Kb + 899Kb; after segment 1 is successfully uploaded, the memory space it occupies can be released, and 1024Kb of memory space will be gradually released; after segment 2 is generated, it enters the first queue and begins generating segment 3. During the generation of segment 3, 561Kb of memory space is gradually allocated for caching segment 3; after segment 2 is successfully uploaded, the memory space it occupies can be released, and 899Kb of memory space will be gradually released; and so on. Through the embodiments of the present invention, the memory space required for network cameras to cache video data can be greatly reduced, and the freed memory space can be used to provide temporary caching for other needs, thereby improving the performance of network cameras.
[0076] In an optional embodiment of the present invention, the method may further include:
[0077] Step S11: Add the cloud storage segments that failed to upload to the second queue;
[0078] Step S13: After the cloud storage fragments in the first queue are uploaded, the cloud storage fragments in the second queue are re-uploaded.
[0079] In this embodiment of the invention, if the upload of a cloud storage segment fails due to network issues or other reasons, the failed cloud storage segment can be added to a second queue. The second queue is used to re-upload the failed cloud storage segment.
[0080] Taking event 1 above as an example, after the network camera generates segment 1, it adds segment 1 to the first queue, at which point segment 1 is at the head of the first queue. The queue follows a first-in, first-out (FIFO) principle. Therefore, the network camera reads the head element of the first queue (i.e., segment 1) and uploads segment 1 to the cloud server. Simultaneously, the network camera generates segment 2. After generating segment 2, the network camera adds segment 2 to the first queue. If segment 1 has already been uploaded, segment 2 is at the head of the first queue, and the network camera uploads segment 2 to the cloud server. If segment 1 has not yet been uploaded, the camera waits for it to complete. This process continues. "Upload completion" includes both successful and failed uploads. Assuming segment 1 is uploaded successfully, segment 2 is at the head of the first queue, and the network camera reads the head element of the first queue (i.e., segment 2) and uploads segment 2 to the cloud server. Assuming segment 2 fails to upload, segment 2 is added to the second queue. At this point, segment 3 is at the head of the first queue, and the network camera reads the head element of the first queue (i.e., segment 3) and uploads segment 3 to the cloud server. Assuming fragment 3 is successfully uploaded, fragment 4 is at the head of the first queue. The network camera reads the head element of the first queue (i.e., fragment 4) and uploads fragment 4 to the cloud server. Assuming fragment 4 is successfully uploaded, the cloud-stored fragments in the second queue can then be uploaded to the cloud server sequentially to re-upload any fragments that failed to upload. If only fragment 2 is in the second queue, then fragment 2 is uploaded to the cloud server. Assuming fragment 2 is successfully uploaded, all cloud-stored fragments from event 1 have been successfully uploaded.
[0081] It should be noted that this embodiment of the invention does not restrict the timing of uploading cloud storage segments in the second queue. Since the cloud storage segments in the first queue are being uploaded for the first time, and to ensure that cloud storage segments generated earlier in a real-time playback scenario can be uploaded to the cloud server first, the cloud storage segments in the second queue can be uploaded only after the cloud storage segments in the first queue have been uploaded.
[0082] Furthermore, in this embodiment of the invention, the filename of each cloud storage segment can be named according to the start time of the cloud storage segment, and the index entry corresponding to the cloud storage segment in the video index file records the start time of the cloud storage segment. Therefore, in non-real-time playback (such as on-demand or replay) scenarios, the upload order of cloud storage segments will not affect the playback order. In specific implementation, cloud storage segments in the second queue can be uploaded at an appropriate time before the cloud storage segments in the first queue have been uploaded; or, a new thread can be started to upload cloud storage segments in the second queue at the same time as uploading cloud storage segments in the first queue.
[0083] This invention uploads video data to the cloud server in units of cloud storage segments. These cloud storage segments are organized into Groups of Pictures (GOPs), with each GOP starting as a 1-frame and its length consisting of the interval between the first and second 1-frames. Therefore, each cloud storage segment starts with a 1-frame, and all subsequent P-frames can use this 1-frame as a reference frame for correct decoding, preventing situations where a P-frame lacks a reference frame. In other words, each cloud storage segment is valid video data and can be decoded and played independently. The loss of individual cloud storage segments does not affect the normal playback of other segments. During playback on the terminal device, only frame skipping due to the loss of individual frames occurs; the entire video remains unplayable.
[0084] Furthermore, through the embodiments of the present invention, the maximum amount of redundant data generated by re-uploading can also be reduced. (See also...) Figure 2 This diagram illustrates a comparison of the maximum amount of redundant data generated during re-upload. The maximum amount of redundant data refers to the maximum amount of data that a network camera needs to re-upload if an upload failure occurs during a single upload request from the network camera to the cloud server. For example... Figure 2 As shown, in related technologies, the complete video of the target event is uploaded to the cloud server only after all video data of the target event has been cached, i.e., after the complete video of the target event has been generated. The network camera needs to upload the data of the complete video in a single upload request to the cloud server. In the event that the last frame of the complete video fails to upload, a maximum redundant data amount is generated, which is the total data volume of the complete video minus the data of the last frame. In this embodiment of the invention, uploads are performed in units of cloud storage segments. The network camera only needs to upload the data volume of one cloud storage segment in a single upload request to the cloud server. In the event that the last frame of the cloud storage segment fails to upload, a maximum redundant data amount is generated, which is the total data volume of the cloud storage segment minus the data of the last frame.
[0085] In this embodiment of the invention, video data is uploaded to the cloud server in units of cloud storage segments. Only cloud storage segments that fail to upload need to be re-uploaded, instead of the entire complete video of the target event, which greatly reduces the amount of redundant data generated by re-uploading.
[0086] In specific implementations, this embodiment of the invention does not impose a time limit on the network camera generating the video index file of the target event. Optionally, the video index file of the target event can be generated and uploaded to the cloud server after all cloud storage segments of the target event have been successfully uploaded; or, the video index file of the target event can be generated and uploaded to the cloud server immediately after the first cloud storage segment of the target event has been successfully uploaded; and so on.
[0087] In this embodiment of the invention, for a specific target event, the network camera can generate a video index file for that target event after all cloud-stored segments of that event have been uploaded, and then upload it to the cloud server. The uploaded video index file contains index records for all cloud-stored segments. After downloading the video index file, the terminal device can sequentially construct download links for each cloud-stored segment based on the index entries in the video index file, thereby allowing it to download and play each cloud-stored segment in sequence.
[0088] In an optional embodiment of the present invention, generating the video index file of the target event may include:
[0089] After the first number of cloud storage segments of the target event are successfully uploaded, a video index file of the target event is generated based on the start time of each of the first number of cloud storage segments.
[0090] Furthermore, to achieve real-time playback, in this embodiment of the invention, for a specific target event, the network camera can generate a video index file for that target event and upload it to the cloud server after a first number of cloud-stored segments of that target event have been uploaded. The first number is a positive integer, less than the total number of cloud-stored segments of the target event; for example, the first number can be 1 or 2. The first number can be set as needed; the smaller the first number, the shorter the real-time playback delay; the larger the first number, the longer the real-time playback delay. This embodiment of the invention uses a first number of 1 as an example for explanation.
[0091] For example, after the first cloud storage segment of the target event is successfully uploaded, a video index file of the target event can be generated based on the start time of the first cloud storage segment. The video index file is then uploaded to the cloud storage server, and the terminal device can download the video index file to play the first cloud storage segment, thereby realizing the real-time playback function and reducing the playback delay of the terminal device.
[0092] In an optional embodiment of the present invention, the method may further include:
[0093] Step S21: Whenever the second number of cloud storage segments of the target event are successfully uploaded, update the video index file of the target event according to the start time of each of the second number of cloud storage segments;
[0094] Step S22: Upload the updated video index file to the cloud server, and after the last cloud storage segment of the target event is successfully uploaded, add an end marker to the last updated video index file.
[0095] The second number can be set as needed, and the first number and the second number can be the same or different. In this embodiment of the invention, the first number and the second number are both 1 as an example.
[0096] After the first cloud-stored segment of the target event is successfully uploaded, a video index file for the target event is generated based on the start time of the first cloud-stored segment. This video index file contains index entries corresponding to the first cloud-stored segment, and is then uploaded to the cloud storage server. The terminal device can then download this video index file to play the first cloud-stored segment. When the second cloud-stored segment of the target event is successfully uploaded, the network camera updates the video index file for the target event based on the start time of the second cloud-stored segment. The updated video index file contains index entries corresponding to both the first and second cloud-stored segments, and is then uploaded to the cloud server. The terminal device can then download this updated video index file to continue playing the second cloud-stored segment. This process continues in the same manner.
[0097] After the network camera uploads the video index file containing the index entry of the first cloud-stored segment to the server, the terminal device can download the video index file and play the first cloud-stored segment. The terminal device needs to determine whether there are any more cloud-stored segments to be played. To facilitate this determination, this embodiment of the invention adds an end marker to the last updated video index file after the last cloud-stored segment of the target event has been successfully uploaded, indicating that all cloud-stored segments of the target event have been successfully uploaded. At this time, the last updated video index file includes the index entries corresponding to all cloud-stored segments of the target event, as well as the end marker. Thus, after the terminal device downloads the video index file (or the updated video index file) of the target event, it can check whether there are any more cloud-stored segments to be played by checking whether the video index file contains the end marker. If there is no end marker, it means that the network camera is still uploading new cloud-stored segments, that is, there are still more cloud-stored segments to be played. The terminal device can download the latest updated video index file from the cloud server, and thus play the cloud-stored segments corresponding to the newly added index entries in the latest downloaded video index file. Therefore, this embodiment of the invention enables network cameras to simultaneously generate cloud storage segments and upload them to a cloud server, while terminal devices simultaneously download and play these segments from the cloud server, achieving real-time playback and reducing playback latency for the terminal devices. If the currently downloaded video index file contains an end marker, it indicates that all cloud storage segments of the target event have been successfully uploaded. The video index file downloaded by the terminal device contains index entries for all cloud storage segments of the target event. After the cloud storage segment corresponding to the last index entry in the video index file has finished playing, all cloud storage segments of the target event have been played.
[0098] In an optional embodiment of the present invention, the method may further include:
[0099] An event message corresponding to the target event is constructed and uploaded to a file server; the event message includes a first field, a second field, and a third field; the first field is used to record the download address of the video index file of the target event; the second field is used to record the start time of the first cloud-stored segment of the target event; and the third field is used to record the duration of the target event.
[0100] In this embodiment of the invention, the network camera can record video data corresponding to the target event and upload it to a cloud server for download and playback by terminal devices. Furthermore, the network camera can also construct an event message corresponding to the target event and upload it to a file server, allowing terminal devices to query which target events occurred and select which to play back.
[0101] The network camera can monitor and record the start and end times of each target event, and construct an event message for each target event. Based on the start and end times of each target event, the duration of that target event can be determined. The download address of the video index file for the target event is determined based on a first specified path. Therefore, based on the download address of the video index file for the target event, the start time of the target event (i.e., the start time of the first cloud-stored segment of the target event), and the duration of the target event, the event message for that target event can be constructed.
[0102] This embodiment of the invention does not impose a time limit on the construction of the event message and its upload to the file server. Optionally, the event message corresponding to the target event can be constructed and uploaded to the file server after all cloud-stored segments of the target event have been successfully uploaded, as well as the video index file of the target event, for the terminal device to select for playback. In this case, only the video index file of the target event needs to be downloaded once to sequentially play each cloud-stored segment of the target event.
[0103] Alternatively, after the first cloud-stored segment of the target event is successfully uploaded, and the video index file of the target event is also successfully uploaded, the event message corresponding to the target event can be constructed and uploaded to the file server for playback by the terminal device. In this case, it may be necessary to download the video index file of the target event (or the updated video index file) multiple times, generating cloud-stored segments while playing them.
[0104] In one example, a network camera detects event 1, begins caching video data, and after sending segment 1 to the cloud server, constructs an event message corresponding to event 1 and uploads it to the file server. The event message for event 1 includes three fields: the first field records the download address of the video index file for event 1; the second field records the start time of the first cloud-stored segment of event 1 (i.e., the time event 1 occurred); and the third field records the duration of event 1. Users can log in to the file server using their terminal devices to view the event messages corresponding to each target event stored on the file server, thereby enabling playback of the video data for the selected target event.
[0105] For example, a user logs into a file server via a terminal device to view event messages and selects a specific event message. In response to the user's selection, the terminal device retrieves the target download address of the video index file for the selected event based on the first field of the selected event message. Using this target download address, the device downloads the target video index file for the selected event. After downloading, it parses the index entries in the target video index file, sequentially constructs download links for each cloud-stored segment, and then downloads and plays each cloud-stored segment in sequence.
[0106] Furthermore, when the network camera detects a target event, it can also record the event type of the target event. When constructing the event message for the target event, the event type can be recorded within the constructed event message. Thus, the terminal device can determine the event type of the corresponding target event when viewing the event message. The event type could be, for example, a target object, object movement, or area intrusion. The event message may also include a fourth field, which is used to record the event type of the target event.
[0107] In an optional embodiment of the present invention, generating the video index file of the target event may include:
[0108] If a time overlap event is detected, a shared video index file is generated for the time overlap event; the time overlap event refers to at least two target events having a time intersection; the shared video index file includes an index entry for each cloud storage segment within a duration from the first target event in the time overlap event to the end of the last target event in the time overlap event.
[0109] A time-overlapping event refers to a situation where the durations of at least two target events overlap. For example, if event 1 starts at 9:00 and ends at 9:15, and event 2 starts at 9:05 and ends at 9:30, then events 1 and 2 have a time overlap, which is from 9:05 to 9:15. In this embodiment of the invention, events 1 and 2 are referred to as time-overlapping events.
[0110] For the same network camera, when time overlap events occur, the video data generated within the time intersection is identical. For example, in the example above, the video data generated between 9:05 and 9:15 is the same for events 1 and 2. Therefore, to further save the memory space required for storing video index files in network cameras, cloud servers, and terminal devices, this embodiment of the invention generates a shared video index file for time overlap events. That is, target events with time overlap can share a single video index file. The shared video index file includes an index entry for each cloud-stored segment within a duration from the first target event (e.g., event 1) in the time overlap events to the end of the last target event (e.g., event 2) in the time overlap events.
[0111] For example, a shared video index file can be generated for events 1 and 2 above. Assume event 1 includes segment 1, segment 2, segment 3, and segment 4. Event 2 includes segment 2, segment 3, segment 4, segment 5, and segment 6. The shared video index files for events 1 and 2 will sequentially include index entries corresponding to segment 1, segment 2, segment 3, segment 4, segment 5, and segment 6.
[0112] When a network camera constructs an event message for a target event, if it detects that the target event is a time-overlapping event with other target events, it sets the value of the first field to the download address of the shared video index file of the time-overlapping event when constructing the event message.
[0113] Furthermore, when a network camera detects a time overlap event, it can record the event. Thus, when generating the video index file, a shared video index file is created for the recorded time overlap event; and when constructing an event message for that time overlap event, the value of the first field in the event message is set to the download address of the shared video index file.
[0114] Reference Figure 3 This illustrates a schematic diagram of a time-overlapping event. For example... Figure 3 As shown, after event 1 occurs, event 2 occurs before event 1 ends. Events 1 and 2 overlap in time, making them time-overlapping events. Initially, assuming the network camera is in sleep mode, when event 1 is detected, the start time of event 1 (i.e., the start time of the first cloud storage segment of event 1), such as 1690958337000, is recorded, and video data caching begins simultaneously. Each cloud storage segment generated is added to the first queue. While generating cloud storage segments, the generated segments are simultaneously sent through the first queue. Before event 1 ends, the network camera detects event 2, records the start time of event 2 (i.e., the start time of the first cloud storage segment of event 2), such as 1690958343000. Events 1 and 2 are recorded as time-overlapping events, and video data caching continues, with each cloud storage segment generated being added to the first queue. When event 1 ends, the end time of event 1 is recorded, and when event 2 ends, the end time of event 2 is recorded.
[0115] The present invention does not limit the timing of generating the shared video index file for time-overlapping events. Optionally, the shared video index file for the time-overlapping event can be generated after the last cloud-stored segment (e.g., segment 6) of the last target event (e.g., event 2) in the time-overlapping event is successfully uploaded. In this example, the generated shared video index file is denoted as 1690958337000.index.
[0116] Optionally, a shared video index file for the time-overlapping events can be generated after the first cloud storage segment (e.g., segment 1) of the first target event (e.g., event 1) in the time-overlapping events is successfully uploaded. For example, in this example, assuming the network camera detects pedestrian 1 entering the frame, i.e., when event 1 is detected, it starts caching video data. After segment 1 is successfully uploaded, a video index file for event 1, such as 1690958337000.index, is generated and uploaded to the cloud server. Before event 1 ends (before pedestrian 1 leaves the frame), the network camera detects pedestrian 2 entering the frame, i.e., event 2 is detected. Events 1 and 2 are recorded as time-overlapping events, and the video index file of event 1 is directly used for event 2, i.e., the video index file of event 1, such as 1690958337000.index, is used as the shared video index file for events 1 and 2. Video data continues to be cached, and each cloud storage segment generated is added to the first queue. The shared video index file can be updated after each cloud storage segment is successfully uploaded. Assuming event 1 ends before event 2, then after the last cloud storage segment of event 2 is successfully uploaded, an end marker will be added to the shared video index file after the last update.
[0117] The index entries corresponding to the cloud storage segments of Event 1 and Event 2 are recorded in the shared video index file 1690958337000.index, which contains the index entries of the same cloud storage segments of Event 1 and Event 2. This eliminates the need to generate a separate video index file for Event 2, thereby reducing the storage of duplicate index entries (such as the index entries of the same cloud storage segments of Event 1 and Event 2) in the video index file and thus reducing the storage space occupied by the video index file.
[0118] Furthermore, if the network camera does not detect any other target events after the last cloud storage segment of the last target event in the time-overlapping events is successfully uploaded, it can enter a sleep state.
[0119] Understandably, if the network camera detects pedestrian 3 entering the frame (i.e., detects event 3), and events 1 and / or 2 have not yet ended, then events 1, 2, and 3 are time-overlapping events. The processing is the same: 1690958337000.index is used as the shared video index file for events 1, 2, and 3. For example, suppose the network camera detects event 3 before event 1 has ended but event 2 has ended. In this case, events 1 and 3 are recorded as time-overlapping events, and the video index file 1690958337000.index of event 1 is directly used for event 3; that is, the video index file 1690958337000.index of event 1 is used as the shared video index file for events 1, 2, and 3. For example, suppose that when the network camera detects that event 3 has occurred, event 1 has ended but event 2 has not yet ended, then events 2 and 3 are recorded as time-overlapping events. And for event 3, the video index file of event 2 is used directly. The video index file of event 2 is a shared video index file of event 1 and event 2, 1690958337000.index. Therefore, the video index file of event 1, 1690958337000.index, is used as the shared video index file of event 1, event 2 and event 3.
[0120] In specific implementation, the processing procedure for two or more time-overlapping events is the same as that for two time-overlapping events. Therefore, in this embodiment of the invention, event 1 and event 2 are mainly used as examples of time-overlapping events for explanation.
[0121] In this example, the network camera can construct an event message for event 1 and upload it to a file server. The event message for event 1 includes the download address of the video index file for event 1, the start time of the first cloud-stored segment of event 1, and the duration of event 1.
[0122] In one example, the field structure of the event message for event 1 is as follows:
[0123] “video”: https: / / first specified path / 1690958337000.index
[0124] "first gop time": 1690958337000
[0125] “duration”: 15
[0126] The first field, "video," records the download address of the video index file for event 1. The second field, "firstgop time," records the start time of the first cloud-stored segment of event 1. The third field, "duration," records the duration of event 1.
[0127] Similarly, the network camera can construct an event message for Event 2 and upload it to the file server. The event message for Event 2 includes the download address of the video index file for Event 2, the start time of the first cloud-stored segment of Event 2, and the duration of Event 2.
[0128] In one example, the field structure of the event message for event 2 is as follows:
[0129] “video”: https: / / first specified path / 1690958337000.index
[0130] "first gop time": 1690958343000
[0131] "duration": 25
[0132] Events 1 and 2 are time-overlapping events, sharing the same video index file "1690958337000.index". Therefore, the value of the first field "video" in the event messages of both events is the same: "https: / / first specified path / 1690958337000.index". By reading the value of the first field "video", the terminal device can obtain the download address of the shared video index file "1690958337000.index" and download it using that address.
[0133] For example, a user logs into a file server via a terminal device and selects event message 1 to play back the video data of event 1. The user device responds to the user's selection and, based on the value of the first field "video" in the event message 1, obtains the download address of the video index file "1690958337000.index", which can then be downloaded locally. The terminal device, based on the value of the second field "first gop time" in the event message 1, obtains the start time of the first cloud storage segment of event 1, such as 1690958337000. The terminal device compares this obtained start time (e.g., 1690958337000) with the start times of each cloud storage segment recorded in the video index file "1690958337000.index", and the matching index entry is the index entry corresponding to the first cloud storage segment of event 1, referred to as the target index entry. Based on the target index, a download link for the first cloud-stored segment of Event 1 can be constructed, which in turn allows the first cloud-stored segment to be downloaded and played.
[0134] After finding the index entry corresponding to the first cloud storage segment of Event 1, the next index entry is the index entry corresponding to the second cloud storage segment of Event 1. This process continues until the index entries corresponding to each cloud storage segment of Event 1 are determined. Therefore, the terminal device can sequentially construct download links for each cloud storage segment of Event 1, thereby downloading and playing each cloud storage segment of Event 1.
[0135] Furthermore, since events 1 and 2 are time-overlapping events, the video index file "1690958337000.index" is a shared video index file for events 1 and 2. Since event 1 ends before event 2, the index entry corresponding to the last cloud-stored segment of event 1 is not the last index entry in this shared video index file. The terminal device can determine the index entry of the last cloud-stored segment of event 1 using the start time and duration of event 1.
[0136] For example, a user logs into a file server via a terminal device and selects event message 1 for playback. The terminal device downloads the shared video index file "1690958337000.index", parses the index entries in the shared video index file, finds the first index entry which corresponds to the first cloud-stored segment of event 1, and then constructs a download link for the first cloud-stored segment of event 1 (segment 1) based on the first index entry, thereby downloading and playing the first cloud-stored segment of event 1. Further, the terminal device can determine whether the total duration of the downloaded cloud-stored segments of event 1 has reached the duration of event 1. If it has not reached the duration of event 1, it constructs a download link for the next cloud-stored segment of event 1 based on the next index entry, downloads and plays it. If the total duration of the downloaded cloud-stored segments of event 1 has reached the duration of event 1, it means that all cloud-stored segments of event 1 have been downloaded, and the construction of the download link for the next cloud-stored segment stops. For example, after the fourth cloud storage segment (segment 4) of event 1 is downloaded, the total duration of the downloaded cloud storage segments of event 1 (the total duration of segment 1, segment 2, segment 3 and segment 4) reaches the duration of event 1, indicating that all cloud storage segments of event 1 have been downloaded.
[0137] For example, a user logs into a file server via a terminal device and selects event message 1 for playback. The terminal device downloads the shared video index file "1690958337000.index", parses the index entries in the shared video index file, and assuming that the second index entry corresponds to the first cloud-stored segment of event 2, then a download link for the first cloud-stored segment of event 2 (segment 2) is constructed based on the second index entry, downloaded, and played. The terminal device determines whether the total duration of the downloaded cloud-stored segments of event 2 has reached the duration of event 2. If it has not reached the duration of event 2, it continues to construct a download link for the next cloud-stored segment of event 2 based on the next index entry, downloads, and plays. If the total duration of the downloaded cloud-stored segments of event 2 has reached the duration of event 2, then the construction of the download link for the next cloud-stored segment is stopped. For example, after the fifth cloud storage segment (segment 6) of event 2 is downloaded, the total duration of the downloaded cloud storage segments of event 2 (the total duration of segments 2, 3, 4, 5 and 6) reaches the duration of event 2, indicating that all cloud storage segments of event 2 have been downloaded.
[0138] In summary, in this embodiment of the invention, when the network camera detects a target event, it caches video data and uploads the video data to the cloud server in units of cloud storage segments. The network camera enters the upload phase as soon as it generates a cloud storage segment, with segment generation and uploading occurring in parallel. The network camera generates and uploads already generated cloud storage segments simultaneously, with the idle waiting time being only the upload duration of the last cloud storage segment, significantly reducing idle waiting time and power consumption. Furthermore, the cloud storage segments are in units of Group of Pictures (GOPs). Therefore, the starting frame of each cloud storage segment is an I-frame, and subsequent P-frames can use this I-frame as a reference frame for correct decoding, preventing situations where P-frames lack a reference frame. That is, each cloud storage segment is valid video data and can be decoded and played independently. The loss of individual cloud storage segments does not affect the normal playback of other segments. During playback on the terminal device, only frame skipping due to the loss of individual frames occurs; the entire video remains unplayable.
[0139] Reference Figure 4 The diagram illustrates a flowchart of another embodiment of the data processing method of the present invention. The method is applied to a terminal device and may include the following steps:
[0140] Step 201: Download the video index file of the specified target event from the cloud server; the video index file includes index entries corresponding to each cloud storage segment of the specified target event, and the index entries record the start time of the corresponding cloud storage segment; the cloud server stores the video index file of the specified target event and each cloud storage segment of the specified target event; the cloud storage segments are in units of GOP;
[0141] Step 202: Based on the index entries in the video index file, construct the download links corresponding to each cloud storage segment of the specified target event in sequence;
[0142] Step 203: Download and play each cloud storage segment of the specified target event sequentially according to the download links corresponding to each cloud storage segment of the specified target event.
[0143] The data processing method provided by this invention can be applied to terminal devices, which have video playback capabilities. These terminal devices may include smartphones, desktop computers, tablets, laptops, digital assistants, augmented reality (AR) / virtual reality (VR) devices, intelligent voice interaction devices, smart home appliances, smart wearable devices, in-vehicle terminal devices, and other electronic devices.
[0144] In this embodiment of the invention, the network camera can record video data corresponding to a target event and upload it to a cloud server for download and playback by terminal devices. The network camera uploads the video data of the target event to the cloud server in units of cloud storage segments, with one cloud storage segment constituting one GOP.
[0145] The cloud server stores video index files of target events uploaded by network cameras, as well as various cloud-stored segments of the target events. Terminal devices can select and play video data of each target event stored in the cloud server. The specified target event refers to the target event selected by the terminal device.
[0146] For example, the cloud server stores the video index file of event 1 and each cloud storage segment of event 1, the video index file of event 2 and each cloud storage segment of event 2, and so on, and stores the video index file of event N and each cloud storage segment of event N, where N is a positive integer greater than 2.
[0147] Assume the video index file for event 1 is as shown in Table 1. When the terminal device selects to play the video data for event 1, event 1 is the designated target event. First, the video index file for event 1 is downloaded from the cloud server; then, the video index file is parsed, and based on each index entry in the video index file, download links for each cloud-stored segment of the designated target event are constructed sequentially, thereby downloading and playing each cloud-stored segment of the designated target event sequentially.
[0148] In this embodiment of the invention, the network camera can upload the video index file of the target event to a first designated path in the cloud server, and upload each cloud-stored segment of the target event to a second designated path in the cloud server. In this embodiment, the first and second designated paths are the same.
[0149] Furthermore, the terminal device can select a specific target event through the file server to play the corresponding video data. The file server can provide a download address for the index file of the target event, which includes a first specified path. The terminal device can download the index file of the target event based on the download address, and based on the first specified path and the start time recorded in each index entry in the video index file, download links for each cloud-stored segment can be constructed.
[0150] For example, suppose the download address of the index file for a specified target event is "https: / / first specified path / 1690958337000.index". After the terminal device downloads the index file "1690958337000.index" according to this download address, it parses the file to obtain the index entries shown in Table 1. Then, based on the first index entry, a download link for the first cloud-stored segment of the specified target event can be constructed, such as "https: / / first specified path / 1690958337000.gop". This download link allows the download and playback of the first cloud-stored segment (e.g., 1690958337000.gop). Based on the second index entry, the terminal device can construct a download link for the second cloud-stored segment of the specified target event, such as "https: / / first specified path / 1690958340000.gop". This download link allows the download and playback of the second cloud-stored segment (e.g., 1690958340000.gop). This process is repeated to enable the playback of a complete video of a specified target event on a terminal device.
[0151] In an optional embodiment of the present invention, the method may further include:
[0152] The system queries the event message corresponding to the target event stored in the file server. The event message includes a first field, a second field, and a third field. The first field is used to record the download address of the video index file of the target event. The second field is used to record the start time of the first cloud-stored segment of the target event. The third field is used to record the duration of the target event.
[0153] In this embodiment of the invention, the network camera can construct an event message corresponding to a target event and upload it to a file server so that terminal devices can query which target events have occurred and thus choose to replay them.
[0154] In an optional embodiment of the present invention, downloading the video index file of the specified target event from the cloud server may include:
[0155] Step S31: In response to the selection operation performed on the event message corresponding to the target event stored in the file server, determine the selected target event message;
[0156] Step S32: Obtain the target download address based on the first field of the target event message;
[0157] Step S33: Based on the target download address, download the target video index file of the target event corresponding to the target event message from the cloud server.
[0158] In one example, the event messages stored in the file server are shown in Table 3.
[0159] Table 3
[0160] Event Message 1 (First Field, Second Field, Third Field) Event message 2 (first field, second field, third field) Event message 3 (first field, second field, third field) Event message 4 (first field, second field, third field)
[0161] If the terminal device performs a selection operation on event message 1, then event message 1 is the target event message, and the target event corresponding to event message 1 (let's say event 1) is the specified target event.
[0162] Based on the first field of the target event message, the target download address can be obtained, such as "https: / / first specified path / 1690958337000.index". Based on this target download address, the terminal device can download the target video index file "1690958337000.index" from the cloud server.
[0163] In an optional embodiment of the present invention, the target video index file may be a shared video index file; the step of sequentially constructing download links corresponding to each cloud-stored segment of the specified target event based on the index entries in the video index file may include:
[0164] Step S41: Obtain the target start time based on the second field of the target event message;
[0165] Step S42: Compare the target start time with the start time recorded in each index entry of the shared video index file to determine the matching target index entry;
[0166] Step S43: Based on the target index item, construct the download link for the first cloud storage fragment of the specified target event;
[0167] Step S44: Based on the target index item and the third field of the target event message, construct download links for the second to the last cloud storage fragments of the specified target event in sequence.
[0168] In practice, there may be time overlap events. When a network camera detects a time overlap event, it generates a shared video index file for the event.
[0169] In the example above, if the terminal device selects a target event message (such as event message 1), and the target event (such as event 1) corresponding to the target event message is a time-overlapping event with event 2, then the video index file downloaded by the terminal device based on the first field of event message 1 is a shared video index file for event 1 and event 2.
[0170] The terminal device can obtain the target start time, i.e., the start time of the first cloud-stored segment of event 1, based on the second field in event message 1. Then, it determines the index entry corresponding to the first cloud-stored segment of event 1 in the shared video index file. For example, the obtained target start time (e.g., 1690958337000) is compared with the start times of each cloud-stored segment recorded in each index entry of the video index file "1690958337000.index". The matching index entry is the index entry corresponding to the first cloud-stored segment of event 1, called the target index entry. Thus, a download link for the first cloud-stored segment of the specified target event (e.g., event 1) can be constructed, such as "https: / / first specified path / 1690958337000.gop", allowing the first cloud-stored segment to be downloaded and played.
[0171] Next, based on the target index item and the third field of the target event message, download links for the second to the last cloud storage fragments of the specified target event can be constructed sequentially.
[0172] After finding the index entry corresponding to the first cloud storage segment of Event 1, the next index entry is the index entry corresponding to the second cloud storage segment of Event 1. This process continues until the index entries corresponding to each cloud storage segment of Event 1 are determined. Therefore, the terminal device can sequentially construct download links for each cloud storage segment of Event 1, thereby downloading and playing each cloud storage segment of Event 1.
[0173] Furthermore, since events 1 and 2 are time-overlapping events, the video index file "1690958337000.index" is a shared video index file for events 1 and 2. The terminal device needs to use the target index entry and the third field (duration of event 1) of the target event message (event message 1) to determine the index entry of the last cloud storage segment of event 1. Specifically, after the target index entry (the index entry corresponding to the first cloud storage segment of event 1) is determined, download links for the second to the last cloud storage segments of event 1 can be constructed sequentially based on the target index entry and the duration of event 1, and then the corresponding cloud storage segments can be downloaded and played sequentially.
[0174] It should be noted that the operation of the terminal device has been described in detail in the foregoing embodiments, and will not be repeated here.
[0175] In an optional embodiment of the present invention, the method may further include:
[0176] Step S51: After downloading the video index file of the specified target event from the cloud server, check whether the downloaded video index file includes an end marker;
[0177] Step S52: If there is no end marker, download the updated video index file of the specified target event from the cloud server;
[0178] Step S53: Based on the newly added index entries in the updated video index file, construct download links for the newly added cloud storage segments of the specified target event, and download and play each newly added cloud storage segment in sequence.
[0179] In this embodiment of the invention, the network camera can generate a video index file for the target event and upload it to the cloud server after all cloud-stored segments of the target event have been successfully uploaded; or, it can generate a video index file for the target event and upload it to the cloud server after the first number (e.g., the first) cloud-stored segments of the target event have been successfully uploaded, so as to realize the real-time playback function of the terminal device.
[0180] In real-time playback scenarios, to help terminal devices determine whether there are still cloud-stored segments to be played, the network camera adds an end marker to the video index file after the last cloud-stored segment of the target event is successfully uploaded, indicating that all cloud-stored segments of the target event have been successfully uploaded.
[0181] After the terminal device downloads the video index file (or the updated video index file) for the specified target event (such as event 1), it can check whether there are any remaining cloud-stored segments to be played by checking if there is an end marker in the video index file. If there is no end marker, it means that the network camera is still uploading new cloud-stored segments, that is, there are still cloud-stored segments to be played. The terminal device can download the latest updated video index file from the cloud server, and thus can play the cloud-stored segments corresponding to the newly added index entries in the latest downloaded video index file. Therefore, this embodiment of the invention can realize that the network camera generates cloud-stored segments and uploads them to the cloud server at the same time, while the terminal device downloads cloud-stored segments from the cloud server for playback, realizing real-time playback function and reducing playback latency of the terminal device. If the currently downloaded video index file contains an end marker, it means that all cloud-stored segments of the target event have been successfully uploaded, and the video index file downloaded by the terminal device contains index entries for all cloud-stored segments of the target event. After the cloud-stored segment corresponding to the last index entry in the video index file is played, all cloud-stored segments of the target event have been played.
[0182] For example, after a terminal device downloads the video index file "1690958337000.index" for event 1 from the address "https: / / first specified path / 1690958337000.index", assuming this video index file only contains the first index entry, the terminal device constructs a download link for segment 1 based on the first index entry, thereby downloading and playing segment 1. If the terminal device detects that the video index file lacks an end marker, it re-downloads the video index file from the same address, resulting in an updated video index file "1690958337000.index" with a second index entry, indicating that the network camera has uploaded a new cloud-stored segment to the cloud server. The terminal device then constructs a download link for segment 2 based on the second index entry, thereby downloading and playing segment 2. This process continues in the same manner. It can be understood that the terminal device playing the downloaded cloud-stored segment and determining the existence of an end marker and downloading the updated video index file can be performed in parallel. Therefore, the terminal device can continue playing segment 2 immediately after playing segment 1, resulting in a continuous video playback for the user.
[0183] For the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0184] Reference Figure 5 The diagram illustrates a structural block diagram of an embodiment of a data processing device according to the present invention. The device is applied to a network camera and may include:
[0185] The detection caching module 501 is used to cache video data if a target event is detected.
[0186] The segment generation module 502 is used to add the cloud storage segment to the first queue whenever the cached video data constitutes a cloud storage segment, and record the start time of the cloud storage segment; the cloud storage segment is in units of GOP;
[0187] The fragment upload module 503 is used to upload the cloud storage fragments in the first queue to the cloud server sequentially when the first queue contains at least one cloud storage fragment.
[0188] The index processing module 504 is used to generate a video index file for the target event and upload it to the cloud server; the video index file includes index entries corresponding to each cloud storage segment of the target event, and the index entries record the start time of the corresponding cloud storage segment.
[0189] Optionally, the index processing module is specifically used for:
[0190] If a time overlap event is detected, a shared video index file is generated for the time overlap event; the time overlap event refers to at least two target events having a time intersection; the shared video index file includes an index entry for each cloud storage segment within a duration from the first target event in the time overlap event to the end of the last target event in the time overlap event.
[0191] Optionally, the device further includes:
[0192] The re-upload module is used to add cloud storage segments that failed to upload to the second queue; after the cloud storage segments in the first queue are uploaded, the cloud storage segments in the second queue are re-uploaded.
[0193] Optionally, the index processing module includes:
[0194] The first generation submodule is used to generate a video index file for the target event based on the start time of each cloud storage segment of the target event after all cloud storage segments of the target event have been successfully uploaded.
[0195] Optionally, the index processing module includes:
[0196] The second generation submodule is used to generate a video index file for the target event based on the start time of each of the first number of cloud storage segments after the first number of cloud storage segments for the target event have been successfully uploaded.
[0197] The device further includes:
[0198] The update upload module is used to update the video index file of the target event according to the start time of each of the second number of cloud storage segments after the second number of cloud storage segments of the target event are successfully uploaded; upload the updated video index file to the cloud server; and add an end marker to the video index file after the last cloud storage segment of the target event is successfully uploaded.
[0199] Optionally, the device further includes:
[0200] The message construction module is used to construct an event message corresponding to the target event and upload it to the file server. The event message includes a first field, a second field, and a third field. The first field is used to record the download address of the video index file of the target event. The second field is used to record the start time of the first cloud storage segment of the target event. The third field is used to record the duration of the target event.
[0201] Optionally, the device further includes:
[0202] The state switching module is used to enter a dormant state after the last cloud storage segment of the target event is successfully uploaded, if no other target events are detected.
[0203] Reference Figure 6 The diagram illustrates a structural block diagram of another embodiment of the data processing apparatus of the present invention. The apparatus is applied to a terminal device and may include:
[0204] The index download module 601 is used to download a video index file of a specified target event from a cloud server; the video index file includes index entries corresponding to each cloud storage segment of the specified target event, and the index entries record the start time of the corresponding cloud storage segment; the cloud server stores the video index file of the specified target event and each cloud storage segment of the specified target event; the cloud storage segments are in units of GOP;
[0205] The link building module 602 is used to sequentially build download links corresponding to each cloud storage segment of the specified target event based on the index entries in the video index file.
[0206] The download and playback module 603 is used to download and play each cloud storage segment of the specified target event sequentially according to the download link corresponding to each cloud storage segment of the specified target event.
[0207] Optionally, the device further includes:
[0208] The message query module is used to query the event message corresponding to the target event stored in the file server; the event message includes a first field, a second field, and a third field; the first field is used to record the download address of the video index file of the target event; the second field is used to record the start time of the first cloud-stored segment of the target event; and the third field is used to record the duration of the target event.
[0209] The index download module includes:
[0210] The target determination submodule is used to determine the selected target event message in response to a selection operation performed on the event message corresponding to the target event stored in the file server.
[0211] The address acquisition submodule is used to obtain the target download address based on the first field of the target event message;
[0212] The index download submodule is used to download the target video index file of the target event corresponding to the target event message from the cloud server based on the target download address.
[0213] Optionally, the target video index file is a shared video index file; the link building module includes:
[0214] The time determination submodule is used to obtain the target start time based on the second field of the target event message;
[0215] The time matching submodule is used to compare the target start time with the start time recorded in each index entry of the shared video index file to determine the matching target index entry;
[0216] The link building submodule is used to construct the download link of the first cloud storage segment of the specified target event based on the target index item; and to construct the download links of the second to the last cloud storage segments of the specified target event in sequence based on the target index item and the third field of the target event message.
[0217] Optionally, the device further includes:
[0218] The flag checking module is used to check whether the downloaded video index file of the specified target event contains an end flag after downloading it from the cloud server.
[0219] The new index download module is used to download the updated video index file of the specified target event from the cloud server if it does not contain an end marker;
[0220] The new segment download module is used to construct download links for newly added cloud-stored segments of the specified target event based on the newly added index entries in the updated video index file, and to download and play each newly added cloud-stored segment in sequence.
[0221] Reference Figure 7 The diagram shows a structural block diagram of an embodiment of a data processing system according to the present invention. The system may include a network camera 701, a cloud server 702, and a terminal device 703.
[0222] The network camera 701 is configured to cache video data if a target event is detected; whenever the cached video data constitutes a cloud storage segment, the cloud storage segment is added to a first queue, and the start time of the cloud storage segment is recorded; the cloud storage segments are in units of GOPs; when the first queue contains at least one cloud storage segment, the cloud storage segments in the first queue are uploaded to the cloud server in sequence; a video index file for the target event is generated and uploaded to the cloud server; the video index file includes index entries corresponding to each cloud storage segment of the target event, and the index entries record the start time of the corresponding cloud storage segment;
[0223] The cloud server 702 is used to receive and store the video index file of the target event uploaded by the network camera, as well as the cloud storage segments of the target event;
[0224] The terminal device 703 is used to download a video index file of a specified target event from a cloud server; the video index file includes index entries corresponding to each cloud-stored segment of the specified target event, and the index entries record the start time of the corresponding cloud-stored segment; the cloud server stores the video index file of the specified target event and each cloud-stored segment of the specified target event; based on the index entries in the video index file, download links corresponding to each cloud-stored segment of the specified target event are constructed sequentially; based on the download links corresponding to each cloud-stored segment of the specified target event, each cloud-stored segment of the specified target event is downloaded sequentially and played.
[0225] In summary, in this embodiment of the invention, when the network camera detects a target event, it caches video data and uploads the video data to the cloud server in units of cloud storage segments. The network camera enters the upload phase as soon as it generates a cloud storage segment, with segment generation and uploading occurring in parallel. The network camera generates and uploads already generated cloud storage segments simultaneously, with the idle waiting time being only the upload duration of the last cloud storage segment, significantly reducing idle waiting time and power consumption. Furthermore, the cloud storage segments are in units of Group of Pictures (GOPs). Therefore, the starting frame of each cloud storage segment is an I-frame, and subsequent P-frames can use this I-frame as a reference frame for correct decoding, preventing situations where P-frames lack a reference frame. That is, each cloud storage segment is valid video data and can be decoded and played independently. The loss of individual cloud storage segments does not affect the normal playback of other segments. During playback on the terminal device, only frame skipping due to the loss of individual frames occurs; the entire video remains unplayable.
[0226] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0227] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0228] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0229] Reference Figure 8 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Figure 8 As shown, the electronic device includes: a processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface communicate with each other through the communication bus. The memory is used to store at least one executable instruction, which causes the processor to perform the steps of the data processing method of the aforementioned embodiment.
[0230] This invention provides a non-transitory computer-readable storage medium that, when the instructions in the storage medium are executed by a program or processor of a terminal, enables the terminal to perform the steps of the data processing method described in the foregoing embodiments.
[0231] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0232] Furthermore, the beneficial effects of using the same method will not be repeated here. For technical details not disclosed in the computer program products or computer program embodiments involved in this application, please refer to the description of the method embodiments of this application.
[0233] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.
[0234] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
[0235] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
[0236] The above provides a detailed description of the data processing method, apparatus, and electronic device provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A data processing method, characterized in that, Applied to network cameras, the method includes: If a target event is detected, cache the video data; Whenever cached video data constitutes a cloud storage segment, the cloud storage segment is added to the first queue, and the start time of the cloud storage segment is recorded; the cloud storage segment is in units of GOP; When the first queue contains at least one cloud storage fragment, the cloud storage fragments in the first queue are uploaded to the cloud server sequentially. A video index file for the target event is generated and uploaded to the cloud server. The video index file includes index entries corresponding to each cloud storage segment of the target event, and the index entries record the start time of the corresponding cloud storage segment.
2. The method according to claim 1, characterized in that, The video index file for generating the target event includes: If a time overlap event is detected, a shared video index file is generated for the time overlap event; the time overlap event refers to at least two target events having a time intersection; the shared video index file includes an index entry for each cloud storage segment within a duration from the first target event in the time overlap event to the end of the last target event in the time overlap event.
3. The method according to claim 1, characterized in that, The method further includes: Add the failed cloud storage segments to the second queue; After the cloud storage fragments in the first queue are uploaded, the cloud storage fragments in the second queue are re-uploaded.
4. The method according to claim 1, characterized in that, The video index file for generating the target event includes: After all cloud storage segments of the target event are successfully uploaded, a video index file for the target event is generated based on the start time of each cloud storage segment.
5. The method according to claim 1, characterized in that, The video index file for generating the target event includes: After the first number of cloud storage segments of the target event are successfully uploaded, a video index file of the target event is generated based on the start time of each of the first number of cloud storage segments. The method further includes: Whenever the second number of cloud storage segments of the target event are successfully uploaded, the video index file of the target event is updated according to the start time of each of the second number of cloud storage segments; The updated video index file is uploaded to the cloud server, and an end marker is added to the video index file after the last cloud storage segment of the target event is successfully uploaded.
6. The method according to claim 1, characterized in that, The method further includes: An event message corresponding to the target event is constructed and uploaded to a file server; the event message includes a first field, a second field, and a third field; the first field is used to record the download address of the video index file of the target event; the second field is used to record the start time of the first cloud-stored segment of the target event; and the third field is used to record the duration of the target event.
7. The method according to claim 1, characterized in that, The method further includes: After the last cloud storage segment of the target event is successfully uploaded, if no other target events are detected, it enters a dormant state.
8. A data processing method, characterized in that, Applied to a terminal device, the method includes: Download a video index file of a specified target event from a cloud server; the video index file includes index entries corresponding to each cloud storage segment of the specified target event, and the index entries record the start time of the corresponding cloud storage segment; the cloud server stores the video index file of the specified target event and each cloud storage segment of the specified target event; the cloud storage segments are in units of GOP; Based on the index entries in the video index file, download links corresponding to each cloud-stored segment of the specified target event are constructed sequentially. Download and play each cloud storage segment of the specified target event sequentially according to the download link corresponding to each cloud storage segment of the specified target event.
9. The method according to claim 8, characterized in that, The method further includes: The system queries the event message corresponding to the target event stored in the file server. The event message includes a first field, a second field, and a third field. The first field records the download address of the video index file of the target event. The second field records the start time of the first cloud-stored segment of the target event. The third field records the duration of the target event. The step of downloading the video index file of the specified target event from the cloud server includes: In response to a selection operation performed on an event message corresponding to a target event stored in the file server, the selected target event message is determined; Based on the first field of the target event message, obtain the target download address; Based on the target download address, download the target video index file of the target event corresponding to the target event message from the cloud server.
10. The method according to claim 9, characterized in that, The target video index file is a shared video index file; the step of constructing download links corresponding to each cloud-stored segment of the specified target event sequentially based on the index entries in the video index file includes: Based on the second field of the target event message, obtain the target start time; The target start time is compared with the start time recorded in each index entry of the shared video index file to determine the matching target index entry; Based on the target index entry, construct the download link for the first cloud-stored fragment of the specified target event; Based on the target index item and the third field of the target event message, download links for the second to the last cloud storage fragments of the specified target event are constructed sequentially.
11. The method according to claim 8, characterized in that, The method further includes: After downloading the video index file of the specified target event from the cloud server, check whether the downloaded video index file includes an end marker; If no end marker is included, the updated video index file for the specified target event is downloaded from the cloud server; Based on the newly added index entries in the updated video index file, a download link for the newly added cloud storage segment of the specified target event is constructed, and each newly added cloud storage segment is downloaded and played in sequence.
12. A data processing apparatus, characterized in that, The device, applied to network cameras, includes: The detection caching module is used to cache video data if a target event is detected. The segment generation module is used to add the cloud storage segment to the first queue whenever the cached video data constitutes a cloud storage segment, and to record the start time of the cloud storage segment; the cloud storage segments are in units of GOP; The fragment upload module is used to sequentially upload cloud storage fragments in the first queue to the cloud server when the first queue contains at least one cloud storage fragment. An index processing module is used to generate a video index file for the target event and upload it to the cloud server. The video index file includes index entries corresponding to each cloud storage segment of the target event, and the index entries record the start time of the corresponding cloud storage segment.
13. A data processing apparatus, characterized in that, Applied to a terminal device, the device includes: The index download module is used to download a video index file of a specified target event from a cloud server. The video index file includes index entries corresponding to each cloud storage segment of the specified target event, and the index entries record the start time of the corresponding cloud storage segment. The cloud server stores the video index file of the specified target event and each cloud storage segment of the specified target event. The cloud storage segments are in units of GOP. The link building module is used to sequentially build download links corresponding to each cloud-stored segment of the specified target event based on the index entries in the video index file. The download and playback module is used to download and play each cloud storage segment of the specified target event sequentially according to the download links corresponding to each cloud storage segment of the specified target event.
14. An electronic device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform the steps of the data processing method as described in any one of claims 1 to 7 or 8 to 11.