A short-term streaming media cache processing method, device, medium and electronic device
The cache server obtains and processes streaming media data in real time and generates corresponding cache service processes, which solves the problem of low efficiency in obtaining short-term streaming media data in AI application services, achieves fast response and efficient transmission, and reduces resource occupation and costs.
Patent Information
- Application Number
- CN202410578975.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-11
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-05-11
AI Technical Summary
In the AI application service scenario, the existing NVR is cumbersome and slow to obtain video data, and cannot meet the response and transmission needs of short-term streaming data, especially because the AI service requires short-term data that has just occurred, and NVR The data in it is a long video, and the encapsulation process is time-consuming and not suitable for the processing of short-term streaming media data.
Obtain streaming media data in real time through the cache server and store short-term streaming media cache data. Generate the corresponding streaming media cache service process according to the client's request type to perform data processing, including adding, modifying, deleting, video acquisition, and picture acquisition operations. Use The memory stores naked flow packets to improve response and transmission efficiency, and controls memory usage by setting a threshold range.
It achieves rapid response and efficient transmission of short-term streaming media data in AI application services, reduces resource occupation and costs, avoids dependence on external storage devices, and meets the storage needs of multi-channel short-term streaming media cache data.
Smart Images

Figure CN118158205B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of streaming media processing, and in particular to a short-term streaming media cache processing method, device, medium and electronic equipment. Background Art
[0002] NVR, or network video recorder, is the storage and forwarding part of the network video surveillance system. NVR works with video encoders or network cameras to complete the video recording, storage and forwarding functions. At present, in the scenario of AI application services, if a time is detected, it is necessary to immediately obtain the video data or image data near the time. Since the existing video data or image data is usually obtained through NVR, the AI application service itself does not provide video functions. Through the retrieval function of NVR, searching and saving video data, downloading and intercepting the required video is not only cumbersome, but also has slow transmission and response speeds. Since the scenario of AI application services requires short-term streaming media data that has just occurred, and the data in NVR are all downloaded and packaged videos, and they are long videos, the packaging process itself consumes a lot of time, and the scenario of AI application services only requires short-term streaming media data. If it still relies on the existing method of searching and downloading first and then intercepting and processing, the user experience is poor.
[0003] Therefore, there is an urgent need for a short-term streaming media cache processing method or device that can be applicable to the response and transmission of short-term streaming media data. Summary of the invention
[0004] In view of the above problems, the present invention is proposed to provide a short-term streaming media cache processing method, device, medium and electronic device that overcome the above problems or at least partially solve the above problems.
[0005] Other features and advantages of the present invention will become apparent from the following detailed description, or may be learned in part by practice of the present invention.
[0006] According to a first aspect of an embodiment of the present invention, a short-term streaming media cache processing method is provided, the short-term streaming media cache processing method comprising: a cache server acquires streaming media data in real time, and stores short-term streaming media cache data in the streaming media data, the short-term streaming media cache data being video cache data with a duration within a first threshold range;
[0007] Receive a streaming media file processing request sent by a client, determine the type of the obtained streaming media file processing request, and generate a corresponding streaming media cache service process according to the type of the streaming media file processing request;
[0008] The streaming media file request message is parsed, and the corresponding streaming media cache service process is executed according to the parsing result, and the streaming media cache service process is used to perform corresponding cache data processing operations on the short-term streaming media cache data.
[0009] In some embodiments of the present invention, the receiving a streaming media file processing request sent by a client and determining the type of the obtained streaming media file processing request includes:
[0010] Based on the RESTful request interface, it receives the streaming media file processing request sent by the client;
[0011] The type of the obtained streaming media file processing request is determined, where the type of the streaming media file processing request includes a request to add or modify a video stream, a request to delete a video stream, a request to obtain a video stream, and a request to obtain a picture.
[0012] In some embodiments of the present invention, generating a corresponding streaming media cache service process according to the type of the streaming media file processing request includes:
[0013] When the type of the streaming media file processing request is a request for adding or modifying a video stream, generating a first streaming media cache service process for performing a new cache or modification operation on the short-term streaming media cache data;
[0014] If there is no first streaming media cache service process currently generated, then generating a first streaming media cache service process, and allocating a video stream ID for distinguishing and verifying the short-term streaming media cache data;
[0015] If the first streaming media cache service process has been generated, the current first streaming media cache service process is paused, and a new first streaming media cache service process is generated.
[0016] In some embodiments of the present invention, after the first streaming media cache service process, when the type of the streaming media file processing request is a video stream deletion request, a second streaming media cache service process is generated for deleting the short-term streaming media cache data.
[0017] In some embodiments of the present invention, after the first streaming media cache service process, when the type of the streaming media file processing request is a video stream acquisition request, a third streaming media cache service process is generated for performing video capture and packaging operations on the short-term streaming media cache data.
[0018] In some embodiments of the present invention, after the first streaming media cache service process, when the type of the streaming media file processing request is a picture acquisition request, a fourth streaming media cache service process is generated for performing a picture frame capture operation on the short-term streaming media cache data.
[0019] In some embodiments of the present invention, the method includes: determining the first threshold range according to the memory size of the cache server.
[0020] According to a second aspect of an embodiment of the present invention, a short-term streaming media cache processing device is provided, and the short-term streaming media cache processing device includes:
[0021] A data cache module, used for acquiring streaming media data in real time through a cache server, and storing short-term streaming media cache data in the streaming media data, wherein the short-term streaming media cache data is video cache data with a duration within a first threshold range;
[0022] A process generation module, used to receive a streaming media file processing request sent by a client, determine the type of the obtained streaming media file processing request, and generate a corresponding streaming media cache service process according to the type of the streaming media file processing request;
[0023] The task execution module is used to parse the streaming media file request message and execute the corresponding streaming media cache service process according to the parsing result. The streaming media cache service process is used to perform corresponding cache data processing operations on the short-term streaming media cache data.
[0024] According to a third aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which computer program instructions are stored. The computer program instructions are loaded and executed by a processor to implement the operations performed by any of the methods described above.
[0025] According to a fourth aspect of an embodiment of the present invention, there is provided an electronic device, comprising a processor and a memory, wherein the memory stores computer program instructions that can be executed by the processor, and when the processor executes the computer program instructions, it implements instructions of any of the methods described above.
[0026] The technical solution provided in the embodiments of the present invention has at least the following technical effects or advantages:
[0027] An embodiment of the present invention provides a short-term streaming media cache processing method and device. The short-term streaming media cache processing method stores streaming media data through the memory of a cache server, and the streaming media data is a raw stream data packet. When video or image data needs to be intercepted, it is packaged and transmitted, with better response and transmission efficiency. By setting the first threshold range, the memory occupancy state of the cache server can be controlled, which is suitable for short-term streaming media cache data. At this time, the storage requirements of multi-channel short-term streaming media cache data can be met through the memory of the cache server, and there is no need to use an external storage device, which not only reduces resource occupation but also reduces costs.
[0028] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0030] Figure 1 A schematic diagram of a flow chart of a short-term streaming media cache processing method provided by an embodiment of the present invention;
[0031] Figure 2 A schematic diagram of the principle structure of a short-term streaming media cache processing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0032] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings.
[0033] Various structural schematic diagrams according to embodiments of the present disclosure are shown in the accompanying drawings. These figures are not drawn to scale, and some details are magnified and some details may be omitted for the purpose of clear expression. The shapes of various regions and layers shown in the figures and the relative sizes and positional relationships therebetween are only exemplary, and may deviate in practice due to manufacturing tolerances or technical limitations, and those skilled in the art may further design regions / layers with different shapes, sizes, and relative positions according to actual needs.
[0034] In the context of the present disclosure, when a layer / element is referred to as being "on" another layer / element, the layer / element may be directly on the other layer / element, or there may be an intervening layer / element therebetween. Additionally, if a layer / element is "on" another layer / element in one orientation, the layer / element may be "below" the other layer / element when the orientation is reversed. In the context of the present disclosure, similar or identical components may be denoted by the same or similar reference numerals.
[0035] In order to better understand the above-mentioned technical scheme, the above-mentioned technical scheme will be described in detail below in combination with specific implementation methods. It should be understood that the embodiments of the present disclosure and the specific features in the embodiments are detailed descriptions of the technical scheme of the present invention, rather than limitations on the technical scheme of the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.
[0036] Figure 1 FIG. 1 is a flow chart of a short-term streaming media cache processing method provided by an embodiment of the present invention. Figure 1 As shown, the short-term streaming media cache processing method includes the following steps:
[0037] S1. The cache server obtains streaming media data in real time, and stores short-term streaming media cache data in the streaming media data, wherein the short-term streaming media cache data is video cache data with a duration within a first threshold range;
[0038] S2, receiving a streaming media file processing request sent by a client, determining the type of the obtained streaming media file processing request, and generating a corresponding streaming media cache service process according to the type of the streaming media file processing request;
[0039] S3. Parse the streaming media file request message, and execute the corresponding streaming media cache service process according to the parsing result, wherein the streaming media cache service process is used to perform corresponding cache data processing operations on the short-term streaming media cache data.
[0040] Regarding step S1, specifically, in an embodiment of the present invention, the client is a PC or a control host, etc., and the client sends a corresponding streaming media file processing request to the cache server through a Restful request interface based on scene requirements. The cache server obtains streaming media data in real time based on a video data acquisition component (such as a camera or a monitoring device, etc.), and in order to improve the rapid response to short-term video stream processing operations, the cache server stores streaming media data based on memory, and has better response and transmission efficiency. At the same time, the short-term streaming media cache data in the streaming media data, the short-term streaming media cache data is video cache data with a duration within a first threshold range, and the video cache data with a duration exceeding the first threshold range is discarded, which can reduce the memory pressure on the cache server.
[0041] An embodiment of the present invention determines the first threshold range according to the memory size of the cache server. For example, when the memory size of the cache server is 16G, the first threshold range can be set to a duration of 1 minute. For 2K resolution video cache data, about 600 videos can be cached at the same time, which has far exceeded the demand for the number of video cache channels of the video data acquisition component.
[0042] In other implementations of the present invention, other first threshold ranges may also be selected according to the memory size of the cache server, and the embodiment of the present invention has no limitation to this.
[0043] Regarding step S2, the embodiment of the present invention receives a streaming media file processing request sent by a client, and determines the type of the obtained streaming media file processing request includes:
[0044] Based on the RESTful request interface, a streaming media file processing request sent by a client is received; the type of the streaming media file processing request obtained is determined, and the types of the streaming media file processing request include adding and modifying video stream requests, deleting video stream requests, video stream acquisition requests, and picture acquisition requests.
[0045] The embodiment of the present invention generates a corresponding streaming media cache service process according to the type of the streaming media file processing request, specifically including:
[0046] When the type of the streaming media file processing request is a request to add or modify a video stream, a first streaming media cache service process is generated for adding a cache or modifying the short-term streaming media cache data; if the first streaming media cache service process has not been generated currently, a first streaming media cache service process is generated, and a video stream ID for distinguishing and verifying the short-term streaming media cache data is assigned; if the first streaming media cache service process has been generated currently, the current first streaming media cache service process is paused, and a newly generated first streaming media cache service process is generated.
[0047] Specifically, each time a request for adding or modifying a video stream is received, the embodiment of the present invention will generate a corresponding first streaming media cache service process, and assign a video stream ID for distinguishing and verifying the short-term streaming media cache data. If the first streaming media cache service process has not been generated, it can be considered that there is no subsequent operation that needs to be performed, and the first streaming media cache service process will be generated immediately, and a video stream ID for distinguishing and verifying the short-term streaming media cache data will be assigned. If the first streaming media cache service process has been generated, it is necessary to first pause the current first streaming media cache service process, and then start and generate a new first streaming media cache service process to serve the new short-term streaming media cache data and assign it a corresponding video stream ID. In the embodiment of the present invention, each first streaming media cache service process corresponds to one short-term streaming media cache data.
[0048] In the embodiment of the present invention, after the first streaming media cache service process, when the type of the streaming media file processing request is a video stream deletion request, a second streaming media cache service process is generated for deleting the short-term streaming media cache data;
[0049] If it is necessary to delete the short-term streaming cache data, for example, the user believes that the memory usage of the cache server is too large, or that part of the acquired short-term streaming cache data is not needed, a video stream deletion request can be sent through the client. The video stream deletion request includes the specified video stream ID, and a second streaming cache service process is generated to delete the short-term streaming cache data corresponding to the specified video stream ID, and at the same time, the first streaming cache service process corresponding to the specified video stream ID is terminated.
[0050] In the embodiment of the present invention, after the first streaming media cache service process, when the type of the streaming media file processing request is a video stream acquisition request, a third streaming media cache service process is generated for performing video interception and packaging operations on the short-term streaming media cache data;
[0051] If it is necessary to obtain the corresponding video data, a video stream acquisition request can be sent through the client. The video stream acquisition request includes the specified video stream ID, duration, and video start time node or video end time node. The embodiment of the present invention generates the third streaming media cache service process, and performs video interception and packaging operations on the short-term streaming media cache data according to the video stream acquisition request. The video data after packaging can be in MP4 or other video formats for transmission to the client for reading and playback.
[0052] It should be noted that, in some embodiments, there may be a situation where the duration and the video start time node and the video end time node are specified at the same time. If the time interval between the video start time node and the video end time node is different from the specified duration, the longer one is selected as the selected duration. For example, if the time interval between the video start time node and the video end time node is 45s, and the specified duration is 30s, 45s is selected as the selected duration.
[0053] Of course, it should be noted that, in some implementations, if the above-mentioned conflict exists, the present invention can also add a secondary confirmation interaction process to determine the selected direction through a secondary command from the client, and the present invention is not limited to this.
[0054] In the embodiment of the present invention, after the first streaming media cache service process, when the type of the streaming media file processing request is a picture acquisition request, a fourth streaming media cache service process is generated for performing a picture frame interception operation on the short-term streaming media cache data.
[0055] For example, if the user only needs to view a picture at a specified time point, a picture acquisition request is sent through the client, and the picture acquisition request includes a specified video stream ID and a time interception node. The embodiment of the present invention generates a fourth streaming media cache service process according to the picture acquisition request, and performs a picture frame interception operation on the short-term streaming media cache data.
[0056] Compared with the prior art, the short-term streaming media caching method described in the embodiment of the present invention has the following advantages:
[0057] 1. The streaming media data is stored in the memory of the cache server, and the streaming media data is a raw stream data packet. When the video or picture data needs to be intercepted, it is packaged and transmitted, which has better response and transmission efficiency;
[0058] 2. By setting the first threshold range, the memory occupancy status of the cache server can be controlled, which is suitable for short-term streaming media cache data. At this time, the storage requirements of short-term streaming media cache data of multiple channels can be met by the memory of the cache server, and there is no need to use an external storage device, which not only reduces resource occupancy but also reduces costs.
[0059] Based on the above embodiment, as the above Figure 1 The present invention provides an embodiment of a short-term streaming media cache processing device, and the device embodiment is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices, see Figure 2 As shown, the short-term streaming media cache processing device includes:
[0060] The data cache module 100 is used to obtain streaming media data in real time through a cache server and store short-term streaming media cache data in the streaming media data, wherein the short-term streaming media cache data is video cache data with a duration within a first threshold range;
[0061] The process generation module 200 is used to receive a streaming media file processing request sent by a client, determine the type of the obtained streaming media file processing request, and generate a corresponding streaming media cache service process according to the type of the streaming media file processing request;
[0062] The task execution module 300 is used to parse the streaming media file request message and execute the corresponding streaming media cache service process according to the parsing result. The streaming media cache service process is used to perform corresponding cache data processing operations on the short-term streaming media cache data.
[0063] The short-term streaming media cache processing device described in the embodiment of the present invention can execute the short-term streaming media cache processing method provided in the above embodiment. The short-term streaming media cache processing device has the corresponding functional steps and beneficial effects of the short-term streaming media cache processing method described in the above embodiment. Please refer to the embodiment of the above short-term streaming media cache processing method for details. The embodiment of the present invention will not be repeated here.
[0064] The embodiment of the present invention also provides an electronic device, which may include a processor and a memory, wherein the processor and the memory may be connected via a bus or other means. The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components and other chips, or a combination of the above-mentioned types of chips. The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the short-term streaming media caching processing method in the embodiment of the present invention. The processor executes various functional applications and data processing of the processor by running the non-transient software programs, instructions and modules stored in the memory, that is, the short-term streaming media caching processing method in the above method embodiment is implemented.
[0065] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. The one or more modules are stored in the memory, and when executed by the processor, the short-term streaming media cache processing method in the above-mentioned method embodiment is executed. The specific details of the above-mentioned electronic device can be understood by corresponding to the corresponding descriptions and effects in the above-mentioned method embodiment, and will not be repeated here. Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and the program, when executed, may include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk drive (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memory.
[0066] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0067] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those expressly recited in each claim. Rather, as reflected in the claims, inventive aspects lie in less than all of the features of the individual embodiments previously disclosed. Therefore, the claims that follow the detailed description are hereby expressly incorporated into the detailed description, with each claim itself serving as a separate embodiment of the present invention.
[0068] It should be noted that the above-mentioned embodiments illustrate rather than limit the invention and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims.
Claims
1. A short-term streaming media cache processing method, applied to AI application services, characterized in that: The short-term streaming media cache processing method comprises: The cache server acquires streaming media data in real time based on the video data acquisition component, the streaming media data is a raw streaming data packet, and stores short-term streaming media cache data in the streaming media data, the short-term streaming media cache data is video cache data with a duration within a first threshold range, the raw streaming data packet is stored in the memory of the cache server, and the first threshold range is 1 minute; Receive a streaming media file processing request sent by a client, determine the type of the streaming media file processing request obtained, the type of the streaming media file processing request includes a request to add or modify a video stream, a request to delete a video stream, a request to obtain a video stream, and a request to obtain a picture, and generate a corresponding streaming media cache service process according to the type of the streaming media file processing request; The streaming media file processing request is parsed, and the corresponding streaming media cache service process is executed according to the parsed result. The streaming media cache service process is used to perform corresponding cache data processing operations on the short-term streaming media cache data. When the type of the streaming media file processing request is a video stream acquisition request and a picture acquisition request, the raw stream data packet is encapsulated and fed back to the client.
2. The short-term streaming media cache processing method according to claim 1 is characterized in that: The receiving a streaming media file processing request sent by the client and determining the type of the obtained streaming media file processing request comprises: Based on the RESTful request interface, it receives the streaming media file processing request sent by the client; Determines the type of streaming file processing request obtained.
3. The short-term streaming media cache processing method according to claim 2 is characterized in that: Generating a corresponding streaming media cache service process according to the type of the streaming media file processing request includes: When the type of the streaming media file processing request is a request for adding or modifying a video stream, generating a first streaming media cache service process for performing a new cache or modification operation on the short-term streaming media cache data; If there is no first streaming media cache service process currently generated, then generating a first streaming media cache service process, and allocating a video stream ID for distinguishing and verifying the short-term streaming media cache data; If the first streaming media cache service process has been generated, the current first streaming media cache service process is paused, and a new first streaming media cache service process is generated.
4. The short-term streaming media cache processing method according to claim 3 is characterized in that: The method further includes: after the first streaming media cache service process, when the type of the streaming media file processing request is a video stream deletion request, generating a second streaming media cache service process for deleting the short-term streaming media cache data.
5. The short-term streaming media cache processing method according to claim 3 is characterized in that: The method further includes: after the first streaming media cache service process, when the type of the streaming media file processing request is a video stream acquisition request, generating a third streaming media cache service process for performing video interception and packaging operations on the short-term streaming media cache data.
6. The short-term streaming media cache processing method according to claim 3 is characterized in that: The method further includes: after the first streaming media cache service process, when the type of the streaming media file processing request is a picture acquisition request, generating a fourth streaming media cache service process for performing a picture frame interception operation on the short-term streaming media cache data.
7. The short-term streaming media cache processing method according to claim 1 is characterized in that: The method includes: determining the first threshold range according to the memory size of the cache server.
8. A short-term streaming media cache processing device, characterized in that: The short-term streaming media cache processing device comprises: A data cache module, used for acquiring streaming media data in real time through a cache server, and storing short-term streaming media cache data in the streaming media data, wherein the short-term streaming media cache data is video cache data with a duration within a first threshold range; A process generation module, used to receive a streaming media file processing request sent by a client, determine the type of the obtained streaming media file processing request, and generate a corresponding streaming media cache service process according to the type of the streaming media file processing request; The task execution module is used to parse the streaming media file processing request and execute the corresponding streaming media cache service process according to the parsing result. The streaming media cache service process is used to perform corresponding cache data processing operations on the short-term streaming media cache data.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which are loaded and executed by a processor to implement the operations performed by the method according to any one of claims 1 to 7.
10. An electronic device comprising a processor and a memory, characterized in that: The memory stores computer program instructions that can be executed by the processor, and when the processor executes the computer program instructions, the processor implements instructions of any one of the methods described in claims 1-7.
