Video splicing storage method, device and storage medium
Through the video splicing storage method, multiple source videos are spliced and re-encoded in the device cluster, which solves the high cost and security challenges of high-resolution video data storage, and achieves efficient management and data integrity guarantee.
Patent Information
- Application Number
- CN202410997998.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-24
AI Technical Summary
The explosive growth of video data has led to high storage costs and difficult management, and the security and integrity of data storage have been challenged. Especially in high-resolution and high-frame-rate video scenarios, it is difficult for existing technologies to effectively reduce storage pressure and protect data. availability and consistency.
The video splicing storage method is used to splice and re-encode multiple source videos through device cluster management. The clustered storage method is used to reduce storage costs and enhance data security and integrity. The first device determines the splicing storage device and obtains And store the video splicing information to extract the source video.
It improves the management efficiency of video data, reduces storage costs, enhances data security and integrity, and solves the pressure of data redundant backup and data loss problems through decentralized storage.
Smart Images

Figure CN118555357B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a video splicing storage method, device and storage medium. Background Art
[0002] With the rapid development of Internet technology, various complex application scenarios have higher requirements for video resolution and frame rate, which makes the bit rate and resolution of captured videos larger and larger, further causing a sharp increase in the amount of video data.
[0003] However, the explosive growth of video data has led to an increasing demand for data storage, especially for large-scale video data such as high-definition and ultra-high-definition videos, and the storage cost is also increasing. Although current video encoding technology or the use of external storage media can help reduce file size, with the widespread popularity of application scenarios such as video surveillance, live broadcasting, social media, and online education, the overall storage demand continues to rise.
[0004] For storage devices, these high-resolution, high-frame-rate video contents undoubtedly increase the pressure on device storage and data redundancy backup. When storing videos, storage devices under high-pressure deployment may lose data due to problems such as device performance and network environment, resulting in incomplete data. At the same time, with the increase in network security vulnerabilities, the privacy and security issues of data storage are becoming increasingly prominent.
[0005] Furthermore, while storing large-scale video data, the management of video data also faces many challenges, such as metadata management, data lifecycle management, backup and recovery, etc. How to efficiently index and retrieve massive video content and ensure the availability and consistency of data has become a problem that needs to be solved urgently. Summary of the invention
[0006] In order to solve the above technical problems, the present application provides a video splicing storage method, device and storage medium to solve the problems in the prior art such as high data storage cost, difficulty in managing stored data, and challenges to the security and integrity of data storage caused by the increase in the amount of video data.
[0007] In order to solve the above technical problems, the present application provides a video splicing storage method, which is applied to a device cluster, the device cluster includes multiple devices, one of the multiple devices is set as a first device, and the video splicing storage method is a method for splicing and storing multiple source videos of at least one device in the device cluster, and the method includes:
[0008] A first device in the device cluster uses at least one of the devices in the device cluster as a spliced storage device;
[0009] Allow each splicing storage device to splice and re-encode at least two of the source videos to obtain spliced video data, and store the spliced video data in at least one device in the device cluster;
[0010] The video stitching information of each stitched video data is acquired and stored, so that the first device can acquire each stitched video data based on the video stitching information of each stitched video data and extract the source video therefrom.
[0011] In order to solve the above technical problems, the present application provides a video splicing storage method, which is applied to a device cluster, the device cluster includes multiple devices, one of the multiple devices is set as a first device, and the method includes:
[0012] In response to obtaining a video stitching instruction issued by the first device, the video stitching device in the device cluster stitches and re-encodes at least two source videos to be stitched indicated by the video stitching instruction to obtain video stitching data, and stores the video stitching data in at least one device in the device cluster;
[0013] The video splicing information of the video splicing data is stored in the first device, so that the first device can obtain each spliced video data based on the video splicing information of each spliced video data and extract the source video therefrom.
[0014] To solve the above technical problems, the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the video splicing storage method in the above technical solution.
[0015] In order to solve the above technical problems, the present application provides a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, it is used to implement the video splicing storage method in the above technical solution.
[0016] Through the above scheme, the beneficial effects of the present application are: the video splicing storage method provided by the present application performs splicing storage management on multiple source video data in at least one device through cluster management of the device, determines the splicing storage device in the device cluster based on the first device set in the device cluster, and the splicing storage device responds to the video splicing instruction issued by the first device, splices and re-encodes at least two source videos indicated by the video splicing instruction, and obtains and stores the video splicing data; the first device obtains and stores the video splicing information of each spliced video data, so that the first device can obtain each video splicing data based on the video splicing information of each video splicing data and extract the source video therefrom; in this way, the management efficiency of the video data is further improved through clustered management, and at the same time, the video splicing storage method can effectively reduce the storage cost of the video data, and the cluster management and distributed storage method can also enhance the security and integrity of data storage. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0018] Figure 1 It is a flowchart of an embodiment of a video splicing storage method provided by the present application;
[0019] Figure 2 It is a flowchart of another embodiment of the video splicing storage method provided by the present application;
[0020] Figure 3 A schematic diagram of pre-allocating memory blocks for a video splicing scaling strategy provided by this application;
[0021] Figure 4 It is a flowchart of a specific embodiment of the video splicing storage method provided by the present application;
[0022] Figure 5 It is a flowchart of the unified scheduling strategy for managing hosts provided by this application;
[0023] Figure 6 This is a flowchart of multi-channel source video decoding, splicing, and re-encoding provided by the present application;
[0024] Figure 7 It is a schematic diagram of a device cluster management process provided by this application;
[0025] Figure 8 It is a structural schematic diagram of an embodiment of an electronic device provided by the present application;
[0026] Fig. 9 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION
[0027] The present application is further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present application, but are not intended to limit the scope of the present application. Similarly, the following examples are only some embodiments of the present application rather than all embodiments, and all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0028] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0029] It should be noted that the terms "first", "second", etc. in this application are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second", etc. can explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0030] At present, the main way to store or back up data is to achieve data redundancy by using multi-disk RAID (Redundant Array of Independent Disks), cluster load balancing, and simultaneous storage of videos on multiple devices. However, the above methods require a large amount of data storage and the number of external storage media, and are costly. At the same time, the storage environment of multiple devices and multiple nodes requires more sophisticated monitoring, configuration, and troubleshooting, which increases the difficulty of operation and maintenance.
[0031] In response to the above problems, the common methods in the prior art to reduce the pressure of device storage and data redundancy backup are: ① Implement dynamic bit rate management for connected cameras and add intelligent H.265 encoding methods to reduce the frequency of key frame sending of big data, thereby reducing the amount of data to reduce video freeze rate or storage and backup pressure; ② Perform intelligent analysis on the original data and dynamically eliminate non-critical or low-value data to reduce the amount of data compression; ③ Distributed forwarding and storage of data, that is, dispersing the data source among different devices for storage and transmission, to solve the problem of insufficient performance of a single device.
[0032] However, for method ①, the method of increasing the interval of video key frames by using dynamic bit rate and intelligent H.265 encoding has limited effect on network transmission and codec acceleration for large video frame bit streams. At the same time, if a video key frame is too long, a large section of video cannot be parsed and played once a frame is lost. For method ②, the source video is intelligently analyzed by using the analysis capability of the device to remove the data of non-critical data frames to highlight the video frames of key value. The constraints of the analysis algorithm or other anomalies may cause the loss of video data, and the integrity of the data is difficult to guarantee. At the same time, for high-resolution video streams, such as 4K and 8K, the video analysis itself consumes a lot of device performance, so it cannot solve the various defects of video data storage and backup in high-resolution scenarios, such as large data volume and large amount of redundant backup data. If the data storage device is abnormal, there is also the possibility of data loss. For method ③, the distributed forwarding and storage of data requires scheduling and processing by multiple servers, which has a high configuration cost. Even for distributed storage, data needs to be stored repeatedly when data is redundantly backed up. In essence, it does not reduce the total amount of data backup, and thus cannot reduce the pressure of data storage.
[0033] Therefore, the present application provides a video splicing and storage method, which performs splicing and storage management on multiple source video data in at least one device through cluster management of devices, determines a splicing storage device in a device cluster based on a first device set in the device cluster, and the splicing storage device responds to a video splicing instruction issued by the first device, splices and re-encodes at least two source videos indicated by the video splicing instruction, and obtains and stores video splicing data; the first device obtains and stores video splicing information of each spliced video data, so that the first device can obtain each video splicing data based on the video splicing information of each video splicing data and extract the source video therefrom; in this way, the management efficiency of video data is further improved through clustered management, and at the same time, the video splicing storage method can effectively reduce the storage cost of video data, and the cluster management and distributed storage method can also enhance the security and integrity of data storage.
[0034] Device clustering refers to combining multiple devices (such as computers, servers, storage devices, etc.) to form a single, collaborative system, thereby improving overall performance, reliability, scalability, and fault tolerance. Each device in a device cluster is connected through a network and can operate independently or share tasks. It communicates and collaborates through a high-speed network, such as exchanging data, transferring tasks, synchronizing status, etc., to achieve resource sharing and load balancing.
[0035] The present application can apply the video splicing storage method in the scenario of device cluster management, wherein the device cluster includes multiple devices, identifies and manages the multiple devices, and clarifies the identity, location, function, and other information of each device. One of the multiple devices is set as the first device, which is responsible for the coordination, task allocation, and result aggregation of the entire video splicing process.
[0036] The video splicing storage method provided in this application is a method for splicing and storing multiple source videos of at least one device in a device cluster. Figure 1 , Figure 1 1 is a flow chart of an embodiment of the video splicing storage method provided by the present application. It should be noted that if there are substantially the same results, this embodiment does not use Figure 1 The process sequence shown is limited. Figure 1 As shown, this embodiment includes:
[0037] S110: A first device in a device cluster uses at least one device in the device cluster as a splicing storage device.
[0038] Usually, multiple devices are configured in a LAN environment for video storage, and multiple devices in the LAN environment are managed in a cluster. A management host is selected as the first device in the device cluster to manage other devices in the device cluster. The management host can be randomly selected in the device cluster, or a device with moderate performance, sufficient network interface and storage capacity can be selected in the device cluster.
[0039] Configure the first device in the environment, such as configuring the correct IP address, subnet mask, default gateway and other network parameters, to ensure that the connection with the LAN is normal and that it can communicate with other devices in the device cluster in the LAN. After the configuration is completed, the first device starts the device discovery process and searches for other devices in the device cluster in the current LAN by sending broadcast or multicast messages. After the management host collects the response information of other devices, it adds other devices to the management queue.
[0040] In other embodiments, in order to ensure the high availability and fault tolerance of the video splicing storage system, a backup device can also be set as a functional standby device for the first device. After the first device obtains the management queue information, the backup device is determined based on the device information in the management queue. When the first device fails or fails to work properly, the backup device can quickly take over its responsibilities, that is, the backup device automatically becomes the first device.
[0041] In one example, a backup device is determined based on the network throughput of all devices in the device cluster except the first device. In a specific example, the network throughput data of all devices in the device cluster except the first device can be collected, and optionally, a device with the lowest network throughput is selected as a backup device. Among them, network throughput refers to the total amount of data successfully transmitted by a network system or device within a certain period of time, reflecting the ability to transmit data between devices. The selection of devices with lower network throughput as backup devices is mainly based on resource utilization efficiency, meeting basic redundancy requirements, avoiding failover bottlenecks, simplifying troubleshooting, and improving energy efficiency. It can be selected that in addition to network throughput, factors such as the computing power, storage space, and stability of the device can also be considered to ensure that the backup device has the ability to fully take over the functions of the first device. Therefore, in the optional scheme, if the network throughput of all candidate devices is similar, they can also be scored according to the policies required by the business, and the device whose comprehensive score meets the policy requirements can be selected as a backup device.
[0042] In case of setting a backup device, the first device and the backup device may establish a keep-alive connection, so that when the first device is offline, the backup device automatically becomes the first device.
[0043] The first device establishes a keep-alive connection with the backup device. For example, a two-way heartbeat mechanism can be established between the first device and the backup device. The online status of the other party is detected by periodically sending heartbeat packets. Once a heartbeat response is not received within a set time, both parties should be able to quickly identify possible faults in the other party. If the first device is offline or cannot respond to the heartbeat, the backup device automatically upgrades to become the first device and begins to perform related duties, and re-executes the steps of determining the backup device based on the network throughput of all devices in the device cluster except the first device, and determines a new backup device; if the backup device is offline or cannot respond to the heartbeat, the first device confirms that the backup device is offline, and re-executes the steps of determining the backup device based on the network throughput of all devices in the device cluster except the first device, and determines a new backup device.
[0044] Optionally, the first device periodically synchronizes the video stitching information to the backup device. Furthermore, the first device periodically synchronizes the information of the current stitched video data (such as the status of ongoing tasks, metadata of completed tasks, a list of pending tasks, device resource status, etc.) to the backup device; in other examples, in order to reduce the amount of data transmission and improve synchronization efficiency, only the data that has changed since the last synchronization can be synchronized, that is, an incremental synchronization method can be used, while ensuring the consistency and integrity of the data during the synchronization process. When the backup device receives the synchronized data, it feeds back a confirmation message to the first device to ensure that the data has been correctly received and stored. If the first device does not receive the confirmation message, it can retry to synchronize the data or trigger an alarm.
[0045] The first device in the device cluster uses at least one device in the device cluster as a splicing storage device to splice and re-encode at least two source videos to obtain spliced video data. In one embodiment, the encoding format of each source video and / or the redundant encoding and decoding resources of at least some devices are determined; wherein the redundant encoding and decoding resources refer to the computing, storage or hardware resources used for data encoding and decoding in the system or device that exceed the current actual demand, that is, there are underutilized or idle encoding and decoding capabilities. Based on the encoding formats of multiple source videos and / or the redundant encoding and decoding resources of at least some devices, at least one of the splicing storage devices is determined.
[0046] In one embodiment, the first device sends a request to other devices in the management queue through an established communication mechanism to collect the video channel information accessed by the first device and the codec resource information of at least some devices. The video channel information mainly includes: source video ID, video encoding format (such as H.264, H.265, MJPEG, etc.), video parameters such as resolution, frame rate, bit rate, data transmission path or streaming media address, etc.; the codec resource information of at least some devices includes: device ID (used to identify the source device of the source video), currently used codec resources (such as the number of video channels being decoded), redundant codec resources (such as the remaining available decoding channels, the maximum concurrent decoding capacity, etc.) and codec capabilities such as supported encoding formats, maximum resolution, etc.
[0047] Based on the collected source video encoding format and the encoding and decoding resource information of the device, the first device determines at least one video splicing storage device according to the following principles:
[0048] (1) Compatibility of encoding formats: Give priority to selecting devices that support all source video encoding formats as splicing storage devices to reduce unnecessary transcoding operations;
[0049] (2) Resource adequacy: Evaluate whether the device's excess encoding and decoding resources are sufficient to handle splicing and re-encoding tasks. Factors to consider include: the number of required decoding paths (number of source videos), the number of encoding paths (number of output spliced videos), the expected encoding parameters (set according to the application scenario and storage requirements), and the actual processing capacity of the device.
[0050] (3) Load balancing: When multiple devices can meet the task requirements, devices with lower current loads are given priority to maintain the overall performance and stability of the device cluster.
[0051] The first device sends a video splicing instruction to the selected splicing storage device so that the splicing storage device executes the video splicing instruction, wherein the video splicing instruction includes source video information, target encoding format, output parameters, etc.
[0052] In one embodiment, the first device groups source videos of the same encoding format into the same group based on the collected video channel information to obtain at least one group of source videos. A video splicing instruction is sent to the source devices of at least two source videos of the same source in each group of source videos, so that the source devices act as video splicing devices to splice and re-encode all source videos of the source devices in each group of source videos to obtain spliced video data. It can be understood that "grouping source videos of the same encoding format into the same group" does not mean that the source videos must be located in the first device, that is, the logical grouping of source videos (according to the encoding format) and their physical location (storage device) are two independent concepts. Even if the source videos logically belong to the same group, they may be physically dispersed and stored in multiple devices, server clusters or cloud storage services.
[0053] Exemplarily, based on the collected video channel information, a data structure such as a dictionary (the key is the encoding format, and the value is the source video channel list corresponding to the encoding format) can be used to divide all source video channels of the same video encoding format into one group, that is, all source videos of the same video encoding format are grouped into the same group. For each group divided based on the video encoding format, sorting is performed according to preset rules. In one example, the source videos from the same device are sorted internally, such as in ascending order according to the source video channel ID; then, external sorting is performed according to the device ID, and the source video channels from the same device are preferentially merged and arranged. For example, a priority queue (heap) or other stable sorting algorithm can be used to achieve this.
[0054] The video channel information corresponding to the grouped and sorted source videos is applied to the scheduling of the source video splicing and re-encoding tasks. In one example, in the sent video splicing instruction, source videos from the same device in the same encoding format group are preferentially selected for splicing to reduce the data receiving and forwarding overhead in the source video splicing process and improve system efficiency.
[0055] In one embodiment, after the source videos of the same coding format are spliced and re-encoded to obtain spliced video data in all the splicing storage devices, there are remaining unspliced source videos. The first device determines the video splicing device of the remaining source videos based on the redundant coding and decoding resources of the source devices of the remaining source videos in each group of source videos, so that the video splicing device splices and re-encodes at least part of the remaining source videos.
[0056] In a specific example, since some devices have completed the splicing task, their codec resource status may have changed. Therefore, the first device can collect and update the video channel information and redundant codec resource information of all devices in the device cluster again, including the codec resources released after the task has been completed and the current load status. Optionally, the video splicing device for the remaining source videos can be determined by considering factors such as the compatibility of the encoding format, the redundant codec resources of the device, and load balancing. Preferably, the device with the strongest redundant codec resources among the source devices of the remaining source videos is used as the video splicing device for the remaining source videos.
[0057] S120: Let each splicing storage device splice and re-encode at least two source videos to obtain spliced video data, and store the spliced video data in at least one device in the device cluster.
[0058] After the first device confirms at least one splicing storage device through S110, it sends a video splicing instruction to the at least one splicing storage device, instructing each splicing storage device to splice and re-encode at least two source videos to obtain spliced video data, and store the spliced video data in at least one device in the device cluster.
[0059] In one embodiment, the first device generates a video splicing instruction based on the relevant information of the source video to be spliced and the determined splicing storage device. The video splicing instruction includes: ① target device ID, which is used to indicate the splicing storage device receiving the instruction; ② source video list, which lists the source video IDs and their encoding formats to be spliced; ③ splicing parameters, such as splicing order, spatiotemporal alignment, resolution, bit rate, etc.; ④ target encoding format, which indicates the encoding format of the spliced video, which is usually the same as the source video encoding format. In other optional schemes, the spliced encoding format can also be set to be different from the encoding format of the source video; ⑤ storage location indication, which is used to indicate at least one device in the device cluster where the spliced video data should be stored. The spliced video data is usually stored in the current splicing storage device. In other optional schemes, the spliced video data in the current splicing storage device can also be stored in at least one device of other devices in the device cluster.
[0060] In one example, a stitching storage device obtains corresponding source video data from a device cluster or an external source based on a source video list in a video stitching instruction, decodes each source video, stitches the decoded source video data according to the stitching parameters of the video stitching instruction, generates a temporary stitched video frame sequence, encodes the stitched video frame sequence according to the target encoding format and parameters in the video stitching instruction, and generates final stitched video data.
[0061] In a specific embodiment, after the spliced video data is generated, the spliced video data can be stored in at least one device in the device cluster except the splicing storage device. In this embodiment, the splicing storage device transmits the generated spliced video data to the storage location specified by the video splicing instruction through the network. After receiving the spliced video data, the target storage device (or service) returns a confirmation message to the splicing storage device, indicating that the data has been successfully stored.
[0062] The splicing storage device feeds back the storage confirmation message to the first device, and sends the video splicing information (video channel information, recording time, corresponding device IP / MAC, redundant data storage device IP / MAC, etc.) of the spliced video data to the first device, completing the closed loop of the entire splicing task.
[0063] In a specific embodiment, in order to reduce network consumption for re-streaming, the splicing storage device decodes, splices and re-encodes at least two source videos stored in the splicing storage device itself based on a video splicing instruction to obtain spliced video data, and stores the spliced video data in the splicing storage device. After successful storage, the video splicing information of the successfully stored spliced video data is sent to the first device.
[0064] In one embodiment, if there are still remaining unspliced source videos after the source videos of the same encoding format are spliced and re-encoded to obtain spliced video data in all splicing storage devices, the first device selects at least one device with strong redundant encoding and decoding resources based on the source devices of the remaining source videos in each group of source videos, and determines it as the video splicing device for the remaining source videos. The first device re-streams the remaining source videos to be spliced in the group corresponding to the source videos to be spliced in the video splicing device, and forwards them to the video splicing device of the remaining source videos currently determined, so that the video splicing device performs the steps of decoding, splicing and re-encoding at least two source videos to obtain spliced video data, and stores the obtained spliced video data in the video splicing device. After successful storage, the video splicing information of the successfully stored spliced video data is sent to the first device. Among them, the obtained spliced video data can be stored in the video splicing device that currently performs splicing and re-encoding, or it can be forwarded and stored in at least one device in other device clusters.
[0065] S130: Acquire and store video stitching information of each stitched video data, so that the first device can acquire each stitched video data based on the video stitching information of each stitched video data and extract the source video therefrom.
[0066] After the storage of the video stitching data is completed, the first device obtains and stores the video stitching information of each stitching video data, so that the first device can obtain each stitching video data based on the video stitching information of each stitching video data and extract the source video therefrom.
[0067] In one example, the video splicing information of each spliced video data is recorded in the video file header and the database. The video splicing information includes: channel number (used to record the unique identifier of each source video involved in the splicing, such as the source video ID or channel number, etc.), bitstream type (used to record the video encoding format used by each channel and possible additional information, etc.), resolution (used to record the resolution of the original video of each channel, including width, height and possible pixel formats such as RGB, YUV, etc.) and area information (used to record the position and size of each channel in the spliced picture).
[0068] The first device obtains and stores the video stitching information of each stitched video data, obtains each stitched video data based on the video stitching information of each stitched video data, and extracts the source video therefrom. Exemplarily, the video stitching information of the source video to be extracted is determined, and the video stitching data of the source video to be extracted is obtained, and the video stitching data is decoded to obtain the decoded stitching data. The decoded stitching data is data segmented according to the stitching display coordinate information of the source video to be extracted in the video stitching information to obtain the source video to be extracted. Preferably, the video stitching information of the video stitching data includes at least the encoding format of the video stitching data, the channel number, and the address of the storage device.
[0069] In one embodiment, when it is necessary to view video data, the channel information of the required spliced video is first retrieved through the database query function of the first device according to the conditions such as the video file name, time period, channel number, etc. According to the storage location of the source video provided in the query result, a request is made to the corresponding splicing storage device, the source video file is opened and the splicing data channel information embedded in its header is parsed, and the splicing data channel information is mutually verified with the database query result to ensure the consistency of the information. Based on the acquired video channel information, the video file is decoded and reorganized using appropriate video processing tools to restore the original channel videos, and the splicing layout is displayed or exported as an independent source video file.
[0070] Exemplarily, through a query interface, file parsing or other means, complete splicing information including the video splicing data of the source video to be extracted is obtained, ensuring that the information contains the encoding format, channel number, storage device address, and coordinate information of the source video in the splicing display, etc. According to the storage device address provided in the splicing information, the actual storage location where the video splicing data is stored is found, and the first device requests the video data from the splicing storage device storing the video splicing data generated by the source video to be extracted. The device corresponding to the actual storage location storing the video splicing data returns the video splicing data to be extracted based on the request of the first device, and can also load it into memory or a temporary file for subsequent processing.
[0071] According to the encoding format (such as H.264, HEVC, AV1, etc.) provided in the splicing information, select a suitable video decoder library or software tool (such as FFmpeg, libavcodec, GStreamer plug-in, etc.). Call the decoder interface, take the video splicing data as input, perform full frame decoding or only decode the time period corresponding to the source video to be extracted, and ensure that the decoding parameters (such as resolution, frame rate, color space, etc.) match the splicing information to obtain high-quality decoded splicing data.
[0072] The coordinate information of the source video to be extracted in the spliced display is extracted from the video splicing information, which may include descriptions such as pixel coordinates, relative position, and screen area. For simple overlay or linear splicing, the portion of the source video to be extracted is directly cropped from each decoded frame image according to the coordinate information, such as rectangular cutting using image processing libraries such as OpenCV and PIL. For more complex splicing structures (such as picture-in-picture, multi-layer overlay, irregular shapes, etc.), it may be necessary to combine image mixing information (such as alpha channel) and / or depth information for precise separation, and custom algorithms or the use of advanced graphics processing tools (such as OpenGL, DirectX, GPU programming) may be required to perform such separation.
[0073] Repackage the segmented source video frames into a standard video file format (such as MP4, MKV, TS, etc.), and select appropriate encoding parameters (such as compression rate, encoding format, etc.) for encoding according to requirements to generate the final source video file to be extracted. Optionally, retain or update the metadata of the source video (such as resolution, frame rate, encoding parameters, copyright information, etc.) to ensure that the extracted source video has complete metadata information.
[0074] See also Figure 2 , Figure 2 FIG. 1 is a flow chart of another embodiment of the video splicing storage method provided by the present application. It should be noted that if there are substantially the same results, this embodiment is not used. Figure 2 The process sequence shown is limited. Figure 2As shown, this embodiment includes:
[0075] S210: In response to obtaining a video stitching instruction issued by the first device, the video stitching device in the device cluster stitches and re-encodes at least two source videos to be stitched indicated by the video stitching instruction to obtain video stitching data, and stores the video stitching data in at least one device in the device cluster.
[0076] The video stitching device in the device cluster receives the video stitching instruction sent by the first device, and according to the instruction information, pulls the real-time video stream or reads the pre-stored video file from the specified source. The video stitching instruction should include detailed information of at least two source videos to be stitched, such as source video address, channel identifier, encoding format and resolution, etc.
[0077] According to the splicing layout parameters that may be contained in the video splicing instruction, such as the position, size, and superposition order of each source video, the source videos are spatially laid out, and the video splicing operation is performed to generate a single composite video stream. The encoding format of the output spliced video is determined to ensure that it is compatible with the first device or other downstream systems. Preferably, the encoding format of the output spliced video is consistent with the encoding format of the source video that forms the spliced video. The spliced video stream is re-encoded in real time or batches to generate video splicing data that conforms to the specified format and parameters, and the video splicing data is stored in at least one device in the device cluster.
[0078] In one embodiment, the video splicing device performs background decoding on the code streams of at least two source videos to be spliced to obtain at least two decoded videos. Exemplarily, the video splicing device simultaneously performs background decoding on the code streams of at least two source videos to be spliced, and during the decoding process, ensures the synchronization of each source video frame. For real-time streams, this can be achieved through timestamp calibration; for recorded videos, ensure that the decoder reads in the correct frame order to ensure the temporal and spatial consistency of each video segment during splicing. In other examples, if the video splicing device can directly obtain the decoded source video frame, it can also skip the decoding step and directly perform the following steps.
[0079] According to the number of splicing paths of the video splicing device and the source video resolution, at least two decoded source videos are scaled to obtain at least two scaled videos. Based on the source video resolution, a memory block is applied for, and images in the at least two scaled videos are sequentially filled into the memory block to obtain a spliced image sequence, and then the spliced image sequence is encoded to obtain spliced video data.
[0080] According to the number of splicing channels supported by the video splicing device (i.e., the number of source videos displayed simultaneously) and the resolution of each source video, the decoded video is adaptively scaled, with the goal of adjusting all source videos to a uniform size suitable for the splicing layout while maintaining the picture clarity as much as possible. Among them, the resolutions of the source videos to be spliced into the same channel can be freely combined according to the actual splicing requirements, and can be the same or different. Preferably, the resolutions of the source videos to be spliced into the same video stream are consistent.
[0081] In one embodiment, see Figure 3 , Figure 3 A schematic diagram of a video splicing scaling strategy pre-allocated memory block provided in this application. Figure 3 As shown, the total number of pixels required for the stitched image is calculated based on the source video resolution (after scaling), and then the size of the required memory block is determined, and a continuous memory area is applied for to store the stitched image sequence. According to the pre-defined stitching layout rules (such as tiling, picture-in-picture, overlay, etc.), each frame of at least two scaled videos is placed sequentially and accurately at the corresponding pixel position of the memory block. Ensure that the boundaries between images are aligned, without overlap or blank areas. In addition, if there are color space differences between the source videos (such as YUV and RGB), the necessary color space conversion is performed in this step to ensure the consistency of the color of the stitched image.
[0082] Set encoding parameters such as encoding format (such as H.264, HEVC), resolution, frame rate, bit rate, GOP structure, encoding quality, etc. according to business needs and storage / transmission conditions. Encode the spliced image sequence in real time to generate a continuous encoded bit stream. Encapsulate the encoded video data into a specified container format (such as MP4, TS, MKV, etc.), including video stream, possible audio stream, metadata and other information to ensure the integrity and playability of the video.
[0083] The encoded stitched video data is stored in the current video stitching device or transmitted to other devices for storage, or pushed to the client in real time through the network interface, and the stitched video data or files are saved according to the predetermined file naming rules and directory structure, and the relevant metadata (such as stitching time, source video information, encoding parameters, etc.) is recorded for subsequent query, playback and management.
[0084] S220: Store the video stitching information of the video stitching data in the first device, so that the first device can obtain each stitching video data based on the video stitching information of each stitching video data and extract the source video therefrom.
[0085] The first device receives and verifies the video stitching information of the video stitching data from the video stitching device, and stores it persistently in a local database or file system. When a certain stitched video data needs to be accessed, the first device finds the storage location of the corresponding source video in the device cluster according to the stored stitching information, and obtains the source video data through an appropriate method (such as HTTP download, internal API call, etc.).
[0086] If it is necessary to extract the original source video from the stitched video data, the first device can use the stored stitching layout information in combination with video processing software to reversely process the stitched video to separate the source videos, such as decoding, cropping, and re-encoding the stitched video.
[0087] The specific process of the first device acquiring each stitched video data based on the video stitching information of each stitched video data and extracting the source video therefrom has been described in detail in the above step S130, which will not be repeated here.
[0088] To better explain the video splicing storage method of this application, please refer to Figure 4 , Figure 4 The following specific embodiments of the video splicing storage method are provided for exemplary description, taking the redundant storage of video data in a NVR (Network Video Recorder) device under cluster management as an example, as follows:
[0089] 1. When multiple NVR devices are configured for video storage in a LAN environment, the management host manages all NVR devices in the LAN and automatically sets up a backup host. When the management host goes down, the backup host automatically takes over the responsibilities of the management host and performs the functions of the management host.
[0090] 2. Management data obtains video channel information of all NVR devices in the LAN, and groups source videos of the same encoding format into one group based on the camera configuration.
[0091] 3. The management host obtains the codec resource information of all NVR devices, and sorts the source videos in each group in step 2 based on the redundant codec resources.
[0092] 4. The management host centrally dispatches all NVR devices that need to be spliced and stored, and forwards video data of the same encoding format in different devices to devices with high encoding capabilities (giving priority to splicing and re-encoding source video data of the same encoding format in the same device).
[0093] 5. After splicing and re-encoding the source video using the excess encoding capacity of the device, the source video is stored or redundantly stored, and the management host records the backup data information for subsequent backup and recovery.
[0094] 6. If the management host crashes, return to step 1; if other devices crash, the management host will allocate the video channel of the crashed device to other devices. When the crashed device is restored, delete the camera temporarily added to other devices.
[0095] Among them, in step 4, the management host unified scheduling This application provides multiple methods. In one embodiment, please refer to Figure 5 , Figure 5 This is a flowchart of the unified scheduling strategy for the management host provided by this application. In this example, the splicing and re-encoding of source video data with the same encoding format in the same device are prioritized, and there are multiple IPCs (Internet Protocol Cameras) in the channel group. Figure 5 IPC1 and IPC2 in the middle channel group 1 multiplex the video data stream in NVR1 for splicing and re-encoding; if there are remaining groupings, the source video data of the same encoding format in different devices are forwarded to the device with high encoding capability, e.g. Figure 5 IPC3 and IPC4 come from NVR2 and NVR3 respectively. Currently, the redundant encoding and decoding capacity of NVR2 is higher than that of NVR3. The management host sends instructions and forwards IPC4 to NVR2. NVR2 re-takes the stream so that IPC3 and IPC4 are spliced and re-encoded in NVR2.
[0096] For example, see Figure 6 , Figure 6 This is a flowchart of multi-channel source video decoding, splicing, and re-encoding provided by this application. Figure 6 As shown in the figure, multiple video streams are input into the VEDC (Video Encoding and Decoding) video stream decoding module, and the redundant available decoding capacity of the NVR device that needs to be spliced and re-encoded is used to perform background decoding on the multiple video streams. In this way, multiple video data can be processed efficiently without affecting the normal function of the device.
[0097] The decoded data is transmitted to the VPSS (Video Processing Sub-System) video stream scaling module for scaling. VPSS is a hardware or software component specifically used for video processing, which can perform various complex operations on the video, such as scaling, cropping, color space conversion, etc. VPSS scales the decoded video according to the set number of splicing paths and the original resolution of each source video data stream, so as to uniformly scale all source video clips to a size suitable for the preset resolution output.
[0098] Taking the output of 1080P image as an example, pre-allocation forms a 1080P image, and its scaling strategy is as above Figure 3 As shown, apply for a virtual VO (Video Output) memory block such as a standard 1080P memory block to splice the scaled YUV data. Fill the YUV data (including brightness and chrominance information) after VPSS scaling into the above pre-allocated memory block according to the predetermined splicing layout to form a complete spliced picture. Then, encode the spliced YUV data to form a spliced standard 1080P video stream. Commonly used encoding methods include H.264, H.265, etc. to ensure efficient compression and transmission of video data.
[0099] While generating the stitched video, the system will record relevant metadata in the video file header and the associated database, such as the channel information of each source video involved in the stitching, frame information and the relative area information of each source video in the stitched picture. For example, the area position information can be recorded using the 8192 coordinate system to accurately describe the position and size of each video in the stitched picture.
[0100] Finally, the spliced video information data is transmitted back to the management host to provide data analysis for subsequent redundant data recovery. For example, if a certain segment of video data is lost, the backup data of the corresponding channel can be relocated and extracted according to the metadata, and then the regional location information can be used to accurately embed it into the corresponding position of the spliced screen to achieve effective recovery of redundant data.
[0101] The above strategy can adaptively convert the redundant decoding performance of the device, automatically adjust the workload, and ensure the effective use of resources without affecting the operation of the main business. When the device has redundant decoding performance, the strategy will start the processing flow of multiple video streams. At the same time, using the video splicing strategy and redundant encoding and decoding capabilities, multiple channels such as 1080P source videos are re-encoded into one 1080P video stream, thus reducing the total amount of redundant video data and forming a dynamic conversion of device performance. Without losing data, the total amount of redundant data backup is reduced to the greatest extent possible, reducing the cost of backup media.
[0102] In theory, if four 1080P videos are spliced and re-encoded into one new 1080P data channel, assuming that the data volume of each original video is equal and the encoding efficiency is consistent, the data volume of the new video will indeed drop to one-fourth (i.e. 25%) of the original, achieving significant data reduction. As the total data volume is reduced, the required storage space is reduced, which directly reduces the procurement cost and long-term operation and maintenance cost of backup media (such as hard disks, cloud storage, etc.). In addition, the time and network bandwidth required for backup and recovery operations will also be reduced accordingly, indirectly improving system efficiency.
[0103] 5. After the NVR device completes the splicing and re-encoding of the source video, it is stored or redundantly stored. The management host records the relevant splicing video information, such as channel number, stream type, resolution, and regional information of each video channel, and records it in the video file header and database, and uniformly transmits it back to the management host for data storage.
[0104] At the same time, all the spliced video information stored in the database is synchronized to the backup host at a regular interval to prevent the loss of spliced video information after the management host crashes.
[0105] If the management host goes down, the standby host is upgraded to the management host and takes over the functions of the original management host according to the contents of the database, that is, returns to the aforementioned step 1.
[0106] If other devices in the cluster fail to function properly, the management host will allocate the video channels in the failed device to other normal NVR devices. When the failed device is restored, the camera temporarily added to other devices will be deleted and the system will return to step 1.
[0107] When you need to view the backup data later, use the database content of the management host to restore the data. In this way, the business display is performed through the management host, and all device data backups are managed and displayed in a unified manner. In business use, there is no need to search for various NVR devices with scattered storage, and the query efficiency is higher.
[0108] Exemplarily, the management host obtains and organizes the redundant recording information, i.e., the spliced video information, of all the NVR devices it manages by accessing its associated database. This information may include the start and end time of the recording, recording segment identification, related metadata, etc., so that the user can intuitively understand the redundant recording resources available for playback. The user can select a certain recording segment to be played back in the management interface.
[0109] When the user clicks to select a redundant video, the management host further queries the database for detailed storage information associated with the selected video record. This information includes the IP address of the NVR that actually stores the video data, the channel number of the video (which may correspond to the camera number), the video stream type (such as main stream, sub-stream, etc.), and the relative coordinate position information of the video in the splicing display scene.
[0110] Based on the queried storage information, the management host initiates a request to the NVR device that actually stores the redundant video data, requesting the transmission of the specified video data. The request will include specific video ID, channel number, bitstream type and other parameters so that the NVR can accurately locate and transmit the required video.
[0111] After receiving the request, the storage NVR retrieves the corresponding video file from the local storage according to the request parameters and sends it back to the management host. After receiving the complete spliced video data, the management host starts decoding and converts the encoded video data into original video frames that can be directly used for display.
[0112] After decoding is completed, the management host performs a segmentation operation on the decoded video data according to the splicing display coordinate information of the video recording, that is, separating the video image of the specific channel requested by the user for playback from the overall spliced image. In this way, it is ensured that only the video content of the selected channel is presented to the user in the end, rather than the entire spliced view, realizing the effective use and accurate recovery of redundant data.
[0113] For further details on the video splicing storage method used in device clusters, see Figure 7 , Figure 7 This is a schematic diagram of a device cluster management process provided by this application. The cluster management strategy is applied to all NVR devices in a local area network environment. The specific process is as follows:
[0114] 1. Set up a management host, which uses broadcast / multicast to discover other devices and establish a backup management host.
[0115] For example, a random or designated device in the cluster is used as the management host. The management host searches for other NVR devices in the current LAN environment by sending broadcast or multicast messages, and adds other NVR devices to the management queue. The management host obtains the network throughput of the network card of the NVR device in the queue in the NVR device management queue, and selects an NVR device under preset conditions as the backup host, such as establishing an NVR with the lowest network throughput in the queue as the backup host.
[0116] 2. The management host and the backup management host communicate to keep alive; if the host fails, the backup host is upgraded to the host; if the backup host fails, a new backup host is selected. In addition, the management host periodically synchronizes the video splicing information database to the backup management host.
[0117] Exemplarily, the standby host and the management host establish keep-alive communication, that is, a two-way heartbeat mechanism is established between the standby host and the management host, and the online status of the other party is detected by periodically sending heartbeat packets. At the same time, the management host periodically synchronizes the video splicing information database to the standby host.
[0118] If the management host cannot connect to the backup host during the keep-alive period, the backup host is considered to be down, and a new backup host is re-established; if the management host is down, the backup host is automatically upgraded to the new management host, and the above step 1 is re-executed to establish a new backup host.
[0119] 3. The management host obtains the video channel information and codec resource information of other NVR devices, groups the video streams with the same encoding configuration, and gives priority to merging the video streams of the same NVR device in the same group.
[0120] For example, the management host communicates with all other NVR devices to obtain the video channel information and codec resource information of the NVR devices in the current LAN, including source video ID, video encoding format, resolution, frame rate, bit rate and other video parameters, as well as device ID, currently used codec resources, redundant codec resources and codec capabilities, etc., and group and sort according to the following rules:
[0121] a. All source videos with the same video encoding format are divided into one group;
[0122] b. In groups with the same video encoding format, those from the same device will be merged and arranged first.
[0123] 4. Based on the redundant codec resource information, the management host preferentially splices, re-encodes and redundantly stores the source video data of the same device and the same encoding configuration, and records the relevant video encoding, channel information and storage devices in the database.
[0124] Exemplarily, the management host instructs the splicing storage device to preferentially splice, re-encode, and redundantly store source video data of the same device and the same encoding configuration based on the redundant encoding and decoding resource information, thereby reducing reception and forwarding of spliced data.
[0125] The management host records relevant video splicing information such as video channel information, recording time, corresponding device IP / MAC, redundant data storage device IP / MAC, etc. in the database for redundant data recovery.
[0126] 5. After all redundant video data with the same encoding configuration in the same device is spliced, re-encoded and backed up, determine whether there are any remaining groups on the management host:
[0127] If there are remaining groupings, process the redundant video information of the remaining groupings, find the encoding capacity of the remaining NVRs, give priority to the devices with the largest remaining encoding capacity, send the source video streams to be spliced to the designated NVR, designate the NVR to splice and re-encode the received data streams for redundant storage, and the host records the relevant information.
[0128] Exemplarily, the redundant video channel information and codec resource information of other videos to be spliced in the remaining groups are rescreened to find the device with the strongest remaining codec capability among the remaining NVR devices. The management host sends instructions and forwards the source video stream to be spliced to the NVR device with the strongest remaining codec capability, and specifies the NVR device to splice, re-encode and redundantly store the received data stream. At the same time, the management host records the relevant spliced video information in the database. Repeat the above process until the splicing process of all videos to be redundantly stored is completed.
[0129] If there are no remaining groups, the current round of cluster management process ends, indicating that the video splicing process to be redundantly stored is completed.
[0130] See also Figure 8 , Figure 8 It is a structural diagram of an embodiment of an electronic device provided in the present application. The electronic device 60 includes a memory 61 and a processor 62 connected to each other. The memory 61 is used to store a computer program. When the computer program is executed by the processor 62, it is used to implement the video splicing storage method in the above embodiment.
[0131] The above-mentioned method is an embodiment, which can exist in the form of a computer program. Therefore, the present application proposes a computer-readable storage medium. Fig. 9 , Fig. 9 is a schematic diagram of the structure of an embodiment of a computer-readable storage medium provided in the present application. The computer-readable storage medium 80 is used to store a computer program 81, which can be executed to implement the video splicing storage method in the above embodiment.
[0132] The computer-readable storage medium 80 may be a server, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which may store program codes.
[0133] The above description is only an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A video splicing storage method, characterized in that: The video splicing storage method is applied to a device cluster, the device cluster includes multiple devices, one of the multiple devices is set as a first device, and the video splicing storage method is a method for splicing multiple source videos of at least one device in the device cluster for redundant storage, the method comprising: The first device in the device cluster determines the encoding format of each source video and redundant encoding and decoding resources of at least some devices; Grouping source videos of the same encoding format into the same group to obtain at least one group of source videos; Sending a video splicing instruction to the source devices of at least two source videos of the same source in each group of source videos, so that the source devices act as video splicing devices to splice and re-encode all source videos of the source devices in each group of source videos to obtain spliced video data; Based on the redundant codec resources of the source devices of the remaining source videos in each group of source videos, determine the video splicing devices of the remaining source videos, wherein the device with the strongest redundant codec resources among the source devices of the remaining source videos is used as the video splicing device of the remaining source videos, so that the video splicing device splices and re-encodes at least part of the remaining source videos to obtain the spliced video data, and the spliced video data is stored in at least one device of the device cluster; Acquire and store video stitching information of each stitched video data, so that the first device can acquire each stitched video data based on the video stitching information of each stitched video data and extract the source video therefrom; Wherein, the device is an NVR device.
2. The video splicing storage method according to claim 1, characterized in that: The step of obtaining and storing the video splicing information of each of the spliced video data further comprises: Determine the video splicing information of the source video to be extracted, and obtain the video splicing data of the source video to be extracted; Decoding the video splicing data to obtain decoded splicing data; The decoded spliced data is segmented according to the splicing display coordinate information of the source video to be extracted in the video splicing information to obtain the source video to be extracted.
3. The video splicing storage method according to claim 1, characterized in that: The method further comprises: Determining a backup device based on the network throughput of all devices in the device cluster except the first device; A keep-alive connection is established with the backup device so that when the first device goes offline, the backup device automatically becomes the first device.
4. A video splicing storage method, characterized in that: The video splicing storage method is applied to a device cluster, the device cluster includes multiple devices, one of the multiple devices is set as a first device, and the video splicing storage method is a method for splicing multiple source videos of at least one device in the device cluster for redundant storage, the method comprising: In response to obtaining a video splicing instruction issued by the first device, the video splicing device in the device cluster splices and re-encodes at least two source videos to be spliced indicated by the video splicing instruction to obtain video splicing data, and redundantly stores the video splicing data in at least one device in the device cluster; wherein the device is an NVR device; storing the video stitching information of the video stitching data in the first device, so that the first device can obtain each video stitching data based on the video stitching information of each video stitching data and extract the source video therefrom; The video splicing device in the device cluster splices and re-encodes at least two source videos to be spliced indicated by the video splicing instruction to obtain video splicing data, including: Grouping source videos of the same encoding format into the same group to obtain at least one group of source videos; Sending a video splicing instruction to the source devices of at least two source videos of the same source in each group of source videos, so that the source devices act as video splicing devices to splice and re-encode all source videos of the source devices in each group of source videos to obtain spliced video data; Based on the redundant codec resources of the source devices of the remaining source videos in each group of source videos, the video splicing devices of the remaining source videos are determined, wherein the device with the strongest redundant codec resources among the source devices of the remaining source videos is used as the video splicing device of the remaining source videos, so that the video splicing device splices and re-encodes at least part of the remaining source videos to obtain the spliced video data.
5. The video splicing storage method according to claim 4, characterized in that: The video splicing device in the device cluster splices and re-encodes at least two source videos to be spliced indicated by the video splicing instruction to obtain video splicing data, including: The video splicing device performs background decoding on the bit streams of at least two source videos to be spliced to obtain at least two decoded videos; Scaling at least two decoded videos according to the number of splicing paths of the video splicing device and the source video resolution to obtain at least two scaled videos; Applying for a memory block based on the source video resolution, and sequentially filling the images in at least two scaled videos into the memory block to obtain a spliced image sequence; The stitched image sequence is encoded to obtain the stitched video data.
6. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the processor is coupled to the memory, and the processor is configured to execute one or more steps of the video splicing storage method according to any one of claims 1 to 5 based on instructions stored in the memory.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the video splicing storage method according to any one of claims 1 to 5.
