A video stream processing method, a client uploading method and a server
By generating a file ID identifier that includes a source identifier and a timestamp, storage space and data nodes can be directly allocated, solving the problem of multiple interactions during video stream uploading in security scenarios. This simplifies the management of the distributed storage system, improves system performance and stability, and reduces hardware and network resource consumption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2022-10-17
- Publication Date
- 2026-05-01
AI Technical Summary
In security scenarios, when video streams captured by cameras are uploaded to a distributed storage system, existing technologies require multiple interactions to manage non-user-named files, resulting in an excessive burden on the distributed storage system. How can these files be effectively managed to reduce the number of interactions and alleviate the management burden?
By generating a file ID identifier for the video stream, which includes source identification information and timestamp information, storage space is directly allocated and data node information is returned. The client names the video stream according to the file ID identifier and writes it to the storage space, simplifying the video stream storage process and omitting the interaction with the metadata server.
It reduces network pressure, improves system performance and stability, reduces hardware and development costs, avoids the coupling problem between file directory services and storage file management services, saves bandwidth and network resources, and alleviates the management pressure of distributed storage systems.
Smart Images

Figure CN115795090B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data storage technology, and in particular to a video stream processing method, a client upload method, and a server. Background Technology
[0002] In a traditional distributed storage system architecture, users send files through a client, and the client stores the file through the distributed storage system. Alternatively, the client can be understood as the client retrieving the file to be stored and sending it to the distributed storage system. When the distributed storage system receives the file, it stores it. Therefore, the storage system needs separate directory and database services. As time goes on and the number of stored files increases, the burden on the distributed storage system becomes increasingly heavy.
[0003] In security scenarios, such as when cameras upload video streams to a distributed storage system, the uploaded data files are not user-named files, but rather streaming media data collected from cameras and other devices. Therefore, how to effectively manage these non-user-named files, reduce the number of interactions with the distributed storage system, and alleviate the management burden of the distributed storage system is a problem that needs to be solved. Summary of the Invention
[0004] This invention provides a video stream storage method, an operation method, and a client upload method, which can reduce the number of interactions in a distributed storage system and alleviate the management burden of the distributed storage system.
[0005] In a first aspect, embodiments of the present invention provide a video stream processing method, the method comprising:
[0006] Receive a new video stream request from the client, wherein the request carries at least source identifier information representing the source of the video stream;
[0007] The file ID identifier for generating the video stream includes at least the source identifier information and timestamp information. The timestamp information is converted based on the time when the request for the new video stream is received, or it is carried by the client when sending the request for the new video stream.
[0008] Allocate storage space corresponding to the file ID identifier of the video stream, and return the file ID identifier and the data node information to which the storage space belongs to the client, so that the client can connect to the corresponding data node according to the data node information, name the video stream with the file ID identifier, and write the video stream into the storage space.
[0009] Optionally, in some embodiments, the file ID identifier of the video stream may further include at least one of the following: capacity information representing the video stream and duration information representing the video stream.
[0010] Optionally, in some embodiments, the source identifier information, timestamp information, and / or capacity information, and / or video stream duration information contained in the file ID identifier of the video stream are one or more bytes in length and are sorted according to a set rule.
[0011] Optionally, in some embodiments, the method further includes:
[0012] Receive an operation request message sent by the client, wherein the operation request message carries the requested operation type and request conditions;
[0013] Determine the file ID identifier of the video stream that meets the requested conditions;
[0014] Based on the requested operation type and the file ID that meets the requested conditions, execute the corresponding operation method;
[0015] Return the result of the operation to the client.
[0016] The request conditions include the identification information of the video stream for which the operation is requested, and / or the time information of the video stream for which the operation is requested, and / or the storage space information of the video stream for which the operation is requested or the data node information of the storage space of the video stream.
[0017] Optionally, in some embodiments, the request operation types include: requesting to delete a video stream, requesting to query a video stream, requesting to change the storage location of a video stream, and requesting to add a new video stream.
[0018] Optionally, in some embodiments, when the request operation type is determined to be a request to delete a video stream, the step of determining the file ID identifier of the video stream that meets the request conditions; and executing the corresponding operation method according to the request operation type and the file ID identifier that meets the request conditions, specifically including:
[0019] Based on the video stream information, determine the file ID identifier of the video stream that meets the request conditions;
[0020] Based on the determined file ID, determine the storage space information corresponding to the file ID;
[0021] Delete the video stream from the storage space, causing the storage identifier of the storage space to change to an unallocated state, wherein the storage identifier is an identifier used to characterize whether the storage space allows data to be stored.
[0022] Optionally, in some embodiments, when the request operation type is determined to be a request to query a saved video stream, the step of determining the file ID identifier of the video stream that meets the request conditions; and executing the corresponding operation method according to the request operation type and the file ID identifier that meets the request conditions, specifically including:
[0023] Based on the video stream information, determine the file ID identifier of the video stream that meets the request conditions;
[0024] Based on the file ID, determine the data node information to which the storage space corresponding to the file ID belongs;
[0025] The data node information is returned to the client, enabling the client to connect to the data node based on the returned data node information and read the video stream from the storage space corresponding to the data node information.
[0026] Optionally, in some embodiments, when the request operation type is determined to be a request to change the storage location of a video stream, the step of determining the file ID identifier of the video stream that meets the request conditions; and executing the corresponding operation method according to the request operation type and the file ID identifier that meets the request conditions, specifically including:
[0027] Based on the requested conditions, determine the first storage space of the video stream that needs to be transferred out and the corresponding file ID identifier;
[0028] Determine the second storage space for the video stream to be transferred in;
[0029] Transfer the video stream from the first storage space to the second storage space;
[0030] Update the storage space and data node information of the video stream corresponding to the file ID to the second storage space and the data node information to which the second storage space belongs.
[0031] Optionally, in some embodiments, when the requested operation type is determined to be a request to change the storage location of a saved video stream, the step of determining the file ID identifier of the video stream that meets the request conditions; and executing the corresponding operation method according to the requested operation type and the file ID identifier that meets the request conditions, specifically including:
[0032] Based on the video stream information, determine the file ID identifier of the video stream that meets the request conditions and needs to be transferred out;
[0033] Based on the file ID identifier, determine the first storage space where the video stream corresponding to the file ID identifier is stored;
[0034] Determine the second storage space that needs to be transferred into the video stream and the data node information to which the second storage space belongs;
[0035] Transfer the corresponding video stream in the first storage space to the second storage space;
[0036] Update the storage space and data node information of the video stream corresponding to the file ID to the second storage space and the data node information to which the second storage space belongs.
[0037] Optionally, in some embodiments, it further includes:
[0038] Upon receiving a video streaming service stop command and determining that there are unfinished operations, the system stops receiving operation request messages from the client and continues to execute the unfinished operations.
[0039] Optionally, in some embodiments, a task set is also included, which is used to store the operation being executed as a task in the task set, and to delete the task from the task set after the task is executed;
[0040] The determination that there are operations that have not been completed specifically includes:
[0041] Determine that the set of tasks is not empty.
[0042] Secondly, embodiments of the present invention also provide a video stream client uploading method, including:
[0043] Receive a video stream write request from the video stream access terminal, wherein the write request carries source identifier information representing the source of the video stream;
[0044] Send a request to the server to add a new video stream, wherein the request carries at least the source identifier information;
[0045] The system receives a file ID identifier and data node information from the server, connects to the data node according to the data node information, names the video stream with the file ID identifier, and writes it to the storage space corresponding to the data node information.
[0046] Thirdly, embodiments of the present invention also provide a server, comprising:
[0047] The receiving module is used to receive a new video stream request sent by the client, wherein the request carries at least source identifier information that represents the source of the video stream;
[0048] The generation module is used to generate a file ID identifier for the video stream. The file ID identifier for the video stream includes at least the source identifier information and timestamp information. The timestamp information is converted according to the time when the request for the new video stream is received, or it is carried by the new video stream request sent by the client.
[0049] The allocation module is used to allocate storage space corresponding to the file ID identifier of the video stream, and return the file ID and the data node information to which the storage space belongs to the client, so that the client can connect to the corresponding data node according to the data node information, name the video stream with the file ID identifier, and write the video stream into the storage space.
[0050] Optionally, as one embodiment, the server further includes: a processing module;
[0051] The processing module is configured to receive an operation request message from the client, the operation request message carrying the request operation type and request conditions; determine the file ID identifier of the video stream that meets the request conditions; execute the corresponding operation method according to the request operation type and the file ID identifier that meets the request conditions; and return the result of the operation method execution to the client.
[0052] The request conditions include the identification information of the video stream for which the operation is requested, and / or the time information of the video stream for which the operation is requested, and / or the storage space information of the video stream for which the operation is requested or the data node information of the storage space of the video stream.
[0053] Fourthly, embodiments of the present invention also provide a video stream processing system, including: a cloud server and cloud storage space;
[0054] This device is configured to generate a file ID identifier for a video stream based on a new video stream request sent by a client, allocate cloud storage space, and return the file ID identifier and the data node information to which the cloud storage space belongs to the client, wherein the file ID identifier of the video stream is used to represent the corresponding video stream information; it is also configured to receive an operation request message sent by a client, execute a corresponding operation method according to the operation request message, and return the result of the operation method execution to the client;
[0055] The cloud storage space is used to store the video stream written by the client. The beneficial effects of this invention are that when the server receives a new video stream request from the client, it generates a file ID identifier for the video stream based on the source identifier information carried and directly returns the client node information. This eliminates the interaction process where the client and user request the file ID to be uploaded from the metadata server, reducing the overall network pressure and improving system performance and stability. Furthermore, the technical solution of this application does not require establishing a mapping relationship between the user's actual stored file name and the file ID within the storage system. Therefore, the functions of directory service / directory server / database can be eliminated, and the database for managing file directories in the distributed storage system is omitted, effectively reducing development and hardware costs. Moreover, since the directory service function is removed, there is no longer a coupling relationship between the file directory service and the storage file management service. The file ID is maintained only by the storage file management service, improving reliability and eliminating data inconsistency problems caused by any service failure of the file directory service and the storage file management service. In addition, the technical solution of this invention has fewer interaction processes, saving network resources and reducing network interactions caused by establishing a mapping relationship between the user's actual stored file name and the file ID within the storage system, saving bandwidth and alleviating the management pressure of the distributed storage system. Attached Figure Description
[0056] Figure 1 This is a schematic diagram of the file writing process in a distributed storage system in the prior art;
[0057] Figure 2 This is a schematic diagram of a system architecture applicable to an embodiment of the present invention;
[0058] Figure 3 A flowchart of a video stream processing method provided in an embodiment of the present invention;
[0059] Figure 4 This is a schematic diagram of the writing process of a video stream storage method provided in an embodiment of the present invention;
[0060] Figure 5 An example of a file ID identifier provided in an embodiment of the present invention;
[0061] Figure 6 Another example of a file ID identifier provided in this embodiment of the invention;
[0062] Figure 7 Another example of a file ID identifier provided in this embodiment of the invention;
[0063] Figure 8 Another example of a file ID identifier provided in this embodiment of the invention;
[0064] Figure 9 A flowchart of another video stream processing method provided in an embodiment of the present invention;
[0065] Figure 10 A flowchart of a method for determining the type of request operation provided in an embodiment of the present invention;
[0066] Figure 11 A flowchart illustrating a method for deleting a video stream, provided in an embodiment of the present invention;
[0067] Figure 12 A flowchart illustrating a method for changing the storage location of a video stream, provided as an embodiment of the present invention;
[0068] Figure 13 A flowchart illustrating another method for changing the storage location of a video stream, provided in an embodiment of the present invention;
[0069] Figure 14 A flowchart of a video stream query operation method provided in an embodiment of the present invention;
[0070] Figure 15 A flowchart of a video stream service stop operation method provided in an embodiment of the present invention;
[0071] Figure 16 Flowchart of another video stream service stop operation method provided in an embodiment of the present invention;
[0072] Figure 17 A flowchart of a video stream client upload method provided in an embodiment of the present invention;
[0073] Figure 18 A schematic block diagram of a server provided for an embodiment of the present invention;
[0074] Figure 19 A schematic block diagram of another server provided in an embodiment of the present invention;
[0075] Figure 20 This is a schematic diagram of a video stream processing system provided in an embodiment of the present invention. Detailed Implementation
[0076] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. 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.
[0077] It should be understood that in the description of the embodiments of the present invention, the terms "first" and "second" are used only for the purpose of distinguishing descriptions and should not be construed as indicating or implying relative importance, nor should they be construed as indicating or implying order.
[0078] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0079] In a traditional distributed storage system architecture, users send files through a client, and the client stores the file through the distributed storage system. Alternatively, the client can be understood as the client obtaining the file to be stored and sending it to the distributed storage system. When the distributed storage system receives the file, it stores it.
[0080] To facilitate the retrieval and management of the target file after it has been stored, the distributed storage system also needs to manage the file's metadata. The metadata is used to record information such as the file identifier and the file's storage address in the distributed storage system.
[0081] The filenames sent by users for storage vary widely, sometimes including various characters and words, and are not identical to the file identifiers. Therefore, the storage system needs a separate directory service and database to manage the mapping between the actual filenames and their corresponding file identifiers. The system determines the file identifier based on the user-sent filename and then further determines the file's specific storage location. As time progresses and the number of stored files increases, the distributed storage system becomes increasingly burdened. For details, please refer to the appendix. Figure 1 As shown.
[0082] From the appendix Figure 1 As can be seen, in order to store user files, the user files need to be repeatedly interacted with and processed before they can be stored in the corresponding data nodes, which will cause a heavy burden on the distributed storage system.
[0083] In security scenarios, such as when cameras upload video streams to a distributed storage system, the uploaded data files are not user-named files, but rather streaming media data collected from cameras and other devices. Therefore, how to effectively manage these non-user-named files, reduce the number of interactions with the distributed storage system, and alleviate the management burden of the distributed storage system is a problem that needs to be solved.
[0084] The system architecture of this application is briefly described below, such as... Figure 2 As shown.
[0085] Figure 2 The diagram illustrates a system architecture applicable to an embodiment of this application.
[0086] The client can have one or more connections, and each client can connect to several video stream access points. The number shown in the diagram is for illustrative purposes only and does not represent the actual number. The client receives various messages and video streams from monitoring devices such as cameras through the video stream access points.
[0087] The client connects to the distributed storage management system via a network. The distributed storage management system has one or more metadata management nodes, which can be simply understood as each metadata management node being a cloud server. The distributed storage management system controls one or more cloud storage spaces, which are used to store various data sent by the client and manage the data in the storage space. Typically, a distributed storage system includes a distributed storage management system and the various cloud storage spaces controlled by the management system. The distributed storage management system and the cloud storage spaces controlled by the management system can be located in the same location or distributed in different locations.
[0088] The following example illustrates the traditional file writing process in a distributed storage system, using a client connecting to a video stream access point and then to a metadata management node in the distributed storage system. (See attached image.) Figure 1 As shown, the specific steps can be summarized as follows:
[0089] 1) When a user reads or writes a file, a file write request is sent to the client, and the request carries a user-defined filename.
[0090] 2) After receiving the request, the client sends a request to the metadata management node to request the file ID.
[0091] 3) When the metadata service receives a request, it generates the corresponding file ID based on the file name, writes the mapping relationship between the file name and the file ID into the database through the directory service, and returns the file ID to the client.
[0092] 4) The client returns the file ID to the user.
[0093] 5) The user initiates a file read / write request to the client based on the file ID to obtain the data node.
[0094] 6) The client requests data node information from the metadata management node based on the file ID.
[0095] 7) When the metadata service receives a request for data node information, it allocates the corresponding data node according to the file ID and returns the data node information to the client.
[0096] 8) The client connects to the data node based on the data node information returned by the metadata node and writes the user's file into the data node.
[0097] One reason why users need to go through multiple steps when storing files with custom names in a distributed file storage system (which can also be understood as a cloud storage system) is that a distributed file storage management system typically has two databases and two services. One database and related services manage the file directory, managing and recording the mapping relationship between user file names and file IDs. The other database and related services manage the stored files, managing and recording information such as the storage address of the file represented by the file ID in the distributed storage system to facilitate operations such as searching. Therefore, if a user needs to store a file in a distributed file storage system, they need to first apply for a file ID from the distributed file storage management system. Only after obtaining the file ID can they store the file to be stored in the distributed file storage system using the file ID as the key. Thus, even a single write operation involves multiple communication and interaction steps, placing a heavy burden on the distributed storage system.
[0098] Therefore, a traditional distributed storage system requires multiple interactions and requests for a single file write operation. Distributed storage systems need to process various write and query requests from clients in parallel. As time goes on and the number of stored files increases, the burden on the distributed storage system will become increasingly heavy.
[0099] However, in security scenarios, the data that needs to be stored is not user files, but streaming media data collected from devices such as cameras / recorders. Streaming media data is usually video stream files in a uniform format and cannot be named by the user. In security scenarios, there are many video stream access points, frequent client requests, a large amount of new data being written continuously, and many query requests. Therefore, if the traditional distributed file storage system is used, it will greatly increase its workload.
[0100] Therefore, in the context of security scenarios, how to design the workflow of a distributed file storage system, reduce the number of interactions, alleviate the workload of the distributed file storage system, and improve the interaction process is a technical problem that needs to be solved.
[0101] This invention provides a video stream processing method, the method comprising:
[0102] Receive new video stream requests from clients, the requests must include at least source identifier information representing the source of the video stream;
[0103] The file ID identifier for generating the video stream includes at least source identifier information and timestamp information. The timestamp information is converted based on the time when the request for a new video stream is received, or it is carried by the client when sending the request for a new video stream.
[0104] The system allocates storage space corresponding to the file ID of the video stream and returns the file ID and data node information to which the storage space belongs to the client. The client then connects to the corresponding data node based on the data node information, names the video stream with the file ID, and writes the video stream into the storage space.
[0105] The following specific embodiments illustrate this, as shown in the attached figures. Figure 3 As shown.
[0106] S301: Receive a request for a new video stream from the client, the request carrying at least source identifier information representing the source of the video stream.
[0107] Before the client sends a new video stream request to the server of the distributed storage system, the client will receive a new video request from the video stream access end. The video stream access end will carry source identification information and send a new video request to the client. The source identification information is the identification information that represents the source of the video stream. For example, it can be the device identification information of the camera, the channel ID assigned by the system, or the location information of the camera, etc., which can distinguish the source of different video streams. After the client receives the new video stream request, it needs to apply for a new video stream request from the server.
[0108] The source identifier information representing the source of the video stream carried in the new video stream request sent by the client to the server can be the same as or different from the source identifier sent by the video stream access end. The client only needs to distinguish between different video stream sources. However, the source identifier information sent to the server needs to meet the server's requirements. Therefore, to meet the server's requirements, the client may optionally convert the source identifier information sent by the video stream access end into source identifier information that meets the server's requirements. In this way, both the client and the server can distinguish video streams sent by different video stream access ends based on the source identifier information.
[0109] S302: The file ID identifier for the generated video stream. The file ID identifier for the video stream includes at least source identifier information and timestamp information. The timestamp information is converted based on the time when the request for a new video stream is received, or it is carried by the client when sending the request for a new video stream.
[0110] After receiving a new video stream request, the server generates a file ID based on the source identifier and timestamp information sent by the client. The timestamp can be obtained by converting the time when the server receives the new video stream request from the client, or by converting the time carried in the new video stream request sent by the client. If it is obtained by converting the time when the server receives the new video stream request from the client, the timestamp is based on the server's time. If it is obtained by converting the time carried in the new video stream request sent by the client, the time can be the time when the client receives the video stream access request, or the time carried in the video stream when sending the new video stream request to the client. If it is the time when the client receives the video stream access request, the timestamp is based on the client's time. If it is the time carried in the video stream when sending the new video stream request to the client, the timestamp is based on the video stream device's time.
[0111] Preferably, the timestamp should be based on the time when the server receives the request for a new video stream. This way, the time of all video streams on the server is based on the server's time. Even if different cameras or different clients send video streams, the time will be based on the server's time, resulting in relatively uniform time and avoiding time differences between different clients and different cameras.
[0112] Of course, those skilled in the art can choose according to their actual needs to obtain the required timestamp information.
[0113] S303: Allocate storage space corresponding to the file ID of the video stream, and return the file ID and data node information to which the storage space belongs to the client, so that the client can connect to the corresponding data node according to the data node information, name the video stream with the file ID, and write the video stream to the storage space.
[0114] Once the file ID is determined, the server allocates storage space to store the new video stream requested by the client. The server identifies the new video stream as the file ID and saves it to disk. Subsequent management of the video stream is then performed based on this file ID, such as deleting or querying the video stream.
[0115] Once storage space is allocated, the server sends the file ID and the data node information to which the storage space belongs to the client. The client connects to the corresponding data node based on the data node information, names the video stream with the file ID, and writes the video stream into the storage space.
[0116] The embodiments of the present invention simplify the steps of adding new video streams compared to traditional distributed storage systems, as detailed in the appendix. Figure 4 As shown, attached Figure 4This is a schematic diagram of the writing process of a video stream storage method provided by the present invention.
[0117] The technical solution of this invention, in order to write a video stream to a file in a distributed storage system, requires only four steps: Step S401: The video stream access terminal sends a request to the client to add a new video stream, carrying the source identifier information of the video stream source. Step S402: The client sends a request to the server to add a new video stream, carrying the source identifier information of the video stream source. Step S403: Based on the request sent by the client, the server generates a file ID identifier, allocates a data node to which the storage space belongs for storing the video stream, and sends the data node to the client. Step S404: The client connects to the data node and writes the video stream into the storage space corresponding to the data node.
[0118] Therefore, in the technical solution of this application, when the server receives a new video stream request from the client, it generates a file ID identifier for the video stream based on the source identifier information carried and directly returns the client node information. This eliminates the interaction process between the client and the user requesting the file ID to be uploaded from the metadata server, reducing the overall network pressure and improving the system performance and stability. Furthermore, the technical solution of this application does not require establishing a mapping relationship between the user's actual stored file name and the file ID within the storage system. Therefore, the functions of the directory service / directory server / database can be removed, eliminating the database for managing the file directory in the distributed storage system, which can effectively reduce development and hardware costs. Moreover, since the function of the file directory service is removed, there is no longer a coupling relationship between the file directory service and the storage file management service. The file ID is maintained only by the storage file management service, which improves reliability and eliminates the data inconsistency problem caused by the failure of either the file directory service or the storage file management service. In addition, the technical solution of this invention has fewer interaction processes, saves network resources, reduces network interaction caused by establishing a mapping relationship between the user's actual stored file name and the file ID within the storage system, saves bandwidth, and alleviates the management pressure of the distributed storage system.
[0119] Furthermore, the client names the video stream to be written to storage space using the server's file ID identifier, eliminating the need for the client to define the video stream name manually. Therefore, the naming of the video stream is handled by the server, which can define names conforming to specified rules or requirements based on its own needs. Since the file ID identifier needs to be stored and transmitted over the network, the server can define a serialized file ID identifier, eliminating the need for transcoding during disk storage and network transmission, thus saving server resources. Moreover, by omitting the user's file naming process, the client does not need to inform the video stream access point of the named file ID; the client only needs to use the file ID identifier sent by the server as the video stream file name for the data node to be written. If the server malfunctions and loses the mapping relationship between file ID identifiers and their corresponding storage spaces, the mapping table can be restored by reading the file name of the video stream stored in storage space and using it as the file ID identifier.
[0120] Furthermore, in the technical solution of this application, the video stream information can be obtained through the corresponding file ID identifier. That is, the file ID identifier can not only be used to identify the video stream, but also serve as the video stream information and be stored. By parsing the file ID identifier, the corresponding video stream information can be obtained, eliminating the need to store the video stream information through a separate database, thus saving storage space and the resource consumption of managing the database. The mapping relationship between the file ID identifier and the corresponding stored information can be stored and maintained in the form of a file. The mapping relationship can be obtained by reading the file. Therefore, in the technical solution of this application, the server does not need a separate database, eliminating the resource consumption caused by the server accessing the database and reducing the management burden of the distributed storage system.
[0121] Optionally, as one embodiment, the file ID identifier of the video stream may also include at least one of the following: information representing the capacity of the video stream and information representing the duration of the video stream.
[0122] The file ID identifier of the video stream contains source identifier information, timestamp information, and / or capacity information, and / or video stream duration information, which are one or more bytes in length and sorted according to a set rule.
[0123] The following is an explanation through specific examples.
[0124] For security cameras, the client and server typically have a pre-agreed agreement regarding the video streams to be stored in cloud storage. The server allocates storage space reasonably based on the storage space required for the video stream or its duration. While the source identifier and timestamp information can uniquely identify the video stream, in actual management and use, these information alone are insufficient. Therefore, additional information can be added to the video stream's file ID.
[0125] Generally, for similar cameras that use the same pixel to capture images, the generated video streams will have the same capacity and duration over the same period of time. Therefore, by judging either the capacity information or the duration information of the video stream, the other information can be analyzed based on one of the information. Thus, the file ID identifier only needs to contain at least one of the information representing the capacity and duration of the video stream, or it can contain both.
[0126] Of course, the capacity information of the frequency stream and the duration information of the video stream can be reflected in the file ID identifier for subsequent management and retrieval. Those skilled in the art can make appropriate modifications based on this embodiment.
[0127] Appendix Figure 5 This illustrates an example of file ID identification information. It should be noted that the byte length and order in the file ID identification information are defined according to set rules and should not constitute a limitation on the present invention.
[0128] As attached Figure 5 As shown, optionally, the file ID identifier can be set as follows: the file ID identifier has 6 bytes, of which the first two bytes are used to represent the source identifier information of the video stream, and the last 4 bytes are used to represent the timestamp information.
[0129] In a computer, one byte occupies 8 bits, and each bit has two states: 0 and 1. Therefore, one byte can represent 2^32 bytes. 8 =256 states, therefore, a 2-byte source identifier can be used to represent 2 16 =65536 states, which is equivalent to being able to distinguish 65536 video streams from different sources. Of course, in practice, the rules can be adjusted according to actual needs, and the length of the bytes representing the source identification information can be appropriately increased or decreased. When the byte length is adjusted, the number of video streams used to represent different sources will also change accordingly.
[0130] The timestamp information refers to the total number of seconds since Greenwich Mean Time 00:00:00 on January 1, 1970 (08:00:00 Beijing Time on January 1, 1970) until now. The timestamp information occupies 4 bytes and can represent 2... 32 Different states, according to calculations, can represent the number of seconds within 136.2 years, i.e., a 4-byte timestamp. If calculated from 08:00:00 Beijing time on January 1, 1970, it has enough bits to represent the number of seconds up to 2106. Therefore, in this embodiment, using 4 bytes to represent the timestamp information meets practical needs. Of course, the byte length representing the timestamp information, or the order with the source identifier information, can be adjusted according to actual needs.
[0131] The rules for setting file ID identifiers can also be as follows: Figure 6 As shown, the file ID identifier is 10 bytes long. The first 6 bytes are the same as described in the previous embodiment, used to represent source identification information and timestamp information. The newly added last 4 bytes are used to represent capacity information, which can represent up to 2... 32 The capacity information is 16 bits, therefore, it can represent a video stream with a capacity of nearly 4G.
[0132] Of course, it can also be based on actual needs, such as Figure 7 As shown, the file ID identifier is 8 bytes long. The first 6 bytes represent source identifier information and timestamp information, and the last 2 bytes are used to represent the duration of the current video stream. The duration information can also be counted in seconds. 2 bytes can represent a maximum duration of 65536 seconds, equivalent to more than 18 hours, which can meet practical needs. Of course, it can be adjusted appropriately as needed, increasing or decreasing the number of bytes representing the duration information. Or as... Figure 8 As shown, the file ID identifier has 12 bytes. The first 6 bytes represent the source identifier information and timestamp information, the 7th and 8th bytes represent the duration information of the current video stream, and the 9th to 12th bytes represent the capacity information of the current video stream.
[0133] The source identifier, timestamp, capacity, and video stream duration contained in the file ID can be set reasonably according to actual needs; examples will not be provided here.
[0134] In embodiments of this invention, the file ID identifier occupies only 6-12 bytes. Therefore, the file ID identifier occupies little space, transmits few bytes, and meets serialization requirements. No transcoding is required during storage or network transmission, further reducing the overall network interaction pressure and metadata server processing pressure. The file ID identifier can also be freely adjusted to meet actual needs. Furthermore, based on the file ID identifier and parsing according to preset rules, the corresponding video stream information can be determined. Therefore, a separate database is not needed to manage video stream information; the corresponding video stream information can be obtained simply by acquiring the file ID identifier, replacing some of the functions of a database for managing stored files. The mapping relationship between the file ID identifier and the corresponding stored information can be stored in a file, such as a text file. Therefore, the file ID identifier and the mapping relationship between the file ID identifier stored in file form and the corresponding stored information can replace a database for managing stored files. The cloud storage system, having already eliminated the database for managing file directories, further eliminates the database for managing stored files. Therefore, the technical solution of this invention does not require database support from the server; it can run and be managed in the server's memory. Compared to the database approach, execution in memory is faster and more efficient.
[0135] Optionally, as one embodiment, the method further includes:
[0136] Receive operation request messages sent by the client. The operation request messages carry the requested operation type and request conditions.
[0137] Determine the file ID of the video stream that matches the request criteria;
[0138] Based on the requested operation type and the file ID that meets the request conditions, execute the corresponding operation method;
[0139] Return the result of the operation to the client;
[0140] The request conditions include the identification information of the video stream for which the operation is requested, and / or the time information of the video stream for which the operation is requested, and / or the storage space information of the video stream for which the operation is requested, or the data node information of the storage space of the video stream.
[0141] The following is an illustration through specific examples.
[0142] See Figure 9 , Figure 9 This is a flowchart of a video stream operation method provided in an embodiment of the present invention.
[0143] S901: Receives operation request messages from clients, which carry the requested operation type and request conditions.
[0144] When the server-side service starts, it reads the file ID identifier based on the received video stream service start command, parses the video stream information represented by the file ID identifier, and determines the storage space where the video stream corresponding to the file ID identifier is stored and the data node information to which the storage space belongs. The video stream information includes at least the video stream identifier information and the video stream timestamp information. As described above, the file ID identifier is stored according to the method in the aforementioned embodiments. Therefore, parsing the file ID identifier can determine the content contained in the video stream information represented by the current file ID identifier. The video stream information includes at least the video stream identifier information and the video stream timestamp information. Optionally, if the file ID identifier also contains video stream capacity information and video stream duration information, these can also be obtained by analyzing the file ID identifier.
[0145] When allocating storage space, the server saves the mapping relationship between file ID identifiers and the storage space corresponding to the file ID identifiers. This mapping relationship can be saved by a file, such as a text file, or it can be saved and retrieved through a database. It can be designed reasonably according to actual needs. Therefore, when reading the file ID identifier, the storage space information corresponding to the video stream represented by the file ID identifier can also be obtained.
[0146] Preferably, the video stream information corresponding to the parsed file ID can be read into the server's memory. The file ID is stored as bytes conforming to a set rule; therefore, it is serialized data that can be directly read from the disk. When the service starts, it reads the serialized file of the file ID from the disk and then deserializes it into memory. The memory then contains the corresponding video stream information for that file ID. Therefore, when parsing the file ID and obtaining the video stream information, the video stream information corresponding to the file ID is read into the server's memory as the server starts. When subsequent client requests arrive, various operations can be performed in memory, resulting in high efficiency. Furthermore, as needed, the updated file ID and corresponding video stream information can be serialized into the disk for permanent storage.
[0147] At this point, the server startup process is complete.
[0148] Once the server service starts, it processes various operation request messages received from clients. These request messages include, but are not limited to, deleting a specified video, querying a specified video, or changing or querying the storage location of a video stream.
[0149] The operation request message sent carries the requested operation type and request conditions. The requested operation type includes query, delete, add, etc.
[0150] S902: Determine the file ID identifier of the video stream that meets the request conditions.
[0151] The request conditions include the identification information of the video stream for which the operation is requested, and / or the time information of the video stream for which the operation is requested, and / or the storage space information of the video stream for which the operation is requested, or the data node information of the storage space of the video stream.
[0152] Therefore, the file ID of the video stream that meets the request conditions can be determined by matching the request operation type and request conditions carried in the operation request message with the parsed video stream information and video stream storage information.
[0153] S903: Execute the corresponding operation method based on the requested operation type and the file ID that meets the request conditions.
[0154] Based on the various operation requests sent by the client, execute the corresponding operation methods.
[0155] S904: Returns the result of the operation to the client.
[0156] Based on the different operation requests from the client, the system returns the result of the operation to the client, such as whether the operation was successful or not, or the data node information of the storage space of the video stream to be queried.
[0157] Typically, servers in distributed storage systems require two databases: one for managing file directories and another for managing stored files. However, in the security scenario described in this application, since the stored data is not user files, the database for managing file directories is eliminated through the storage process described in the aforementioned embodiments, and correspondingly, the directory service / database function of the metadata server is also eliminated. In the embodiments of this application, video stream information is used as a file ID identifier and saved, which can replace some of the functions of managing the stored file database. It is only necessary to save the mapping relationship between the storage space where the video stream corresponding to the file ID is stored and the data node information to which the storage space belongs. The mapping relationship can be recorded in the form of a file without the need for a database, such as using text files or other forms of recording. Therefore, the server-side stored file database can be further eliminated. It is only necessary to use ordinary files to save the storage space where the video stream corresponding to the file ID is stored and the data node information to which the storage space belongs. Therefore, in the embodiments of this application, the metadata management node of the distributed storage system does not need to have a database for managing file directories and a database for managing stored files; it only needs to save the storage space where the video stream corresponding to the file ID is stored and the data node information to which the storage space belongs.
[0158] Therefore, in the technical solution of the embodiments of the present invention, the server does not need to use database management. Moreover, the technical solution of the present invention can directly read the video stream information into the server's memory when analyzing the file ID information. When the client sends a request later, the various operations of the request can be performed in memory, which is highly efficient. After the operation is completed, the updated file ID identifier and the corresponding video stream information (the storage space where the video stream corresponding to the file ID identifier is stored and the data node information to which the storage space belongs) can be serialized to the disk for permanent storage.
[0159] Furthermore, by persistently storing the file ID identifier and the corresponding video stream's storage space information on the disk, the metadata server can restart and load the file ID serialization file when the metadata service starts, reconstruct the file ID identifier and the corresponding video stream information in memory, and manage and operate them in memory. Therefore, the technical solution of this application embodiment can manage the file ID identifier, the corresponding video stream information, and the stored storage space information in the memory of the metadata server without operating the database. Compared with the traditional method of storing the file name and file ID identifier mapping relationship together in the directory service / database, this method occupies less disk space while ensuring that the file ID identifier information is not lost. Moreover, the operation and data interaction are carried out in memory, and the requirements for the storage medium of its own data are not high. A mechanical disk is sufficient to meet the usage requirements. Traditional server technical solutions require SSD disks to meet the storage needs because the database needs to frequently read and write data from the disk. However, SSD disks are much more expensive than mechanical disks. Therefore, the technical solution of this invention embodiment does not require SSD disks and only requires ordinary mechanical disks to store data, reducing the hardware and maintenance costs of the distributed storage system.
[0160] Optionally, as one embodiment, the request operation types include: requesting to delete a video stream, requesting to query a video stream, requesting to change the storage location of a video stream, and requesting to add a new video stream.
[0161] As attached Figure 10 As shown, when the server receives an operation request message from the client, it determines the type of operation requested in the message, determines the corresponding process based on the determined operation type, and executes the corresponding operation.
[0162] S1001: Receive the operation request message sent by the client and determine the operation type contained in the operation request message.
[0163] S1002: Determine if the operation type is a request to delete the video stream. If yes, proceed to step A; otherwise, proceed to step S1003.
[0164] S1003: Determine whether the operation type is a request to query the video stream. If yes, proceed to step B; otherwise, proceed to step S1004.
[0165] S1004: Determine whether the operation type is a request to change the storage location of the video stream. If yes, proceed to step S1007; otherwise, proceed to step S1005.
[0166] S1005: Determine if the operation type is a request to add a video stream. If yes, proceed to step D; otherwise, proceed to step S1006.
[0167] S1006: Return an alarm to the client indicating an abnormal operation type;
[0168] S1007: Determine whether the requested operation is storage space information / data node information in the request conditions. If yes, execute step C1; otherwise, execute step C2.
[0169] The process of requesting a new video stream, D, is the same as the process of adding a new video stream in the aforementioned embodiments. For details, please refer to the above embodiments; examples will not be repeated here. For other steps A, B, C1, and C2, please refer to the appendix. Figure 11 Appendix Figure 12 Appendix Figure 13 Appendix Figure 14 The steps in the process.
[0170] Referring to the above embodiments, once the video streaming service is started, the corresponding file ID, video stream information, and storage information are already stored in memory. Therefore, when a request is received from a client, the corresponding operation can be performed based on the operation type and request conditions in the client's request. During the execution of the corresponding operation, the process can be carried out in the server's memory, without requiring a separate database service, resulting in high efficiency, fast response, and good processing effects.
[0171] The request operation types include: requesting to delete a video stream, requesting to query a video stream, and requesting to change the storage location of a video stream. The following is an explanation through specific examples.
[0172] When the request operation type is determined to be a request to delete a video stream, the file ID identifier of the video stream that meets the request conditions is identified; based on the request operation type and the file ID identifier that meets the request conditions, the corresponding operation method is executed, specifically including:
[0173] Based on the video stream information, determine the file ID identifier of the video stream that meets the request conditions;
[0174] Based on the determined file ID, determine the storage space information corresponding to the file ID;
[0175] Deleting the video stream from the storage space changes the storage space's storage identifier to an unallocated state. The storage identifier is used to indicate whether the storage space allows data to be stored.
[0176] Referring to the above embodiments, once the video streaming service is started, the memory already contains the corresponding file ID, video stream information, and storage information. Therefore, when a request to delete a video stream is received, such as... Figure 11 As shown, process A is as follows:
[0177] S1101: When the request operation type is determined to be a request to delete a video stream, determine the request conditions for the video stream to be deleted.
[0178] If the request operation type is to delete a video stream, the request conditions for the video stream to be deleted are determined based on the request conditions in the request message.
[0179] The request conditions include the identification information of the video stream for which the operation is requested, and / or the time information of the video stream for which the operation is requested, and / or the storage space information of the video stream for which the operation is requested, or the data node information of the storage space of the video stream.
[0180] S1102: Determine the file ID identifier of the video stream that meets the request conditions based on the request conditions and video stream information.
[0181] Based on the determined request conditions of the video stream to be deleted and the video stream information stored in memory, the file ID identifier of the video stream matching the request conditions is determined. The file ID identifier can identify the source identifier information and timestamp information of the video stream. The memory also contains the storage space where the video stream corresponding to the file ID identifier is stored and the data node information to which the storage space belongs. Therefore, based on the determined request conditions of the video stream to be deleted and the video stream information stored in memory, the file ID identifier of the video stream matching the request conditions can be determined. Moreover, there can be one or more file ID identifiers matching the request conditions of the video stream to be deleted, which is not limited here.
[0182] S1103: Determine the storage space information corresponding to the file ID based on the determined file ID identifier.
[0183] Once the file ID that matches the request conditions for the video stream to be deleted is determined, the storage space information corresponding to the file ID needs to be determined. The storage space information includes the data node information to which the storage space belongs, so that the next step can be performed based on the data node information.
[0184] S1104: Delete the video stream in the storage space, causing the storage identifier of the storage space to change to an unallocated state. The storage identifier is an identifier used to characterize whether the storage space allows data to be stored.
[0185] After determining the storage space to be deleted, delete the video stream in the storage space. The deletion method is not limited. It can be done by clearing the data or by deleting the storage space index. There is no restriction here. The goal is to change the storage identifier of the storage space to an unallocated state. The storage identifier is used to indicate whether the storage space allows data to be stored. That is, the storage space is in an unallocated state, and new video stream files can be stored in the current storage space.
[0186] S1105: Update and save the file ID identification information and storage space information.
[0187] The file ID identifier information in memory is deleted, the status of the corresponding storage space is updated, and the corresponding file ID identifier information and corresponding storage space information that have been written to disk are deleted so that the video streaming service can correctly read the contents of the file when it restarts.
[0188] When the request operation type is determined to be a request to change the storage location of a video stream, the file ID identifier of the video stream that meets the request conditions is identified; based on the request operation type and the file ID identifier that meets the request conditions, the corresponding operation method is executed, specifically including:
[0189] Based on the request conditions, determine the first storage space of the video stream that needs to be transferred out and the corresponding file ID identifier;
[0190] Determine the second storage space for the video stream to be transferred in;
[0191] Transfer the video stream from the first storage space to the second storage space;
[0192] Update the storage space and data node information of the video stream corresponding to the updated file ID to the second storage space and the data node information to which the second storage space belongs.
[0193] The following describes specific embodiments, see appendix. Figure 12 As shown, Figure 12 The flowchart for an operation method to change the storage location of a video stream is shown below, with process C1 as follows.
[0194] S1201: Based on the request conditions, determine the first storage space of the video stream that needs to be transferred out and the corresponding file ID identifier.
[0195] The request conditions include the identification information of the video stream to be operated on, and / or the time information of the video stream to be operated on, and / or the storage space information of the video stream to be operated on or the data node information of the storage space of the video stream. When the request conditions request the operation of the storage space information of the video stream or the data node information of the storage space of the video stream, it is necessary to determine the first storage space of the video stream to be transferred out and the corresponding file ID identifier, that is, to determine the corresponding file ID identifier to be transferred out according to the storage space of the video stream.
[0196] S1202: Determine the second storage space for the video stream to be transferred in.
[0197] When the request condition is a request operation type of requesting to change the storage location of the video stream, optionally, the request condition can carry a requirement for a second storage space to be moved into the video stream, such as... Figure 2 If video stream data in cloud storage space 1 is transferred to cloud storage space 2, then the metadata management node server allocates a second storage space in the corresponding cloud storage space 2 according to the request conditions. The allocated second storage space is allocated based on the file ID identifier. Therefore, if there are multiple storage spaces corresponding to file ID identifiers to be allocated, multiple second storage spaces corresponding to the file ID identifiers to be transferred into the video stream will be allocated.
[0198] If the request does not specify a second storage space for the video stream to be moved in, the metadata management node will allocate the second storage space for the video stream to be moved in as appropriate. For example, if the request is to move all video stream files out of cloud storage space 1, then the metadata management node will allocate the second storage space for the video stream to be moved in as appropriate.
[0199] S1203: Transfer the video stream in the first storage space to the second storage space.
[0200] S1204: Update the storage space and data node information of the video stream corresponding to the file ID identifier to the second storage space and the data node information to which the second storage space belongs.
[0201] Once the transfer is complete, update the storage space and data node information of the video stream corresponding to the file ID in memory to the second storage space and the data node information to which the second storage space belongs, and update the storage space and data node information of the video stream corresponding to the file ID in disk to the second storage space and the data node information to which the second storage space belongs.
[0202] Optionally, when the request operation type is determined to be a request to change the storage location of a saved video stream, the file ID identifier of the video stream that meets the request conditions is determined; based on the request operation type and the file ID identifier that meets the request conditions, the corresponding operation method is executed, specifically including:
[0203] Based on the video stream information, determine the file ID identifiers of the video streams that meet the request conditions and need to be transferred out.
[0204] Based on the file ID identifier, determine the first storage space where the video stream corresponding to the file ID identifier is stored;
[0205] Determine the second storage space that needs to be transferred into the video stream and the data node information to which the second storage space belongs;
[0206] Transfer the corresponding video stream from the first storage space to the second storage space;
[0207] Update the storage space and data node information of the video stream corresponding to the updated file ID to the second storage space and the data node information to which the second storage space belongs.
[0208] The following specific examples illustrate this, see appendix. Figure 13 As shown, attached Figure 13 The flowchart of another method for changing the storage location of a video stream provided in this embodiment is as follows, and the process C2 is as follows.
[0209] S1301: Based on the video stream information, determine the file ID identifier of the video stream that meets the request conditions and needs to be transferred out.
[0210] If the request conditions include video stream identifier information and / or time information of the requested video stream, then the request conditions are matched with the video stream information in memory to determine the file ID identifier of the video stream that needs to be transferred out that matches the request conditions. For example, if the request condition is to transfer a video stream that matches a certain source identifier information into cloud storage space 1, then for this request condition, all file ID identifiers that match a certain source identifier information in the distributed storage management system are first determined, and then the file ID identifiers that are not in cloud storage space 1 are determined from them. As another example, if the request condition is to transfer a video stream that matches a certain day to cloud storage space 3, then the timestamp range is determined according to the request conditions, and the file ID identifiers that match the request conditions are determined according to the timestamp range.
[0211] S1302: Determine the first storage space where the video stream corresponding to the file ID is stored based on the file ID identifier.
[0212] Once the file ID is determined, the first storage space where the video stream corresponding to the file ID is stored is determined based on the saved mapping relationship between the file ID and the storage space corresponding to the file ID.
[0213] S1303: Determine the second storage space to be transferred into the video stream and the data node information to which the second storage space belongs.
[0214] Based on the request conditions or actual situation, the metadata management node service determines the second storage space and the data node information of the second storage space. The second storage space is the second storage space that needs to be transferred into the video stream. If multiple file ID identifiers are determined, then there are multiple second storage spaces.
[0215] S1304: Transfer the corresponding video stream in the first storage space to the second storage space.
[0216] S1305: Update the storage space and data node information of the video stream corresponding to the file ID identifier to the second storage space and the data node information to which the second storage space belongs.
[0217] Once the transfer is complete, update the storage space and data node information of the video stream corresponding to the file ID in memory to the second storage space and the data node information to which the second storage space belongs, and update the storage space and data node information of the video stream corresponding to the file ID in disk to the second storage space and the data node information to which the second storage space belongs.
[0218] Optionally, as one embodiment, when the request operation type is determined to be a request to query a saved video stream, the file ID identifier of the video stream that meets the request conditions is determined; based on the request operation type and the file ID identifier that meets the request conditions, the corresponding operation method is executed, specifically including:
[0219] Based on the video stream information, determine the file ID identifier of the video stream that meets the request conditions;
[0220] Based on the file ID, determine the data node information to which the storage space corresponding to the file ID belongs;
[0221] The system returns data node information to the client, enabling the client to connect to the data node based on the returned data node information and read the video stream from the storage space corresponding to the data node information.
[0222] The following specific examples illustrate this, see appendix. Figure 14 As shown, attached Figure 14 The flowchart of a video stream query operation method provided in this embodiment is as follows: Flow B is as follows.
[0223] S1401: Based on the video stream information, determine the file ID identifier of the video stream that meets the request conditions.
[0224] The request conditions include the identification information of the video stream for which the operation is requested, and / or the time information of the video stream for which the operation is requested. Therefore, based on the request conditions, the video stream information corresponding to the file ID identifier in memory is matched to determine the file ID identifier of the video stream that meets the request conditions. It should be noted that there may be more than one file ID identifier of the video stream that meets the request conditions.
[0225] S1402: Determine the data node information to which the storage space corresponding to the file ID belongs based on the file ID identifier.
[0226] Once the file ID is determined, the data node information of the storage space corresponding to the file ID can be determined. If there are multiple file IDs, the data node information of the storage space corresponding to each of the multiple file IDs can be determined.
[0227] S1403: Returns data node information to the client, enabling the client to connect to the data node based on the returned data node information and read the video stream from the storage space corresponding to the data node information.
[0228] The system returns data node information to the client. If the data node information that meets the request conditions is not unique, it returns multiple data nodes to the client. The client connects to the data node based on the returned data node information and reads the video stream from the storage space corresponding to the data node information.
[0229] It's important to note that since the video streams stored in the storage space are for a specific time period, if the query condition is a video stream that matches a specified time period, it cannot be guaranteed that the requested time period will result in a complete video stream. There may be issues with streams spanning multiple video streams or only a segment within a single video stream. Therefore, the video streams corresponding to the data node information returned by the server to the client only need to ensure that the time period requested by the client falls within the range of all time periods of the video streams corresponding to all the returned data node information. After the client connects to the data node based on the returned data node information and reads the video stream from the storage space corresponding to the data node information, it can perform appropriate processing based on the actual situation. The client can use all the video streams corresponding to the data node information as the query result, or it can further determine the specific start and end positions of the requested video stream based on the timestamp information in the video stream as the query result.
[0230] Optionally, as one embodiment, it further includes: receiving a video stream service stop instruction, and when it is determined that there is an unfinished operation, stopping receiving operation request messages sent by the client and continuing to execute the unfinished operation.
[0231] When a video streaming service stop command is received, the server determines whether there are any unfinished operations. If so, it stops receiving operation request messages from the client after the video streaming service stop command, or stops responding to operation request messages from the client and continues to execute the unfinished operations until the task is completed.
[0232] To determine whether there are any unfinished tasks, one can check if there are any unfinished thread pool tasks or create a task set. For those skilled in the art, there are many ways to determine whether there are any unfinished tasks, which will not be listed here.
[0233] If an unfinished task continues to be executed, such as when a client requests to query a video segment, and the server receives a video streaming service stop instruction before the server has finished processing the request, the server will not immediately stop the service. Instead, it will continue to process the unfinished operations before the service was stopped, return the required content to the client, and stop the server service once it is determined that there are no unfinished operations.
[0234] Optionally, as one embodiment, it also includes a task set, used to store the operation being executed as a task in the task set, and to delete the task from the task set after the task is executed;
[0235] It has been determined that there are operations that have not been completed, specifically including:
[0236] Ensure the task set is not empty.
[0237] The following describes specific embodiments, see appendix. Figure 15 As shown.
[0238] S1501: Receive video streaming service stop command.
[0239] The service stop command can be issued by a network server with administrative privileges or by a metadata server; there are no restrictions here.
[0240] S1502: Determine if the task set is empty.
[0241] If yes, proceed to step S1503; otherwise, proceed to step S1504.
[0242] The task set is used to store ongoing operations as tasks, and to remove tasks from the task set after they are completed. In other words, if there are still tasks in the task set, it means that there are tasks that have not been completed.
[0243] S1503: Stop video streaming service.
[0244] There are no unfinished tasks; stop the video streaming service.
[0245] S1504: Stop receiving operation request messages from the client and continue executing unfinished operations.
[0246] If there are unfinished tasks, stop receiving operation request messages from the client, continue executing the unfinished operations, and check at intervals whether the task set is empty. If it is, stop the video streaming service; otherwise, continue executing the unfinished operations until the task set is empty, at which point the video streaming service is stopped.
[0247] It can also be attached Figure 16 As shown.
[0248] Steps S1601-S1603 are the same as steps S1501-S1503 in the previous embodiments, and can be referred to the previous embodiments. They will not be repeated here, only the differences from the previous embodiments will be described.
[0249] S1604: Stop receiving operation request messages from the client and continue executing unfinished operations.
[0250] If the task set is not empty, it means that there are tasks that have not been completed. Therefore, stop receiving operation request messages from the client and continue to execute the unfinished operations.
[0251] S1605: Determine that the last task in the task set has been completed.
[0252] When the last task in the task set is completed, it means that the task set is empty. Therefore, continue to step S1603 and stop the video streaming service.
[0253] The difference between this embodiment and the previous embodiment is that when the last task in the task set is completed, the server will be notified and the server can immediately stop the video streaming service. With this technical solution, the server does not need to check whether the task set is empty at intervals. Therefore, it can save the server time and resources for querying the task set. Moreover, when the last task is completed, the server is notified and can immediately end the video streaming service to release the resources occupied by the video streaming service.
[0254] Optionally, embodiments of the present invention also provide a video stream client upload method, including:
[0255] Receive a video stream write request from the video stream access terminal. The write request carries source identifier information that represents the source of the video stream.
[0256] Send a request to the server to add a new video stream, and the request must include at least the source identifier information;
[0257] It receives data node information from the server, connects to the data node based on the data node information, and writes the video stream to the storage space corresponding to the data node information.
[0258] The following describes specific embodiments; see [link to specific examples]. Figure 17 .
[0259] S1701: Receive a video stream write request from the video stream access terminal. The write request carries source identifier information that represents the source of the video stream.
[0260] When the video stream access terminal is working, if the video stream is not stored in the cloud storage space, it will send a video stream write request to the client. The write request will at least carry source identifier information that represents the source of the video stream. Optionally, the request may also carry the timestamp information of the video stream access terminal.
[0261] S1702: Send a request to the server for a new video stream, the request must include at least the source identifier information.
[0262] After receiving a video stream write request from the video stream access terminal, the client immediately sends a new video stream request to the server to apply for cloud storage space. The request must include at least the source identifier information. Optionally, if the write request from the video stream access terminal also includes the timestamp information of the video stream access terminal, the client can also include the timestamp information of the video stream access terminal when sending the request to the server. Optionally, if the request does not include timestamp information, it can also include the timestamp information of the client when sending the new video stream request to the server. Of course, it can also only include the source identifier information.
[0263] S1703: Receives the file ID identifier and data node information sent by the server, connects to the data node according to the data node information, names the video stream with the file ID identifier, and writes it to the storage space corresponding to the data node information.
[0264] Typically, when a server receives a new video stream request from a client, it immediately allocates storage space to store the video stream file. Therefore, if the client does not carry timestamp information, the server determines the timestamp based on the time of the received new video stream request and generates a file ID identifier based on the source identifier information and the timestamp information. Optionally, the server also carries the video stream's file ID identifier when sending data node information. The client connects to the data node based on the data node information, names the current video stream file with the file ID identifier, and writes the video stream to the storage space corresponding to the data node information.
[0265] The storage space can be a pre-agreed capacity for storing video stream files of a specified size or a video stream file of a specified duration. When the storage space is full, the client will immediately send another request to the server to add a new video stream to obtain new storage space. Therefore, the video stream access end does not need to determine whether the newly generated video stream has been written to the cloud storage space and send another video stream write request to the client. Instead, the client determines and controls this, and immediately requests new storage space when it is full. This ensures the continuity of the video stream time, reduces the interaction between the client and the video stream access end, reduces network transmission pressure, and saves resource consumption.
[0266] Optionally, as one embodiment, this invention also provides a server 1800, see appendix. Figure 18 As shown, it includes:
[0267] The receiving module 1801 is used to receive a new video stream request sent by the client. The request carries at least source identifier information that represents the source of the video stream.
[0268] The generation module 1802 is used to generate a file ID identifier for the video stream. The file ID identifier for the video stream includes at least source identifier information and timestamp information. The timestamp information is converted based on the time when the request for a new video stream is received, or it is carried by the client when sending the request for a new video stream.
[0269] The allocation module 1803 is used to allocate storage space corresponding to the file ID identifier of the video stream, and return the file ID identifier and the data node information to which the storage space belongs to the client, so that the client can connect to the corresponding data node according to the data node information and write the video stream into the storage space named with the file ID identifier.
[0270] Optionally, as one embodiment, the server of this embodiment of the invention further includes: a processing module, see appendix. Figure 19 As shown.
[0271] Appendix Figure 19The functions of 1901-1903 are the same as those of 1801-1803 in the above embodiments, and will not be described again here. Only the differences from the above embodiments will be described here.
[0272] Compared with the above embodiments, this embodiment adds a processing module 1904, which is used to receive an operation request message sent by the client, the operation request message carrying the requested operation type and request conditions; determine the file ID identifier of the video stream that meets the request conditions; execute the corresponding operation method according to the requested operation type and the file ID identifier that meets the request conditions; and return the result of the operation method execution to the client.
[0273] The request conditions include the identification information of the video stream for which the operation is requested, and / or the time information of the video stream for which the operation is requested, and / or the storage space information of the video stream for which the operation is requested, or the data node information of the storage space of the video stream.
[0274] This invention also provides a video stream processing system 2000, see attached document. Figure 20 As shown, it includes: cloud server 2001 and cloud storage space 2002;
[0275] To better explain this example, this embodiment also describes the video stream access terminal 2003 and the client 2004.
[0276] Cloud server 2001 is used to generate a file ID identifier for the video stream and allocate cloud storage space 2002 according to the new video stream request sent by client 2004, and return the file ID identifier and the data node information to which the cloud storage space 2002 belongs to client 2004. The file ID identifier of the video stream is used to identify the corresponding video stream information. It is also used to receive operation request messages sent by client 2004, execute the corresponding operation method according to the operation request message, and return the result of the operation method execution to client 2004.
[0277] Client 2004 is used to request cloud storage space 2002 from cloud server 2001 to store video streams based on new video stream requests sent by video stream access terminal 2003; it is also used to name the video stream sent by video stream access terminal 2003 with the file ID identifier and data node information sent by cloud server 2001, and write it into the cloud storage space 2002 corresponding to the data node.
[0278] The video stream access terminal 2003 is used to access the video input device, transmit the video stream captured by the video stream access terminal 2003 to the client 2004, and send a new video stream request to the client 2004;
[0279] Cloud storage space 2002 is used to store the video stream written by client 2004.
[0280] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0281] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0282] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0283] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0284] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A video stream processing method, characterized in that, The method includes: Receive a new video stream request from the client, wherein the request carries at least source identifier information representing the source of the video stream; The file ID identifier for generating the video stream includes at least the source identifier information and timestamp information. The timestamp information is converted based on the time when the request for the new video stream is received, or it is carried by the client when sending the request for the new video stream. Allocate storage space corresponding to the file ID identifier of the video stream, and return the data node information to which the file ID identifier and the storage space belong to the client, so that the client can connect to the corresponding data node according to the data node information, name the video stream with the file ID identifier, and write the video stream into the storage space; The method further includes: The system receives an operation request message from a client requesting the deletion of a video stream. Based on the video stream information, it determines the file ID of the video stream that meets the request conditions carried in the operation request message. Based on the determined file ID, it determines the storage space information corresponding to the file ID. The system deletes the video stream from the storage space, causing the storage identifier of the storage space to change to an unallocated state. The storage identifier is an identifier used to characterize whether the storage space allows data to be stored. And / or, The system receives an operation request message from a client requesting to query a saved video stream. Based on the video stream information, it determines the file ID of the video stream that meets the request conditions carried in the operation request message. Based on the file ID, it determines the data node information to which the storage space corresponding to the file ID belongs. It then returns the data node information to the client, enabling the client to connect to the data node based on the returned data node information and read the video stream from the storage space corresponding to the data node information. And / or, The system receives an operation request message from the client requesting a change in the storage location of the video stream. Based on the request conditions carried in the operation request message, it determines the first storage space where the video stream needs to be moved out and the corresponding file ID identifier; it determines the second storage space where the video stream needs to be moved in; it moves the video stream in the first storage space to the second storage space; and it updates the storage space and data node information of the video stream corresponding to the file ID identifier to the second storage space and the data node information to which the second storage space belongs. And / or, The system receives an operation request message from a client requesting a change in the storage location of a video stream. Based on the video stream information, it determines the file ID identifier of the video stream that needs to be transferred out, meeting the request conditions carried in the operation request message. Based on the file ID identifier, it determines the first storage space where the video stream corresponding to the file ID identifier is stored. It determines the second storage space where the video stream needs to be transferred into and the data node information to which the second storage space belongs. It then transfers the corresponding video stream in the first storage space to the second storage space and updates the storage space and data node information of the video stream corresponding to the file ID identifier to the second storage space and the data node information to which the second storage space belongs.
2. The method according to claim 1, characterized in that, The method further includes: After receiving the operation request message from the client and executing the corresponding operation: Return the result of the operation to the client. The request conditions include the identification information of the video stream for which the operation is requested, and / or the time information of the video stream for which the operation is requested, and / or the storage space information of the video stream for which the operation is requested or the data node information of the storage space of the video stream.
3. The method according to claim 1, characterized in that, The file ID identifier of the video stream also includes at least one of the following: information representing the capacity of the video stream and information representing the duration of the video stream.
4. The method according to claim 2, characterized in that, Also includes: Upon receiving a video streaming service stop command and determining that there are unfinished operations, the system stops receiving operation request messages from the client and continues to execute the unfinished operations.
5. The method according to claim 4, characterized in that, It also includes a task set, which is used to store the operation being executed as a task in the task set, and to delete the task from the task set after the task is executed; The determination that there are operations that have not been completed specifically includes: Determine that the set of tasks is not empty.
6. A video stream client upload method, characterized in that, include: Receive a video stream write request from the video stream access terminal, wherein the write request carries source identifier information representing the source of the video stream; Send a request to the server to add a new video stream, wherein the request carries at least the source identifier information; Receive the file ID identifier and data node information sent by the server, connect to the data node according to the data node information, name the video stream with the file ID identifier, and write it into the storage space corresponding to the data node information; The method further includes: Send an operation request message of request operation type "request to delete video stream" to the server; so that the server performs the following steps: determine the file ID identifier of the video stream that meets the request conditions carried in the operation request message based on the video stream information; determine the storage space information corresponding to the file ID identifier based on the determined file ID identifier; delete the video stream in the storage space, so that the storage identifier of the storage space is changed to an unallocated state, wherein the storage identifier is an identifier used to characterize whether the storage space allows data to be stored; And / or, The system sends an operation request message to the server, specifying the operation type as "Request to Query Saved Video Streams". The server then performs the following steps: based on the video stream information, it determines the file ID of the video stream that matches the request conditions carried in the operation request message; based on the file ID, it determines the data node information to which the storage space corresponding to the file ID belongs; and returns the data node information to the client, enabling the client to connect to the data node based on the returned data node information and read the video stream from the storage space corresponding to the data node information. And / or, Send an operation request message to the server requesting a change in the storage location of the video stream; so that the server performs the following steps: (1) Based on the request conditions carried in the operation request message, determine the first storage space and the corresponding file ID identifier of the video stream to be transferred out; determine the second storage space of the video stream to be transferred into; transfer the video stream in the first storage space to the second storage space; update the storage space and data node information of the video stream corresponding to the file ID identifier to the second storage space and the data node information to which the second storage space belongs; or, (2) Based on the video stream information, determine the file ID identifier of the video stream to be transferred out that meets the request conditions carried in the operation request message; based on the file ID identifier, determine the first storage space of the video stream corresponding to the file ID identifier; determine the second storage space of the video stream to be transferred into and the data node information to which the second storage space belongs; transfer the corresponding video stream in the first storage space to the second storage space; update the storage space and data node information of the video stream corresponding to the file ID identifier to the second storage space and the data node information to which the second storage space belongs.
7. A server, characterized in that, include: The receiving module is used to receive a new video stream request sent by the client, wherein the request carries at least source identifier information that represents the source of the video stream; The generation module is used to generate a file ID identifier for the video stream. The file ID identifier for the video stream includes at least the source identifier information and timestamp information. The timestamp information is converted according to the time when the request for the new video stream is received, or it is carried by the new video stream request sent by the client. The allocation module is used to allocate storage space corresponding to the file ID identifier of the video stream, and return the file ID and the data node information to which the storage space belongs to the client, so that the client can connect to the corresponding data node according to the data node information and write the video stream into the storage space named with the file ID identifier; Processing module, used for: The system receives an operation request message from a client requesting the deletion of a video stream. Based on the video stream information, it determines the file ID of the video stream that meets the request conditions carried in the operation request message. Based on the determined file ID, it determines the storage space information corresponding to the file ID. Delete the video stream from the storage space, so that the storage identifier of the storage space is changed to an unallocated state, wherein the storage identifier is an identifier used to characterize whether the storage space allows data to be stored; And / or, The system receives an operation request message from a client requesting to query a saved video stream. Based on the video stream information, it determines the file ID of the video stream that meets the request conditions carried in the operation request message. Based on the file ID, it determines the data node information to which the storage space corresponding to the file ID belongs. It then returns the data node information to the client, enabling the client to connect to the data node based on the returned data node information and read the video stream from the storage space corresponding to the data node information. And / or, The system receives an operation request message from the client requesting a change in the storage location of the video stream. Based on the request conditions carried in the operation request message, it determines the first storage space where the video stream needs to be moved out and the corresponding file ID identifier; it determines the second storage space where the video stream needs to be moved in; it moves the video stream in the first storage space to the second storage space; and it updates the storage space and data node information of the video stream corresponding to the file ID identifier to the second storage space and the data node information to which the second storage space belongs. And / or, The system receives an operation request message from a client requesting a change in the storage location of a video stream. Based on the video stream information, it determines the file ID identifier of the video stream that needs to be transferred out, meeting the request conditions carried in the operation request message. Based on the file ID identifier, it determines the first storage space where the video stream corresponding to the file ID identifier is stored. It determines the second storage space where the video stream needs to be transferred into and the data node information to which the second storage space belongs. It then transfers the corresponding video stream in the first storage space to the second storage space and updates the storage space and data node information of the video stream corresponding to the file ID identifier to the second storage space and the data node information to which the second storage space belongs.
8. The server according to claim 7, characterized in that, The processing module is further configured to: after receiving an operation request message from the client and executing the corresponding operation method, return the result of the operation method to the client; The request conditions include the identification information of the video stream for which the operation is requested, and / or the time information of the video stream for which the operation is requested, and / or the storage space information of the video stream for which the operation is requested or the data node information of the storage space of the video stream.
9. A video stream processing system, characterized in that, include: Cloud servers, cloud storage space; The cloud server is configured to generate a file ID identifier for the video stream and allocate cloud storage space according to the new video stream request sent by the client, and return the file ID identifier and the data node information to which the cloud storage space belongs to the client, wherein the file ID identifier of the video stream is used to represent the corresponding video stream information; it is also configured to receive an operation request message sent by the client, perform a corresponding operation method according to the operation request message, and return the result of the operation method execution to the client; the receiving of the operation request message sent by the client and the performing of the corresponding operation method according to the operation request message specifically includes: (1) receiving a request from the client whose operation type is a request to delete. The operation request message for the video stream, based on the video stream information, determines the file ID identifier of the video stream that meets the request conditions carried in the operation request message; based on the determined file ID identifier, determines the storage space information corresponding to the file ID identifier; deletes the video stream in the storage space, so that the storage identifier of the storage space is changed to an unallocated state, wherein the storage identifier is an identifier used to characterize whether the storage space allows data to be stored; and / or, (2) receives an operation request message from the client whose request operation type is to query a saved video stream, and determines the file ID of the video stream that meets the request conditions carried in the operation request message based on the video stream information. Identify; based on the file ID identifier, determine the data node information to which the storage space corresponding to the file ID ID belongs; return the data node information to the client, so that the client connects to the data node according to the returned data node information and reads the video stream in the storage space corresponding to the data node information; and / or, (3) receive the operation request message from the client requesting to change the storage location of the video stream, and determine the first storage space and the corresponding file ID identifier that need to be transferred out of the video stream according to the request conditions carried in the operation request message; determine the second storage space to be transferred into the video stream; transfer the video stream in the first storage space to the second storage space; update the The storage space and data node information of the video stream corresponding to the file ID identifier are the second storage space and the data node information to which the second storage space belongs; and / or, (4) receive an operation request message from the client requesting to change the storage location of the video stream, and determine the file ID identifier that needs to be transferred out of the video stream according to the video stream information and the request conditions carried in the operation request message; determine the first storage space where the video stream corresponding to the file ID identifier is stored according to the file ID identifier; determine the second storage space that needs to be transferred into the video stream and the data node information to which the second storage space belongs; transfer the video stream corresponding to the first storage space to the second storage space;Update the storage space and data node information of the video stream corresponding to the file ID to the second storage space and the data node information to which the second storage space belongs; The cloud storage space is used to store the video stream written by the client.
Citation Information
Patent Citations
File storage method and device
CN108984560A
Audio and video storage method and system, terminal and computer readable storage medium
CN112492345A