CN114125493A - Distributed storage method, device and equipment for streaming media - Google Patents

Distributed storage method, device and equipment for streaming media Download PDF

Info

Publication number
CN114125493A
CN114125493A CN202111387482.7A CN202111387482A CN114125493A CN 114125493 A CN114125493 A CN 114125493A CN 202111387482 A CN202111387482 A CN 202111387482A CN 114125493 A CN114125493 A CN 114125493A
Authority
CN
China
Prior art keywords
streaming media
code stream
data
media data
frame
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111387482.7A
Other languages
Chinese (zh)
Other versions
CN114125493B (en
Inventor
陆家龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vtron Group Co Ltd
Original Assignee
Vtron Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Vtron Group Co Ltd filed Critical Vtron Group Co Ltd
Priority to CN202111387482.7A priority Critical patent/CN114125493B/en
Publication of CN114125493A publication Critical patent/CN114125493A/en
Application granted granted Critical
Publication of CN114125493B publication Critical patent/CN114125493B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/231Content storage operation, e.g. caching movies for short term storage, replicating data over plural servers, prioritizing data for deletion
    • H04N21/23103Content storage operation, e.g. caching movies for short term storage, replicating data over plural servers, prioritizing data for deletion using load balancing strategies, e.g. by placing or distributing content on different disks, different memories or different servers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/23418Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving operations for analysing video streams, e.g. detecting features or characteristics
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/643Communication protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

The invention discloses a distributed storage method, a device and equipment of streaming media, which are applied to a master control manager, wherein the master control manager is in communication connection with a storage server, the storage server comprises a plurality of distributed storage nodes, and the method comprises the following steps: acquiring initial streaming media data frame by frame; adding a corresponding timestamp to the initial streaming media data according to a transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data; performing code stream packaging and splicing on the intermediate streaming media data frame by frame to obtain spliced code stream data; and determining and storing the target storage node position of the spliced code stream data according to the residual storage space value and the load path number respectively corresponding to each distributed storage node, thereby ensuring that the transmission cost of the stream media data is lower and reducing the storage time.

Description

Distributed storage method, device and equipment for streaming media
Technical Field
The present invention relates to the field of streaming media storage technologies, and in particular, to a distributed storage method, apparatus, and device for streaming media.
Background
With the continuous development of storage technology, distributed storage has become a common storage mode. But there are still few distributed storage methods for streaming media in terms of storage objects.
In a traditional distributed storage mode, the object generally aims at is known in data size, data is split, and the split data is stored to different storage nodes through a storage algorithm; when reading, data stored in different storage nodes need to be extracted respectively and then spliced, and the spliced data are transmitted to a user side.
However, for the stored data in the form of streaming media, such as data in the aspects of live broadcast, security and the like, only an intercepted portion may be required to be viewed during reading, and the data needs to be completely spliced and then intercepted again by adopting the conventional distributed storage mode, which takes too much time, thereby increasing the transmission cost.
Disclosure of Invention
The invention provides a distributed storage method, a device and equipment for streaming media, which solve the technical problem that the transmission cost is increased due to excessive time spent in the prior art because storage data needs to be spliced and then intercepted and transmitted again.
The invention provides a distributed storage method of streaming media in a first aspect, which is applied to a master control manager, wherein the master control manager is in communication connection with a storage server, the storage server comprises a plurality of distributed storage nodes, and the method comprises the following steps:
acquiring initial streaming media data frame by frame;
adding a corresponding timestamp to the initial streaming media data according to a transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data;
performing code stream packaging and splicing on the intermediate streaming media data frame by frame to obtain spliced code stream data;
and determining and storing the target storage node position of the spliced code stream data according to the residual storage space value and the load path number respectively corresponding to each distributed storage node.
Optionally, the step of adding a corresponding timestamp to the initial streaming media data according to the transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data includes:
analyzing a transmission protocol corresponding to the initial streaming media data to obtain a transmission frame rate corresponding to the initial streaming media data of the current frame;
and adding a corresponding timestamp to the initial streaming media data according to the transmission frame rate to obtain intermediate streaming media data.
Optionally, the method further comprises:
calculating a timestamp difference value between a timestamp corresponding to the intermediate streaming media data of the last frame and a timestamp corresponding to the intermediate streaming media data of the current frame;
comparing the absolute value of the timestamp difference value with a preset difference threshold value;
and if the absolute value of the timestamp difference is larger than the difference threshold, adding a new timestamp to the initial streaming media data again according to the transmission frame rate to obtain new intermediate streaming media data.
Optionally, the step of determining and storing the target storage node position of the spliced code stream data according to the remaining storage space value and the load path number respectively corresponding to each distributed storage node includes:
performing data fragmentation on the spliced code stream data according to the residual storage space values respectively corresponding to the distributed storage nodes to obtain a plurality of fragmented code stream data and respectively corresponding time period information;
and determining and storing the target storage node position of the fragment code stream data based on the load path number corresponding to each distributed storage node.
Optionally, the step of performing data fragmentation on the spliced code stream data according to the remaining storage space values respectively corresponding to the distributed storage nodes to obtain a plurality of fragmented code stream data and respectively corresponding time period information includes:
comparing the residual storage space values respectively corresponding to the distributed storage nodes, and determining the minimum value as the minimum residual storage space value;
performing data fragmentation on the spliced code stream data according to a preset data fragmentation rule and the minimum remaining storage space value to obtain a plurality of fragmented code stream data;
calculating the ratio of the fragment capacity of the fragment code stream data to the byte length of each frame of spliced code stream data to obtain the number of storage frames corresponding to the fragment code stream data;
and calculating the sum of the storage frame numbers to obtain the time period information corresponding to the fragment code stream data.
Optionally, the step of determining and storing a target storage node position of the fragmented code stream data based on the load path number corresponding to each distributed storage node includes:
sequencing all the distributed storage nodes according to the load paths corresponding to the distributed storage nodes respectively, and determining the sequencing number of each distributed storage node;
determining and storing a target storage node position corresponding to the fragment code stream data based on a preset storage node calculation formula in combination with the sequencing number;
the calculation formula of the storage node is as follows:
Node=(lastNode+1)%nodeNum;
node is the sorting number corresponding to the position of the target storage Node, nodeNum is the total number of the current distributed storage nodes, and lastNode is the sorting number corresponding to the position of the last target storage Node.
Optionally, the method further comprises:
and respectively establishing association information between each time interval information and each target storage node position to obtain a time interval key value pair table.
Optionally, the method further comprises:
when a data acquisition request sent by a user side is received, analyzing the data acquisition request, and determining a corresponding data acquisition time interval;
retrieving the time interval key value pair table by adopting the data acquisition time interval, and determining a plurality of storage node positions to be returned and time interval information to be returned corresponding to the data acquisition time interval;
sequentially acquiring the fragment code stream data corresponding to the time period to be returned from each storage node position to be returned as target code stream data, and returning the target code stream data to the user side;
and when the return progress of the target code stream data exceeds a preset return threshold, parallelly returning the target code stream data in the next storage node to be returned.
The second aspect of the present invention provides a distributed storage apparatus for streaming media, which is applied to a master control manager, where the master control manager is communicatively connected to a storage server, where the storage server includes a plurality of distributed storage nodes, and the apparatus includes:
the streaming media data acquisition module is used for acquiring initial streaming media data frame by frame;
a timestamp adding module, configured to add a corresponding timestamp to the initial streaming media data according to a transmission protocol corresponding to the initial streaming media data, so as to obtain intermediate streaming media data;
the data packaging and splicing module is used for carrying out code stream packaging and splicing on the intermediate streaming media data frame by frame to obtain spliced code stream data;
and the node determining and storing module is used for determining and storing the target storage node position of the spliced code stream data according to the residual storage space value and the load path number respectively corresponding to each distributed storage node.
A third aspect of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program, when executed by the processor, causes the processor to execute the steps of the distributed storage method for streaming media according to any one of the first aspect of the present invention.
According to the technical scheme, the invention has the following advantages:
the method comprises the steps of obtaining initial streaming media data frame by frame, adding a corresponding timestamp to the initial streaming media data based on a transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data, and meanwhile, when generating a frame of intermediate streaming media data, performing code stream packaging on the frame of intermediate streaming media data and splicing the frame of intermediate streaming media data with the previous frame of intermediate streaming media data to obtain spliced code stream data; and finally, carrying out data fragmentation on spliced code stream data according to the residual storage space and the load path number respectively corresponding to each distributed storage node, and determining and storing the position of a target storage node. Therefore, the technical problem that in the prior art, due to the fact that the storage data need to be spliced and then intercepted again for transmission, too much time is spent to increase transmission cost is solved, and the storage time is reduced while the transmission cost is lower.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without inventive exercise.
Fig. 1 is a flowchart illustrating steps of a distributed storage method for streaming media according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating steps of a distributed storage method for streaming media according to a second embodiment of the present invention;
fig. 3 is a schematic flow chart of code stream encapsulation and data splicing according to an embodiment of the present invention;
fig. 4 is a flow chart of slicing and storing spliced code stream data according to an embodiment of the present invention;
fig. 5 is a flow chart of object code stream data return according to an embodiment of the present invention;
fig. 6 is a block diagram of a distributed storage apparatus for streaming media according to a third embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a distributed storage method, a distributed storage device and distributed storage equipment for streaming media, which are used for solving the technical problem that the transmission cost is increased due to excessive time consumption caused by the fact that storage data needs to be spliced and then intercepted and transmitted again in the prior art.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating a distributed storage method for streaming media according to an embodiment of the present invention.
The invention provides a distributed storage method of streaming media, which is applied to a main control manager, wherein the main control manager is in communication connection with a storage server, the storage server comprises a plurality of distributed storage nodes, and the method comprises the following steps:
step 101, acquiring initial streaming media data frame by frame;
the initial streaming media data refers to temporally continuous media data, such as audio, video, animation, multimedia, and the like, the content of which can be transmitted by using streaming technology information without conversion, and in the embodiment of the present invention, the initial streaming media data mainly includes video streaming data in H264/H265+ AAC format, and the like.
In the embodiment of the present invention, since the initial streaming media data is usually streamed, in order to ensure the display continuity of the subsequent streaming media data, the present device acquires the initial streaming media data frame by frame, and subsequently processes the initial streaming media data acquired by each frame.
102, adding a corresponding timestamp to the initial streaming media data according to a transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data;
in a specific implementation, the user terminal generally performs data acquisition such as playback recording, video skipping and dragging in time sequence when searching for streaming media data.
Therefore, after receiving a frame of initial streaming media data, a corresponding transmission protocol may be further acquired from the initial streaming media data to determine a frame rate corresponding to the initial streaming media data of the current frame, and a corresponding timestamp is added to the initial streaming media data of the current frame according to the frame rate, so as to obtain intermediate streaming media data.
103, performing code stream packaging and splicing on the intermediate streaming media data frame by frame to obtain spliced code stream data;
after the intermediate streaming media data is acquired, because the streaming media data is usually transmitted according to the format of H264/H265+ AAC, for the encoded data, if the encoded data is decoded and stored, the storage cost and the time cost are increased; if the video and audio data are stored separately, subsequent acquisition also requires splicing, which is also costly in terms of time.
Therefore, in the embodiment of the invention, the intermediate streaming media data can be subjected to code stream packaging frame by frame and spliced frame by frame to obtain spliced code stream data.
It should be noted that the code stream encapsulation refers to a process of generating code stream data by encapsulating a plurality of header files. For example, for H264, the following codestream (PS) encapsulation is performed: each IDR NALU typically includes NALUs such as SPS, PPS, etc. before it, so the NALUs of SPS, PPS, IDR are encapsulated into one PS packet, including PS header, and then PS system header, PS system map, PES header + h264raw data are added. So an IDR NALU PS packet is in the outside-in order: PSheader | PS system header | PS system Map | PES header | h264raw data. For the PS packets of other non-key frames, it is much simpler to add the PS header and PES header directly. The sequence is as follows: PS header | PES header | h264raw data. The above is for the case of video only, and it is also possible to pack Audio into PS packages. When there is audio data, it is sufficient to put the data plus a PES header into the video PES. The sequence is as follows: PS packet ═ PS header | pes (video) | pes (audio).
And step 104, determining and storing the target storage node position of the spliced code stream data according to the residual storage space and the load path number respectively corresponding to each distributed storage node.
The load path number refers to the number of data storage paths corresponding to each distributed storage node at the current time, for example, one storage path is 1 load, and 2 storage paths are 2 loads.
After the spliced code stream data is obtained, because a plurality of distributed storage nodes exist in the storage server, the remaining storage space of each distributed storage node may be different, and the stored data amount may also be different.
In order to balance the storage capacity of each distributed storage node and ensure the network bandwidth balance, the minimum residual storage space can be selected from the plurality of distributed storage nodes as a target storage node position according to the residual storage space corresponding to each distributed storage node and the respective load path number, the next target storage node position is further selected according to the load path number by combining the previous target storage node position and the current target storage node position, and then the spliced code stream data is stored to each target storage node.
In the embodiment of the invention, initial streaming media data are obtained frame by frame, corresponding timestamps are added to the initial streaming media data based on a transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data, and meanwhile, when one frame of intermediate streaming media data is generated, the frame of intermediate streaming media data is subjected to code stream packaging and is spliced with the previous frame of intermediate streaming media data to obtain spliced code stream data; and finally, carrying out data fragmentation on spliced code stream data according to the residual storage space and the load path number respectively corresponding to each distributed storage node, and determining and storing the position of a target storage node. Therefore, the technical problem that in the prior art, due to the fact that the storage data need to be spliced and then intercepted again for transmission, too much time is spent to increase transmission cost is solved, and the storage time is reduced while the transmission cost is lower.
Referring to fig. 2, fig. 2 is a flowchart illustrating a distributed storage method for streaming media according to a second embodiment of the present invention.
The invention provides a distributed storage method of streaming media, which is applied to a main control manager, wherein the main control manager is in communication connection with a storage server, the storage server comprises a plurality of distributed storage nodes, and the method comprises the following steps:
step 201, acquiring initial streaming media data frame by frame;
the initial streaming media data refers to temporally continuous media data, such as audio, video, animation, multimedia, and the like, the content of which can be transmitted by using streaming technology information without conversion, and in the embodiment of the present invention, the initial streaming media data mainly includes video streaming data in H264/H265+ AAC format, and the like.
In the embodiment of the present invention, since the initial streaming media data is usually streamed, in order to ensure the display continuity of the subsequent streaming media data, the present device acquires the initial streaming media data frame by frame, and subsequently processes the initial streaming media data acquired by each frame.
Step 202, adding a corresponding timestamp to the initial streaming media data according to a transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data;
optionally, step 202 may include the following sub-steps:
analyzing a transmission protocol corresponding to the initial streaming media data to obtain a transmission frame rate corresponding to the current frame of the initial streaming media data;
and adding a corresponding time stamp to the initial streaming media data according to the transmission frame rate to obtain intermediate streaming media data.
The transmission frame rate refers to the frequency (rate) at which bitmap images appear continuously on the display in units of frames. The term applies equally to film and video cameras, computer graphics and motion capture systems. The frame rate may also be referred to as a frame frequency and is expressed in hertz (Hz).
In the embodiment of the present invention, after the master controller receives a frame of initial streaming media data, the master controller may analyze a transmission protocol corresponding to the frame of initial streaming media data to extract a transmission frame rate corresponding to the initial streaming media data, and then add a corresponding timestamp to the initial streaming media data according to the transmission frame rate to obtain intermediate streaming media data.
Further, after performing step 202, the method may further include the following steps S11-S13:
s11, calculating the time stamp difference between the time stamp corresponding to the middle streaming media data of the last frame and the time stamp corresponding to the middle streaming media data of the current frame;
s12, comparing the absolute value of the timestamp difference value with a preset difference threshold value;
and S13, if the absolute value of the timestamp difference is larger than the difference threshold, adding a new timestamp to the initial streaming media data again according to the transmission frame rate to obtain new intermediate streaming media data.
When the intermediate streaming media data is obtained, due to different data protocols corresponding to different initial streaming media data frames in the same file, an error may be caused in adding the timestamp.
Therefore, a timestamp difference between a timestamp corresponding to the previous frame of intermediate streaming media data and a timestamp of the current frame of intermediate streaming media data can be further calculated, whether the timestamp difference is greater than a preset difference threshold value or not is compared, and if the timestamp difference is greater than the preset difference threshold value, a new timestamp can be added again according to the transmission frame rate to obtain new intermediate streaming media data; if not, the original intermediate stream media data is kept, and subsequent code stream packaging and data splicing are obtained.
It should be noted that after obtaining the new intermediate streaming media data, the process may further jump to step S11 to check whether the timestamp of the intermediate streaming media data is correct.
Step 203, performing code stream packaging and splicing on the intermediate streaming media data frame by frame to obtain spliced code stream data;
after the intermediate streaming media data is acquired, because the streaming media data is usually transmitted according to the format of H264/H265+ AAC, for the encoded data, if the encoded data is decoded and stored, the storage cost and the time cost are increased; if the video and audio data are stored separately, subsequent acquisition also requires splicing, which is also costly in terms of time.
Therefore, in the embodiment of the invention, the intermediate streaming media data can be subjected to code stream packaging frame by frame and spliced frame by frame to obtain spliced code stream data.
It should be noted that the code stream encapsulation refers to a process of generating code stream data by encapsulating a plurality of header files. For example, for H264, the following codestream (PS) encapsulation is performed: each IDR NALU typically includes NALUs such as SPS, PPS, etc. before it, so the NALUs of SPS, PPS, IDR are encapsulated into one PS packet, including PS header, and then PS system header, PS system map, PES header + h264raw data are added. So an IDR NALU PS packet is in the outside-in order: PSheader | PS system header | PS system Map | PES header | h264raw data. For the PS packets of other non-key frames, it is much simpler to add the PS header and PES header directly. The sequence is as follows: PS header | PES header | h264raw data. The above is for the case of video only, and it is also possible to pack Audio into PS packages. When there is audio data, it is sufficient to put the data plus a PES header into the video PES. The sequence is as follows: PS packet ═ PS header | pes (video) | pes (audio).
Referring to fig. 3, fig. 3 is a flow chart illustrating code stream encapsulation and data splicing according to an embodiment of the present invention.
In the embodiment of the present invention, taking the initial streaming media data in the storage pool H264+ AAC as an example, after processing to obtain a frame of intermediate streaming media data, PS header data of a PS stream may be encapsulated for the intermediate streaming media data, then PES/PSM header data may be encapsulated for the H264/AAC, and after obtaining an encapsulated PS data packet and a PS header, the current frame of intermediate streaming media data and the previous frame of intermediate streaming media data are spliced in a manner of splicing the PS header and the PS data packet, so as to obtain a spliced code stream data.
Step 204, performing data fragmentation on the spliced code stream data according to the residual storage spaces corresponding to the distributed storage nodes respectively to obtain a plurality of fragmented code stream data and corresponding time period information respectively;
optionally, step 204 may include the following sub-steps:
comparing the residual storage spaces corresponding to the distributed storage nodes respectively, and determining the minimum value as the minimum residual storage space;
performing data fragmentation on spliced code stream data according to a preset data fragmentation rule and the minimum residual storage space to obtain a plurality of fragmented code stream data;
calculating the ratio of the fragment capacity of the fragment code stream data to the byte length of each frame of spliced code stream data to obtain the number of storage frames corresponding to the fragment code stream data;
and calculating the sum of the storage frame numbers to obtain the time period information corresponding to the fragment code stream data.
In the embodiment of the invention, the distributed storage nodes upload the residual storage spaces to the master control manager periodically, and after the master control manager receives each residual storage space at the current moment, the minimum value is selected as the minimum residual storage space by comparing the residual storage spaces respectively corresponding to each distributed storage node; and carrying out data slicing on the spliced code stream data according to the minimum residual storage space and a preset data slicing rule to obtain a plurality of sliced code stream data.
For example, the minimum remaining storage space is m, the data fragmentation rule specifies that the fragmentation capacity is m/2, and at this time, the spliced code stream data can be subjected to data fragmentation according to the fragmentation capacity of m/2, so as to obtain a plurality of m/2 fragmented code stream data.
When the fragmented code stream data is obtained, because each fragmented code stream data has multi-frame data, the fragmentation capacity of the fragmented code stream data is further calculated in combination with the byte length of each frame of spliced code stream data, the ratio between the fragmentation capacity and the byte length is calculated to obtain the number of storage frames corresponding to the fragmented code stream data, and then the sum of the number of the storage frames is calculated respectively to obtain the time period information corresponding to each fragmented code stream data.
And step 205, determining and storing the target storage node position of the fragmented code stream data based on the load path number respectively corresponding to each distributed storage node.
Optionally, step 205 may comprise the following sub-steps:
sequencing all distributed storage nodes according to the load paths corresponding to the distributed storage nodes respectively, and determining the sequencing number of each distributed storage node;
determining and storing a target storage node position corresponding to the fragmented code stream data based on a preset storage node calculation formula in combination with the sequencing number;
the calculation formula of the storage node is as follows:
Node=(lastNode+1)%nodeNum;
node is the sort number corresponding to the position of the target storage Node, nodeNum is the total number of the current distributed storage Node, and lastNode is the sort number corresponding to the position of the last target storage Node.
In an example of the present invention, after the multiple fragmented code stream data are obtained, to balance the network bandwidth and the load of each distributed storage node, the distributed storage nodes may be further sorted according to the number of load paths corresponding to each distributed storage node, and the sorting number corresponding to each distributed storage node is determined. And determining the position of a target storage node corresponding to the fragmented code stream data based on a preset storage node calculation formula and the sequencing number, and storing the fragmented code stream data to the corresponding position of the target storage node.
Referring to fig. 4, fig. 4 is a flow chart of slicing and storing spliced code stream data according to an embodiment of the present invention.
After splicing of the intermediate streaming media data is completed and spliced code stream data is obtained, receiving the residual storage space of each storage node at the current moment, such as a storage node 1 and a storage node 2; slicing and dividing spliced code stream data based on the minimum residual storage space and a preset slicing rule to obtain a plurality of sliced code stream data; meanwhile, according to the load path number respectively corresponding to each distributed storage node, calculating the storage state corresponding to each distributed storage node, and determining the target storage node position of the fragmented code stream data; and storing the data of the fragment code stream to the position of a target storage node, and after the data of one fragment code stream is stored, calculating the position of the next target storage node again until all the data of the fragment code stream are stored. And simultaneously recording the positions of all the distributed storage nodes and the corresponding time period information in the storage process.
Further, after performing step 205, the method further comprises the steps of:
and respectively establishing association information between each time interval information and each target storage node position to obtain a time interval key value pair table.
In particular implementations, the manner in which a user acquires streaming media is typically based on a point in time, such as playback video, video skip, and progress bar drag. In order to improve the efficiency of subsequent data return, association information between each time period information and each target storage node position can be respectively established to obtain a time period key value pair table. When a user needs a certain period, the period key value pair table can be inquired according to the required period information, and corresponding fragment code stream data can be quickly acquired from the corresponding target storage node position and returned.
In another example of the present invention, the method further comprises the following steps S21-S24:
s21, when a data acquisition request sent by a user side is received, analyzing the data acquisition request and determining a corresponding data acquisition time interval;
s22, determining positions of a plurality of storage nodes to be returned and information of the time periods to be returned corresponding to the data acquisition time periods by adopting a data acquisition time period retrieval time period key value pair table;
s23, sequentially acquiring fragmented code stream data corresponding to the time period to be returned from each storage node position to be returned as target code stream data, and returning the target code stream data to the user side;
in this embodiment, after the spliced code stream data is stored in each distributed storage node, if the master control manager receives a data acquisition request from the user side, the data acquisition request is further analyzed to determine a data acquisition time period required by the user side; determining the positions of a plurality of storage nodes to be returned and corresponding time interval information to be returned corresponding to the data acquisition time interval by adopting a data acquisition time interval retrieval time interval key value pair table; and sequentially acquiring the fragment code stream data corresponding to the time period to be returned from each storage node position to be returned as target code stream data, and returning the target code stream data to the user side.
And S24, when the return progress of the target code stream data exceeds a preset return threshold, parallelly returning the target code stream data in the next storage node to be returned.
In a specific implementation, in order to better reduce the network bandwidth, target code stream data may be returned from more than one storage node position to be returned, at this time, the return progress of the target code stream data at the current storage node position to be returned needs to be monitored in real time, and if the return progress exceeds a predetermined return threshold, fragmented code stream data in a period to be returned in the next storage node position to be returned can be obtained in advance as the target code stream data and is returned to the user side in parallel until all the target code stream data are returned.
Referring to fig. 5, fig. 5 shows a flow chart of object code stream data return in the embodiment of the present invention.
In the embodiment, when a data acquisition request sent by a user side is received, the data acquisition request is analyzed by a main control manager to determine the position of a corresponding storage node to be returned, N target code stream data corresponding to the time interval information to be returned are sequentially returned through the positions of the storage nodes to be returned, and the N target code stream data can be further returned to the user side in the form of data packets; when the return progress of the Nth target code stream data is larger than the return threshold value, for example, 80%, returning the next section of target code stream data from the next storage node position to be returned until all the target code stream data of the period to be returned have been returned.
In the embodiment of the invention, initial streaming media data are obtained frame by frame, corresponding timestamps are added to the initial streaming media data based on a transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data, and meanwhile, when one frame of intermediate streaming media data is generated, the frame of intermediate streaming media data is subjected to code stream packaging and is spliced with the previous frame of intermediate streaming media data to obtain spliced code stream data; and finally, carrying out data fragmentation on spliced code stream data according to the residual storage space and the load path number respectively corresponding to each distributed storage node, and determining and storing the position of a target storage node. Therefore, the technical problem that in the prior art, due to the fact that the storage data need to be spliced and then intercepted again for transmission, too much time is spent to increase transmission cost is solved, and the storage time is reduced while the transmission cost is lower.
Referring to fig. 6, fig. 6 is a block diagram illustrating a distributed storage apparatus for streaming media according to a third embodiment of the present invention.
The embodiment of the invention provides a distributed storage device of streaming media, which is applied to a main control manager, wherein the main control manager is in communication connection with a storage server, the storage server comprises a plurality of distributed storage nodes, and the device comprises:
a streaming media data obtaining module 601, configured to obtain initial streaming media data frame by frame;
a timestamp adding module 602, configured to add a corresponding timestamp to the initial streaming media data according to a transmission protocol corresponding to the initial streaming media data, so as to obtain intermediate streaming media data;
a data encapsulating and splicing module 603, configured to perform code stream encapsulation and splicing on the intermediate streaming media data frame by frame, so as to obtain spliced code stream data;
and the node determining and storing module 604 is configured to determine and store a target storage node position of the spliced code stream data according to the remaining storage space value and the load path number respectively corresponding to each distributed storage node.
Optionally, the timestamp adding module 602 includes:
the protocol analysis submodule is used for analyzing a transmission protocol corresponding to the initial streaming media data to obtain a transmission frame rate corresponding to the current frame of the initial streaming media data;
and the timestamp adding submodule is used for adding a corresponding timestamp to the initial streaming media data according to the transmission frame rate to obtain intermediate streaming media data.
Optionally, the timestamp adding module 602 further includes:
a timestamp difference calculation submodule for calculating a timestamp difference between a timestamp corresponding to the intermediate streaming media data of the previous frame and a timestamp corresponding to the intermediate streaming media data of the current frame;
the difference comparison submodule is used for comparing the absolute value of the timestamp difference with a preset difference threshold;
and the intermediate streaming media data updating submodule is used for adding a new timestamp to the initial streaming media data again according to the transmission frame rate to obtain new intermediate streaming media data if the absolute value of the timestamp difference is greater than the difference threshold.
Optionally, the node determination and storage module 604 includes:
the data fragmentation submodule is used for carrying out data fragmentation on the spliced code stream data according to the residual storage space values respectively corresponding to the distributed storage nodes to obtain a plurality of fragmented code stream data and respectively corresponding time period information;
and the position determining and storing submodule is used for determining and storing the position of the target storage node of the fragmented code stream data based on the load path number respectively corresponding to each distributed storage node.
Optionally, the data fragmentation sub-module is specifically configured to:
comparing the residual storage space values respectively corresponding to all the distributed storage nodes, and determining the minimum value as the minimum residual storage space value;
performing data fragmentation on spliced code stream data according to a preset data fragmentation rule and a minimum remaining storage space value to obtain a plurality of fragmented code stream data;
calculating the ratio of the fragment capacity of the fragment code stream data to the byte length of each frame of spliced code stream data to obtain the number of storage frames corresponding to the fragment code stream data;
and calculating the sum of the storage frame numbers to obtain the time period information corresponding to the fragment code stream data.
Optionally, the position determining and storing submodule is specifically configured to:
sequencing all distributed storage nodes according to the load paths corresponding to the distributed storage nodes respectively, and determining the sequencing number of each distributed storage node;
determining and storing a target storage node position corresponding to the fragmented code stream data based on a preset storage node calculation formula in combination with the sequencing number;
the calculation formula of the storage node is as follows:
Node=(lastNode+1)%nodeNum;
node is the sort number corresponding to the position of the target storage Node, nodeNum is the total number of the current distributed storage Node, and lastNode is the sort number corresponding to the position of the last target storage Node.
Optionally, the apparatus further comprises:
and the time interval key value pair table establishing module is used for respectively establishing the association information between each time interval information and each target storage node position to obtain the time interval key value pair table.
Optionally, the apparatus further comprises:
the data acquisition request receiving module is used for analyzing the data acquisition request and determining a corresponding data acquisition time interval when receiving the data acquisition request sent by the user side;
the return position and time period determining module is used for searching a time period key value pair table by adopting a data acquisition time period and determining a plurality of storage node positions to be returned and time period information to be returned corresponding to the data acquisition time period;
the target code stream data returning module is used for sequentially acquiring the fragment code stream data corresponding to the time period to be returned from each position of the storage node to be returned as target code stream data and returning the target code stream data to the user side;
and the cache returning module is used for parallelly returning the target code stream data in the next storage node to be returned when the returning progress of the target code stream data exceeds a preset returning threshold value.
The embodiment of the present invention further provides an electronic device, which includes a memory and a processor, where the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the distributed storage method for streaming media according to any embodiment of the present invention.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses, modules and sub-modules may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A distributed storage method of streaming media is applied to a master control manager, the master control manager is in communication connection with a storage server, the storage server comprises a plurality of distributed storage nodes, and the method comprises the following steps:
acquiring initial streaming media data frame by frame;
adding a corresponding timestamp to the initial streaming media data according to a transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data;
performing code stream packaging and splicing on the intermediate streaming media data frame by frame to obtain spliced code stream data;
and determining and storing the target storage node position of the spliced code stream data according to the residual storage space value and the load path number respectively corresponding to each distributed storage node.
2. The method according to claim 1, wherein the step of adding a corresponding timestamp to the initial streaming media data according to a transmission protocol corresponding to the initial streaming media data to obtain intermediate streaming media data comprises:
analyzing a transmission protocol corresponding to the initial streaming media data to obtain a transmission frame rate corresponding to the initial streaming media data of the current frame;
and adding a corresponding timestamp to the initial streaming media data according to the transmission frame rate to obtain intermediate streaming media data.
3. The method of claim 2, further comprising:
calculating a timestamp difference value between a timestamp corresponding to the intermediate streaming media data of the last frame and a timestamp corresponding to the intermediate streaming media data of the current frame;
comparing the absolute value of the timestamp difference value with a preset difference threshold value;
and if the absolute value of the timestamp difference is larger than the difference threshold, adding a new timestamp to the initial streaming media data again according to the transmission frame rate to obtain new intermediate streaming media data.
4. The method according to claim 1, wherein the step of determining and storing the target storage node position of the spliced code stream data according to the remaining storage space value and the number of load paths respectively corresponding to each distributed storage node comprises:
performing data fragmentation on the spliced code stream data according to the residual storage space values respectively corresponding to the distributed storage nodes to obtain a plurality of fragmented code stream data and respectively corresponding time period information;
and determining and storing the target storage node position of the fragment code stream data based on the load path number corresponding to each distributed storage node.
5. The method according to claim 4, wherein the step of performing data fragmentation on the spliced code stream data according to the remaining storage space values respectively corresponding to the distributed storage nodes to obtain a plurality of fragmented code stream data and respectively corresponding time period information comprises:
comparing the residual storage space values respectively corresponding to the distributed storage nodes, and determining the minimum value as the minimum residual storage space value;
performing data fragmentation on the spliced code stream data according to a preset data fragmentation rule and the minimum remaining storage space value to obtain a plurality of fragmented code stream data;
calculating the ratio of the fragment capacity of the fragment code stream data to the byte length of each frame of spliced code stream data to obtain the number of storage frames corresponding to the fragment code stream data;
and calculating the sum of the storage frame numbers to obtain the time period information corresponding to the fragment code stream data.
6. The method according to claim 4, wherein the step of determining and storing the target storage node position of the fragmented code stream data based on the load path number corresponding to each distributed storage node comprises:
sequencing all the distributed storage nodes according to the load paths corresponding to the distributed storage nodes respectively, and determining the sequencing number of each distributed storage node;
determining and storing a target storage node position corresponding to the fragment code stream data based on a preset storage node calculation formula in combination with the sequencing number;
the calculation formula of the storage node is as follows:
Node=(lastNode+1)%nodeNum;
node is the sorting number corresponding to the position of the target storage Node, nodeNum is the total number of the current distributed storage nodes, and lastNode is the sorting number corresponding to the position of the last target storage Node.
7. The method of claim 4, further comprising:
and respectively establishing association information between each time interval information and each target storage node position to obtain a time interval key value pair table.
8. The method of claim 7, further comprising:
when a data acquisition request sent by a user side is received, analyzing the data acquisition request, and determining a corresponding data acquisition time interval;
retrieving the time interval key value pair table by adopting the data acquisition time interval, and determining a plurality of storage node positions to be returned and time interval information to be returned corresponding to the data acquisition time interval;
sequentially acquiring the fragment code stream data corresponding to the time period to be returned from each storage node position to be returned as target code stream data, and returning the target code stream data to the user side;
and when the return progress of the target code stream data exceeds a preset return threshold, parallelly returning the target code stream data in the next storage node to be returned.
9. A distributed storage device for streaming media, which is applied to a master control manager, wherein the master control manager is communicatively connected to a storage server, the storage server includes a plurality of distributed storage nodes, and the device includes:
the streaming media data acquisition module is used for acquiring initial streaming media data frame by frame;
a timestamp adding module, configured to add a corresponding timestamp to the initial streaming media data according to a transmission protocol corresponding to the initial streaming media data, so as to obtain intermediate streaming media data;
the data packaging and splicing module is used for carrying out code stream packaging and splicing on the intermediate streaming media data frame by frame to obtain spliced code stream data;
and the node determining and storing module is used for determining and storing the target storage node position of the spliced code stream data according to the residual storage space value and the load path number respectively corresponding to each distributed storage node.
10. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program, when executed by the processor, causes the processor to perform the steps of the distributed storage method for streaming media according to any one of claims 1-8.
CN202111387482.7A 2021-11-22 2021-11-22 Distributed storage method, device and equipment for streaming media Active CN114125493B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111387482.7A CN114125493B (en) 2021-11-22 2021-11-22 Distributed storage method, device and equipment for streaming media

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111387482.7A CN114125493B (en) 2021-11-22 2021-11-22 Distributed storage method, device and equipment for streaming media

Publications (2)

Publication Number Publication Date
CN114125493A true CN114125493A (en) 2022-03-01
CN114125493B CN114125493B (en) 2023-06-09

Family

ID=80439197

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111387482.7A Active CN114125493B (en) 2021-11-22 2021-11-22 Distributed storage method, device and equipment for streaming media

Country Status (1)

Country Link
CN (1) CN114125493B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104954810A (en) * 2015-07-14 2015-09-30 电子科技大学 Switching method for ensuring data continuity of distributed video stream storage system
CN104967862A (en) * 2015-07-22 2015-10-07 东方网力科技股份有限公司 Video storage method and device, and video searching method and device
CN106961613A (en) * 2017-03-30 2017-07-18 上海七牛信息技术有限公司 A kind of streaming real-time transcoding order method and system
CN107295425A (en) * 2017-06-12 2017-10-24 北京达沃时代科技股份有限公司 A kind of method of quick splicing transcoding slicing files
WO2019019371A1 (en) * 2017-07-24 2019-01-31 平安科技(深圳)有限公司 Streaming media data transmission method, storage medium and streaming media server
CN112788366A (en) * 2020-12-28 2021-05-11 杭州海康威视***技术有限公司 Video processing method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104954810A (en) * 2015-07-14 2015-09-30 电子科技大学 Switching method for ensuring data continuity of distributed video stream storage system
CN104967862A (en) * 2015-07-22 2015-10-07 东方网力科技股份有限公司 Video storage method and device, and video searching method and device
CN106961613A (en) * 2017-03-30 2017-07-18 上海七牛信息技术有限公司 A kind of streaming real-time transcoding order method and system
CN107295425A (en) * 2017-06-12 2017-10-24 北京达沃时代科技股份有限公司 A kind of method of quick splicing transcoding slicing files
WO2019019371A1 (en) * 2017-07-24 2019-01-31 平安科技(深圳)有限公司 Streaming media data transmission method, storage medium and streaming media server
CN112788366A (en) * 2020-12-28 2021-05-11 杭州海康威视***技术有限公司 Video processing method and device

Also Published As

Publication number Publication date
CN114125493B (en) 2023-06-09

Similar Documents

Publication Publication Date Title
CN110446072B (en) Video stream switching method, electronic device and storage medium
US9609338B2 (en) Layered video encoding and decoding
CN110784750B (en) Video playing method and device and computer equipment
US10491937B2 (en) Information processing system
CN110662017B (en) Video playing quality detection method and device
US9578333B2 (en) Method for decreasing the bit rate needed to transmit videos over a network by dropping video frames
US9628537B2 (en) High picture quality video streaming service method and system
CN109714623B (en) Image display method and device, electronic equipment and computer readable storage medium
CN109348309A (en) A kind of distributed video transcoding method suitable for frame rate up-conversion
CN108419041A (en) A kind of method and apparatus of video data processing
CN111263164A (en) High frame frequency video parallel coding and recombination method
CN112714338B (en) Video transmission method, video playing method, video transmission device, video playing device, computer equipment and storage medium
CN111741247B (en) Video playback method and device and computer equipment
CN114125493B (en) Distributed storage method, device and equipment for streaming media
CN116980662A (en) Streaming media playing method, streaming media playing device, electronic equipment, storage medium and program product
CN108989905B (en) Media stream control method and device, computing equipment and storage medium
CN107734278B (en) Video playback method and related device
CN115878379A (en) Data backup method, main server, backup server and storage medium
CN111818338B (en) Abnormal display detection method, device, equipment and medium
CN110855619B (en) Processing method and device for playing audio and video data, storage medium and terminal equipment
JP2023007048A (en) Streaming server, transmission method, and program
US20210076054A1 (en) Temporally-overlapped video encoding, video decoding and video rendering techniques therefor
CN113824715B (en) Method and device for playing real-time video stream
TW202110176A (en) Coding of video and audio with initialization fragments
CN115695918B (en) Multi-camera broadcast guide control method and device, readable storage medium and terminal equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant