WO2016011823A1 - Method for acquiring live video slice, server, and storage medium - Google Patents
Method for acquiring live video slice, server, and storage medium Download PDFInfo
- Publication number
- WO2016011823A1 WO2016011823A1 PCT/CN2015/074766 CN2015074766W WO2016011823A1 WO 2016011823 A1 WO2016011823 A1 WO 2016011823A1 CN 2015074766 W CN2015074766 W CN 2015074766W WO 2016011823 A1 WO2016011823 A1 WO 2016011823A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- slice
- key frame
- duration
- qth
- live broadcast
- 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.)
- Ceased
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/80—Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
- H04N21/83—Generation or processing of protective or descriptive data associated with content; Content structuring
- H04N21/845—Structuring of content, e.g. decomposing content into time segments
Definitions
- the present invention relates to a live video streaming media technology, and in particular, to a method, a server and a computer storage medium for acquiring a live video slice.
- the HLS (HTTP Live Streaming) protocol is a dynamic code stream adaptation protocol based on the Hypertext Transfer Protocol (HTTP). It is a streaming media transmission protocol proposed by Apple.
- HTTP Hypertext Transfer Protocol
- the HLS protocol has been widely used in the field of streaming media, mainly because it uses HTTP protocol transmission, and can adaptively adjust the code rate according to the network bandwidth, such as allowing the server on the network side to store multiple different code rates for the same program content.
- the multimedia stream, and the terminal can adaptively adjust the code rate of the multimedia stream to be downloaded according to the actual network download speed; when the network bandwidth is tight, the terminal can achieve uninterrupted playback by reducing the code rate.
- the multimedia data acquired by the terminal is not a complete data stream, but a slice with data recorded, because: in the HLS protocol, the server side
- the live data stream is stored as a continuous, short-lived media file (Motion Picture Experts Group MPEG-Transport Stream TS format). These media files are called slices, and the client only needs to continuously download and play these slices.
- a live video can be formed. Among them, because the server always generates a new slice of the latest live data, the client only needs to continuously play the slice obtained from the server in order, and the live broadcast is realized.
- the transcoding process of the media data directly generates the slice that meets the requirement; the second method is to separate the transcoding and the fragmentation process separately, first transcoding the live data, and then slicing the transcoded file;
- the first method requires that the transcoder must be able to support the slicing function, which has high design requirements for the transcoder, which is not conducive to implementation; the second method is easier to implement because it converts the transcoding and fragmentation independently.
- the second method of generating slices is more popular, but it also has the following problems: due to the fixed length of the generated slice, there may be incomplete data or redundant data at the edge of the slice, resulting in a live view of the slice. There is a discontinuity in the live picture between the slow and adjacent two slices, which reduces the user's viewing experience.
- the embodiment of the present invention provides a method, a server, and a computer storage medium for acquiring a live video slice, which can solve the slow occurrence of the live broadcast picture of the slice, and the live picture between the adjacent two slices exists. Discontinuous conditions, etc., thereby improving the smoothness of live video playback, the quality of the playback picture, and improving the user viewing experience.
- An embodiment of the present invention provides a method for obtaining a live video slice, where the method includes:
- the starting position of the q+1th key frame is the first time when the q+1th key frame exists in the first duration and/or the second duration of the start position of the qth key frame.
- the current original live broadcast source is segmented to form a qth slice; wherein q is a positive integer.
- the method further includes:
- the position from the start position of the qth key frame is the reference duration
- the current original live broadcast source is segmented to form a qth slice.
- the reference duration for obtaining the slice includes:
- the sum value obtained is taken as the reference duration of the slice.
- the method before acquiring the reference duration of the slice, the method includes:
- the qth key frame is obtained according to the key frame information.
- the method further includes:
- the lengths of the program content carried by the slices configured with different code rates are the same, so as to facilitate the switching of different code rate slices.
- the embodiment of the invention further provides a server, the server comprising:
- a first obtaining unit configured to acquire a reference duration of the slice
- the first determining unit is configured to determine that the sum of the reference duration and the first preset duration is the first duration, And/or determining a difference between the reference duration and the first preset duration is a second duration;
- a second acquiring unit configured to acquire a qth key frame of the current original live broadcast source
- a second determining unit configured to determine that a starting position of the qth key frame is a starting position of the qth slice
- a third determining unit configured to determine, when the q+1th key frame exists in the first duration and/or the second duration of the start position of the qth key frame, the q+1th key
- the starting position of the frame is the end position of the qth slice
- the first sub-unit is configured to split the current original live broadcast source at the start position and the end position of the q-th frame to form a q-th slice; wherein q is a positive integer.
- the third determining unit is further configured to determine that the qth key is the distance when there is no q+1th key frame in the first duration and/or the second duration of the qth key frame start position.
- the position where the frame start position is the reference duration is the end position of the qth slice;
- the first segmentation unit is further configured to slice the current original live broadcast source at the start position and the end position of the qth frame to form a qth slice.
- the first acquiring unit is further configured to:
- the sum value obtained is taken as the reference duration of the slice.
- the server further includes:
- the first receiving unit is configured to receive the current original live broadcast source
- the first converting unit is configured to convert the current original live broadcast source into a real-time transport protocol RTP stream, and identify key frame information of the RTP stream;
- a first processing unit configured to cache, sort, and parse the RTP stream
- a first deleting unit configured to delete an RTP header in the RTP stream processed by the first processing unit to form RTP payload data
- the second acquiring unit is further configured to acquire, in the RTP payload data, the qth key frame according to the key frame information.
- the server further includes:
- the third obtaining unit is configured to obtain a program association table PAT and a program mapping table PMT from the current original live broadcast source;
- the first configuration unit is configured to configure PAT and PMT to an initial position of each slice to facilitate playing of the program content carried by the slice;
- the fourth determining unit configured to determine that the current original live broadcast source has at least two code rates, triggering the second configuration unit
- the second configuration unit is configured to configure the lengths of the program content carried by the slices of different code rates to be the same, so as to facilitate switching of different code rate slices.
- the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the foregoing method for obtaining a live video slice.
- the method for obtaining a live video slice, the server, and the computer storage medium provided by the embodiment of the present invention include: obtaining a reference duration of the slice; determining a sum of the reference duration and the first preset duration as a first duration, and/or determining The difference between the reference duration and the first preset duration is the second duration; obtaining the qth key frame of the current original live broadcast source; determining the starting position of the qth keyframe as the starting position of the qth slice; Determining that the q+1th key frame is the qth slice when the q+1th key frame exists in the first duration and/or the second duration of the start position of the key frame End position; at the beginning and end of the qth frame, the current original straight
- the broadcast source performs segmentation to form a qth slice; wherein q is a positive integer.
- the slice length can be fluctuated around the reference duration, and the live broadcast picture of the slice can be slowed down, and the live picture between the adjacent two slices is discontinuous, thereby improving the live broadcast.
- the smoothness of video playback and the quality of the playback picture enhance the user's viewing experience.
- FIG. 1 is a schematic flowchart of a method for obtaining a live video slice according to an embodiment of the present invention
- FIG. 2 is a schematic diagram of an application scenario according to an embodiment of the present invention.
- FIG. 3 is a schematic diagram of a specific implementation process of a method for obtaining a live video slice according to an embodiment of the present disclosure
- FIG. 4 is a schematic diagram of an application scenario 2 according to an embodiment of the present invention.
- FIG. 5 is a schematic structural diagram of a server according to an embodiment of the present invention.
- FIG. 1 is a schematic flowchart of a method for obtaining a live video slice according to an embodiment of the present invention; as shown in FIG. 1 , the method includes:
- Step 11 Obtain a reference duration of the slice
- the network side specifically the network side server receives the original live source stream, such as the MPEG-TS stream sent by the live broadcast source MPEG system, because the original live source stream is continuously sent to the server by the live source system, so the server pair
- the processing of the original live source stream received each time is the same, please see the description below.
- the server converts the MPEG-TS code stream into a Real-time Transport Protocol (RTP) code stream, and identifies key frame information in the RTP code stream, and performs processing such as buffering, sorting, and parsing the RTP stream;
- RTP payload data After the RTP header of the RTP stream processed as described above, RTP payload data; wherein the key frame information includes: a key frame header, a frame tail; a key frame length in the RTP stream, and a video buffer verifier for buffering the code stream (VBV, Video Buffering Verifier)
- the first threshold A is preset, and may be set according to the actual length of the MPEG-TS code stream. For example, A may be set to 1 in advance, or may be set to 2 in advance; the reference duration and key are The unit of frame length, V, and A can be seconds s, minutes min, hour hours, etc., and is usually taken as seconds.
- the key frame may also be referred to as an I frame; the purpose of identifying key frame information in the RTP code stream is illustrated in step 13.
- Step 12 determining that the sum of the reference duration and the first preset duration is the first duration, and/or determining that the difference between the reference duration and the first preset duration is the second duration;
- the first preset duration is set according to the actual application situation; taking the first preset duration as the duration B as an example, calculating the sum of the reference durations BS and B, and taking the sum of the two as the first duration; / or, calculate the difference between the base duration BS and B, and use the difference between the two as the second duration.
- Step 13 Obtain the qth key frame of the current original live broadcast source.
- the qth key frame is identified; wherein q is a positive integer.
- Step 14 determining that the starting position of the qth key frame is the starting position of the qth slice
- Step 15 Determine, in the first duration and/or the second duration of the start position of the qth key frame, that the q+1th key frame exists, determine the start of the q+1th key frame The position is the end position of the qth slice;
- the start position of the qth key frame it is searched whether there is a q+1th key frame, and when found, the q+1th key frame is determined.
- the starting position is the end position of the qth slice.
- Step 16 At the start position and the end position of the qth frame, the current original live broadcast source is segmented to form a qth slice; wherein q is a positive integer.
- the q-th slice is formed at the start position and the end position of the qth key frame to form a q-th slice; that is, the start position of the q-th slice is the q-th key frame start position, the qth The end position of the slice is the starting position of the q+1th key frame.
- the qth key frame start position is not present when the q+1th key frame is not present.
- the position of the reference duration is the end position of the qth slice, and at the start position and the end position of the qth frame, the current original live broadcast source is segmented to form a qth slice.
- the information identifies the first key frame, and the start position of the first key frame is the start position of the first slice of the current original live broadcast source, and the start position of the first key frame is 0s, from the 0s position. Find the time to 9s-11s. In the duration of the 9s-11s, when the second key frame is determined, the start position of the second key frame is taken as the end position of the first slice.
- the start position and the end position of the slice are segmented to form the first slice of the current original live broadcast source; meanwhile, the start position of the second key frame is used as the start position of the second slice of the current original live broadcast source.
- the starting position of the second slice is 0s, and then searching from the 0s position to the time of 9s-11s. During the duration of the 9s-11s, it is determined that there is a third key frame, and the third key frame is present.
- the starting position is used as the ending position of the second slice, and is segmented at the start position and the end position of the second slice to form a second slice of the current original live broadcast source; and so on, the server pairs each receive The original live source to the slice is sliced.
- the starting position (the beginning position) of the qth key frame is the starting position (the beginning position) of the qth slice
- the starting position of the q+1th key frame is the The end position of q slices.
- a key frame can be divided into the same slice.
- the position of the key frame is the segmentation position, or the distance from the q-th key frame start position is used as the reference duration.
- the location is the segmentation location, and the original live source stream is segmented to ensure that the HLS slice length fluctuates around the reference duration, so that the key frames are sliced into the same slice, which solves the incomplete data or data redundancy of the slice edge.
- the phenomenon of the live broadcast of the slice is slow, and the live picture between the adjacent two slices is discontinuous, which improves the smoothness of the live video playback, the quality of the playback picture, and improves the user viewing experience.
- the sliced slice When slicing the original live source stream, the sliced slice also needs to be satisfied:
- the PAT table mainly includes a program channel number and a packet identifier (PID, Packet Identifier) number of the PMT corresponding to each channel; the PMT table includes PIDs of all video streams of each channel, and audio data of all audio streams.
- PID Packet Identifier
- the Video data can be filtered from the channel through the PID of the Video; meanwhile, the PAT and the PMT periodically appear in the original live source stream.
- PAT and PMT are configured at the beginning of each slice, enabling independent playback of each slice.
- the lengths of the program content carried by the slices configured with different code rates are the same, so as to facilitate switching of different code stream slices, that is, in order to facilitate live video Switch between different code rates.
- each slice also referred to as a TS slice
- the live single rate file includes: a main index file, a sub-index file, and a TS slice; wherein the main index file is named index.m3u8, and the sub-index file is
- the code rate is named 1024.m3u8 (the code rate is 1024 kbps)
- the TS slice is named $time-1024-$seq.ts; where: $time indicates the slice formation time, 1024 indicates the slice rate is 1024 kbps, and $seq indicates the slice.
- the serial number; the slices with the same playback rate need to be placed under the same sub-index file.
- the file content of the sub-index file 1024.m3u8 can represent the names of all the slices that it can index.
- the sub-index file 1024.m3u8 can be indexed by up to 3 TS slices, it can be indexed to Slice 1 of 20140521160000-1024-1.ts, slice 2 named 20140521160000-1024-2.ts, and slice 3 named 20140521160000-1024-2.ts.
- the original live source stream is multi-code rate similar to the description of the original live source stream as the single code rate, except that in the multi-rate original live source stream, the number of sub-index files is equal to the code used in the original live source stream. The number of rates.
- the server continuously acquires the original live source stream, the original live stream is continuously segmented, and new slices are continuously formed, so the main and sub index files are required to be The new slice is continuously updated. For example, within 1 min, the server can split the original live source stream into 6 TS slices, then the sub-index file is updated every 10s, updated to index the 6 latest TS slices, and deleted. For the previous 6 TS slices The index is adapted to the requirements of the HLS live specification; this process can be seen as a rollback process for slices.
- FIG. 2 is a schematic diagram of an application scenario according to an embodiment of the present invention
- FIG. 3 is a schematic flowchart of a specific implementation of a method for obtaining a live video slice according to an embodiment of the present invention
- FIG. 2 and FIG. 3 further describe an embodiment of the present invention.
- Step 301 The node, specifically the server located at the node, receives the original live broadcast source MPEG-TS code stream sent by the MPEG system;
- the server supports a User Data Protocol (UDP) unicast and UDP multicast of a code stream.
- UDP User Data Protocol
- Step 302 The server converts the received MPEG-TS code stream into an RTP code stream.
- the server will add an extended RTP header to the MPEG-TS code stream, determine the length of the VBV, and the key frame information of the code stream such as the key frame header, the end of the frame, the length, etc.; obtain the PAT and PMT of the code stream.
- Step 303 The server performs processing such as buffering, sorting, parsing, and the like on the RTP stream to facilitate playback of the subsequent terminal.
- the data may be scrambled, descrambled, encrypted, etc., depending on the specific application.
- Step 304 Determine a reference duration BS
- BS key frame length KP + VBV length V + 1.
- Step 305 Remove the header of the RTP stream to obtain RTP payload data.
- Step 306 In the RTP payload data, obtain the qth key frame of the current original live broadcast source; determine the starting position of the qth key frame as the starting position of the qth slice; Finding whether there is a q+1th key frame in the first duration and/or the second duration of the start position of the key frame;
- step 307 is performed; otherwise, step 308 is performed.
- Step 307 Determine the start position of the q+1th key frame as the end position of the qth slice; at the start position and the end position of the qth frame, segment the current original live broadcast source to form the qth Slice, continue to step 309;
- the beginning position of the qth key frame is the beginning position of the qth slice
- the beginning position of the q+1th key frame is the end position of the qth slice; I will not repeat them here.
- Step 308 The position at which the q-th key frame start position is the reference duration is the end position of the q-th slice, and at the start position and the end position of the q-th frame, the current original live broadcast source is segmented to form a first q slices, continue to step 309;
- the PAT and PMT of the code stream need to be placed at the beginning of each slice so that independent playback of each slice can be achieved.
- Step 309 The server generates a sub-index file for the formed slice according to the HLS protocol.
- Step 310 The server refreshes the formed slice, the sliced primary index file, and the sub-index file to the disk for storage.
- the server upon receiving the MPEG-TS code stream, the server generates a main index file in accordance with the HLS protocol.
- Step 311 When the terminal reports a video play request for the current 10s of the channel A, the terminal requests the main index file from the download server (DLS, Down Load Server) in the node; the DLS reads the main index file of the channel A in the disk. And sending the file content to the terminal through the HTTP protocol; the terminal requests the sub-index file from the DLS; the DLS reads the sub-index file corresponding to the video within the current 10s of the channel A in the disk, and sends the file content to the terminal through the HTTP protocol.
- the download server DLS, Down Load Server
- terminal to DLS please Finding a TS slice file corresponding to the sub-index file; the DLS reads the TS slice file of the current 10s video carrying the channel A in the disk, and sends the file content to the terminal through the HTTP protocol, and the terminal plays the TS slice for the User watch.
- FIG. 4 is a schematic diagram of an application scenario 2 according to an embodiment of the present invention. As shown in FIG. 4, the server in the solution may also be applied to a multi-node scenario; wherein each node may be connected to the terminal to facilitate the terminal request.
- each node includes a server and a download server DLS; further, the central node, specifically the server of the central node receives the MPEG-TS code stream, and transmits the MPEG-TS code stream to the regional node, specifically the regional node
- the server of the area node transmits the MPEG-TS code stream to the edge node; after the corresponding server in the three nodes receives the live source source stream, the processing is performed according to the foregoing steps 302 to 311, and details are not described herein again.
- the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used in the foregoing method for obtaining a live video slice.
- FIG. 5 is a schematic diagram of a server according to an embodiment of the present invention; as shown in FIG. 5, the server includes: a first acquiring unit 500. a first determining unit 501, a second obtaining unit 502, a second determining unit 503, a third determining unit 504, and a first splitting unit 505;
- the server further includes a first receiving unit, a first converting unit, a first processing unit, and a first deleting unit;
- the first obtaining unit 500 is configured to acquire a reference duration of the slice
- the server specifically the first receiving unit, receives the original live source stream, such as receiving an MPEG-TS stream from the MPEG system, and transmits the received MPEG-TS stream to the first converting unit;
- the converting unit converts the MPEG-TS code stream into an RTP code stream, and identifies key frame information in the RTP code stream;
- the first processing unit buffers, sorts, parses, etc. the RTP code stream;
- the first deleting unit deletes the first frame Processing unit processing RTP code stream
- the RTP packet header forms the RTP payload data;
- the first obtaining unit 500 obtains the key frame length and the VBV length in the RTP code stream, and sums the key frame length, the VBV length, and the first threshold, and the summation result is used as a slice.
- the reference duration that is, if the key frame length is KP, the VBV length is V, and the first threshold is A
- the first processing unit in the process of buffering, sorting, parsing, etc. processing the RTP stream if the original live source stream has been scrambled (descrambled), the first processing unit in the solution needs to perform descrambling ( Scrambling) operation; if the slice needs to be encrypted when it is subsequently divided into slices, the first processing unit also needs to perform encryption processing.
- the first determining unit 501 is configured to determine that the sum of the reference duration and the first preset duration is a first duration, and/or determine that the difference between the reference duration and the first preset duration is a second duration;
- the first determining unit 501 calculates the sum of the reference durations BS and B, and uses the sum of the two as the first duration; and/or calculates the reference durations BS and B. The difference between the two is taken as the second duration.
- the second obtaining unit 502 is configured to acquire the qth key frame of the current original live broadcast source
- the second obtaining unit 502 identifies the qth key frame according to the key frame information in the RTP payload data.
- a second determining unit 503, configured to determine that a starting position of the qth key frame is a starting position of the qth slice;
- the third determining unit 504 is configured to determine, when the q+1th key frame exists in the first duration and/or the second duration of the qth key frame start position, the q+1th The starting position of the key frame is the end position of the qth slice;
- the third determining unit 504 searches for the q+1th key frame in the first duration and/or the second duration of the qth key frame start position, and when found, determines the q+th
- the starting position of one key frame is the end position of the qth slice.
- the first unit 505 is configured to be at the start position and the end position of the qth frame, for the current
- the original live broadcast source is segmented to form a qth slice; wherein q is a positive integer.
- the first slicing unit 505 performs segmentation at the qth key frame start position and end position to form a qth slice; that is, the qth slice starts from the qth key frame.
- the starting position, the end position of the qth slice is the q+1th key frame starting position.
- the third determining unit 504 is further configured to: when the q+1th key frame is not present, the qth distance is determined in the first duration and/or the second duration of the qth key frame start position.
- the position where the key frame start position is the reference duration is the end position of the qth slice;
- the first segmentation unit 505 is further configured to segment the current original live broadcast source at the start position and the end position of the qth frame to form a qth slice.
- the key frame information of the stream identifies the first key frame, and the second determining unit 503 determines that the start position of the first key frame is the start position of the first slice of the current original live broadcast source, and the third determining unit 504
- the starting position of the first key frame is 0s, and the position from the 0s position is searched to the time of 9s-11s.
- the second key frame is The start position is the end position of the first slice
- the first segmentation unit 505 performs segmentation at the start position and the end position of the first slice to form the first slice of the current original live broadcast source; meanwhile, the second The determining unit 503 determines that the starting position of the second key frame is the starting position of the second slice of the current original live broadcast source, and the third determining unit 504 searches for the second slice starting position as 0s, and then searches from the 0s position.
- the start position of the third key frame is taken as the end position of the second slice, and the first segmentation unit 505 performs segmentation at the start position and the end position of the second slice to form the current original live broadcast source.
- the second slice; and so on, the slice of the original live feed received each time.
- the beginning position of the qth key frame is determined to be the qth slice.
- the starting position determines that the starting position (the beginning position) of the q+1th key frame is the ending position of the qth slice.
- the server further includes:
- a third acquisition unit a first configuration unit, a fourth determination unit, and a second configuration unit (not illustrated in FIG. 5);
- the third obtaining unit is configured to obtain a program association table PAT and a program mapping table PMT from the current original live source stream;
- the first configuration unit is configured to configure PAT and PMT to an initial position of each slice to facilitate playing of the program content carried by the slice;
- the PAT table mainly includes a program channel number and a PID of the PMT corresponding to each channel, and a code; the PMT table includes PIDs of all video streams of each channel, PIDs of all audio streams, and other PIDs;
- the Video data can be filtered out from the channel through the PID of the Video; meanwhile, the PAT and the PMT periodically appear in the original live source stream to facilitate the terminal to request playback.
- the code stream of the played video can be accessed at any time during the video;
- the fourth determining unit configured to determine that the current original live broadcast source has at least two code rates, triggering the second configuration unit
- the second configuration unit is configured to configure the lengths of the program content carried by the slices of different code rates to be the same, so as to facilitate switching of different code rate slices.
- PAT and PMT are configured at the beginning of each slice, enabling independent playback of each TS slice.
- the original broadcast source stream is segmented by taking the position of the key frame as the segmentation position or the position of the q-th key frame starting position as the reference position, and ensuring the HLS slice length is
- the base time fluctuates around the reference time, so that the key frame is split into the same slice, which solves the problem that the data of the slice edge is incomplete or the data is redundant, thereby solving the sliced
- the live broadcast screen appears slower, and the live video between adjacent two slices has discontinuous problems, which improves the smoothness of live video playback, the quality of the playback picture, and improves the user viewing experience.
- the first obtaining unit 500, the first determining unit 501, the second obtaining unit 502, the second determining unit 503, the third determining unit 504, and the first splitting unit 505 may each be configured by a central processing unit (CPU). Central Processing Unit), or a digital signal processing (DSP), or a microprocessor (MPU, Micro Processor Unit), or a Field Programmable Gate Array (FPGA);
- CPU central processing unit
- DSP digital signal processing
- MPU Micro Processor Unit
- FPGA Field Programmable Gate Array
- the CPU, DSP, MPU, and FPGA can all be built into the node, specifically the server.
- embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
- the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
- the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
- These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
- the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
- An embodiment of the present invention provides a method, a server, and a computer storage medium for acquiring a live video slice, where the location of the key frame is a segmentation position, or the location of the q-th key frame starting position is a segmentation time.
- the location, the original live source stream is segmented, which can ensure that the HLS slice length fluctuates around the reference duration, so that the key frame is split into the same slice, which solves the problem that the slice edge has incomplete data or data redundancy, thereby solving the problem.
- the live broadcast screen of the slice appears slower, and there are problems such as discontinuity in the live video between the adjacent two slices, which improves the smoothness of the live video playback, the quality of the playback picture, and improves the user viewing experience.
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
Abstract
Description
本发明涉及直播视频流媒体技术,具体涉及一种获取直播视频切片的方法、服务器及计算机存储介质。The present invention relates to a live video streaming media technology, and in particular, to a method, a server and a computer storage medium for acquiring a live video slice.
HLS(HTTP Live Streaming)协议为基于超文本传输协议(HTTP,Hypertext Transfer Protocol)的动态码流自适应协议,是由苹果公司提出的一种流媒体传输协议。近年来,HLS协议在流媒体领域得到了广泛应用,主要由于其采用HTTP协议传输,可以根据网络带宽自适应地调整码率,如允许网络侧的服务器为同一节目内容存放多个不同码率的多媒体流,而终端可根据实际的网络下载速度自适应地调整所要下载的多媒体流的码率;在网络带宽紧张时,终端可通过降低码率实现不间断的播放。The HLS (HTTP Live Streaming) protocol is a dynamic code stream adaptation protocol based on the Hypertext Transfer Protocol (HTTP). It is a streaming media transmission protocol proposed by Apple. In recent years, the HLS protocol has been widely used in the field of streaming media, mainly because it uses HTTP protocol transmission, and can adaptively adjust the code rate according to the network bandwidth, such as allowing the server on the network side to store multiple different code rates for the same program content. The multimedia stream, and the terminal can adaptively adjust the code rate of the multimedia stream to be downloaded according to the actual network download speed; when the network bandwidth is tight, the terminal can achieve uninterrupted playback by reducing the code rate.
相对于其它常见的流媒体直播协议,例如路由选择表维护协议(RTMP,Routing Table Maintenance Protocol)、实时流传输协议(RTSP,Real Time Streaming Protocol)、微软媒体服务器协议(MMS,Microsoft Media Server Protocol)等,利用HLS协议对视频进行直播,最大的不同在于,终端获取到的多媒体数据并不是一个完整的数据流,而是一个个记录有数据的切片,这是因为:在HLS协议中,服务器端将直播数据流存储为连续的、很短时长的媒体文件(动态图像专家组MPEG-传输流TS格式),这些媒体文件就被称为切片,而客户端只需要不断的下载并播放这些切片,即可形成直播视频。其中,因为服务器端总是会将最新的直播数据生成新切片,客户端只需不停的按顺序播放从服务器获取到的切片,就实现了直播。Compared with other common live streaming protocols, such as the Routing Table Maintenance Protocol (RTMP), the Real Time Streaming Protocol (RTSP), and the Microsoft Media Server Protocol (MMS). Etc., using the HLS protocol to broadcast live video, the biggest difference is that the multimedia data acquired by the terminal is not a complete data stream, but a slice with data recorded, because: in the HLS protocol, the server side The live data stream is stored as a continuous, short-lived media file (Motion Picture Experts Group MPEG-Transport Stream TS format). These media files are called slices, and the client only needs to continuously download and play these slices. A live video can be formed. Among them, because the server always generates a new slice of the latest live data, the client only needs to continuously play the slice obtained from the server in order, and the live broadcast is realized.
目前可采用以下两种方式生成符合HLS协议的切片:一种方式是在多 媒体数据的转码过程中直接生成符合要求的切片;第二种方式是将转码与分片两个过程独立开来,先将直播数据进行转码,再对转码后的文件进行切片;其中,第一种方式要求转码器必须能够支持切片功能,对转码器的设计要求较高,不利于实现;第二种方式由于其将转码、分片独立开来,使得实现较为容易。所以,目前第二种生成切片的方法更受欢迎,但是其也存在以下问题:由于生成的切片长度固定,使得切片边缘可能会存在有不完整数据或者冗余数据,导致切片的直播画面出现较慢且相邻两切片之间的直播画面存在有不连续的情况,降低了用户观看体验。There are currently two ways to generate slices that conform to the HLS protocol: one way is more The transcoding process of the media data directly generates the slice that meets the requirement; the second method is to separate the transcoding and the fragmentation process separately, first transcoding the live data, and then slicing the transcoded file; Among them, the first method requires that the transcoder must be able to support the slicing function, which has high design requirements for the transcoder, which is not conducive to implementation; the second method is easier to implement because it converts the transcoding and fragmentation independently. . Therefore, the second method of generating slices is more popular, but it also has the following problems: due to the fixed length of the generated slice, there may be incomplete data or redundant data at the edge of the slice, resulting in a live view of the slice. There is a discontinuity in the live picture between the slow and adjacent two slices, which reduces the user's viewing experience.
发明内容Summary of the invention
为解决现有存在的技术问题,本发明实施例提供一种获取直播视频切片的方法、服务器及计算机存储介质,能够解决切片的直播画面出现较慢、相邻两切片之间的直播画面存在有不连续等情况,从而提高直播视频播放流畅性、播放画面质量,提升用户观看体验。In order to solve the existing technical problems, the embodiment of the present invention provides a method, a server, and a computer storage medium for acquiring a live video slice, which can solve the slow occurrence of the live broadcast picture of the slice, and the live picture between the adjacent two slices exists. Discontinuous conditions, etc., thereby improving the smoothness of live video playback, the quality of the playback picture, and improving the user viewing experience.
本发明实施例的技术方案是这样实现的:The technical solution of the embodiment of the present invention is implemented as follows:
本发明实施例提供了一种获取直播视频切片的方法,所述方法包括:An embodiment of the present invention provides a method for obtaining a live video slice, where the method includes:
获取切片的基准时长;Get the baseline duration of the slice;
确定基准时长与第一预设时长之和为第一时长,和/或确定基准时长与第一预设时长之差为第二时长;Determining a sum of a reference duration and a first preset duration as a first duration, and/or determining a difference between the reference duration and the first preset duration is a second duration;
获取当前原始直播源的第q个关键帧;Get the qth key frame of the current original live broadcast source;
确定第q个关键帧的起始位置为第q个切片的起始位置;Determining a starting position of the qth key frame as a starting position of the qth slice;
在第q个关键帧起始位置的第一时长和/或第二时长内,确定为存在有第q+1个关键帧时,确定所述第q+1个关键帧的起始位置为第q个切片的结束位置;Determining that the starting position of the q+1th key frame is the first time when the q+1th key frame exists in the first duration and/or the second duration of the start position of the qth key frame The end position of q slices;
在第q帧起始位置及结束位置处,对当前原始直播源进行切分,形成第q个切片;其中,q为正整数。 At the start position and the end position of the qth frame, the current original live broadcast source is segmented to form a qth slice; wherein q is a positive integer.
上述方案中,所述方法还包括:In the above solution, the method further includes:
在第q个关键帧起始位置的第一时长和/或第二时长内,确定为没有存在第q+1个关键帧时,将距离第q个关键帧起始位置为基准时长的位置为第q个切片的结束位置,在第q帧起始位置及结束位置处,对当前原始直播源进行切分,形成第q个切片。In the first duration and/or the second duration of the start position of the qth key frame, when it is determined that there is no q+1th key frame, the position from the start position of the qth key frame is the reference duration At the end position of the qth slice, at the start position and the end position of the qth frame, the current original live broadcast source is segmented to form a qth slice.
上述方案中,所述获取切片的基准时长,包括:In the above solution, the reference duration for obtaining the slice includes:
获取当前原始直播源的关键帧长度;Get the key frame length of the current original live broadcast source;
获取用于缓存当前原始直播源的视频缓存检验器VBV长度;Obtaining a video buffer checker VBV length for buffering the current original live broadcast source;
求取关键帧长度、VBV长度及第一预设阈值之和;Obtaining a sum of a key frame length, a VBV length, and a first preset threshold;
将所求取的和值作为切片的基准时长。The sum value obtained is taken as the reference duration of the slice.
上述方案中,在获取切片的基准时长之前,所述方法包括:In the above solution, before acquiring the reference duration of the slice, the method includes:
接收当前原始直播源;Receiving the current original live broadcast source;
转换当前原始直播源为实时传输协议RTP码流,并标识出所述RTP码流的关键帧信息;Converting the current original live broadcast source into a real-time transport protocol RTP stream, and identifying key frame information of the RTP stream;
对所述RTP码流进行缓存、排序、解析处理;Cache, sort, and parse the RTP stream;
删除经处理后的RTP码流中的RTP包头,形成RTP净载荷数据;Deleting the RTP header in the processed RTP stream to form RTP payload data;
在所述RTP净载荷数据中,依据关键帧信息,获取第q个关键帧。In the RTP payload data, the qth key frame is obtained according to the key frame information.
上述方案中,所述方法还包括:In the above solution, the method further includes:
从当前原始直播源中获取节目关联表PAT和节目映射表PMT,配置PAT和PMT至每个切片的初始位置,以方便切片所承载节目内容的播放;Obtaining the program association table PAT and the program mapping table PMT from the current original live broadcast source, and configuring the PAT and the PMT to the initial position of each slice to facilitate the playback of the program content carried by the slice;
当前原始直播源存在有至少两种码率时,配置不同码率的切片所承载的节目内容的长度为相同,以方便不同码率切片的切换。When there are at least two code rates in the current live broadcast source, the lengths of the program content carried by the slices configured with different code rates are the same, so as to facilitate the switching of different code rate slices.
本发明实施例还提供了一种服务器,所述服务器包括:The embodiment of the invention further provides a server, the server comprising:
第一获取单元,配置为获取切片的基准时长;a first obtaining unit configured to acquire a reference duration of the slice;
第一确定单元,配置为确定基准时长与第一预设时长之和为第一时长, 和/或确定基准时长与第一预设时长之差为第二时长;The first determining unit is configured to determine that the sum of the reference duration and the first preset duration is the first duration, And/or determining a difference between the reference duration and the first preset duration is a second duration;
第二获取单元,配置为获取当前原始直播源的第q个关键帧;a second acquiring unit, configured to acquire a qth key frame of the current original live broadcast source;
第二确定单元,配置为确定第q个关键帧的起始位置为第q个切片的起始位置;a second determining unit, configured to determine that a starting position of the qth key frame is a starting position of the qth slice;
第三确定单元,配置为在第q个关键帧起始位置的第一时长和/或第二时长内,确定为存在有第q+1个关键帧时,确定所述第q+1个关键帧的起始位置为第q个切片的结束位置;a third determining unit, configured to determine, when the q+1th key frame exists in the first duration and/or the second duration of the start position of the qth key frame, the q+1th key The starting position of the frame is the end position of the qth slice;
第一切分单元,配置为在第q帧起始位置及结束位置处,对当前原始直播源进行切分,形成第q个切片;其中,q为正整数。The first sub-unit is configured to split the current original live broadcast source at the start position and the end position of the q-th frame to form a q-th slice; wherein q is a positive integer.
上述方案中,In the above scheme,
所述第三确定单元,还配置为在第q个关键帧起始位置的第一时长和/或第二时长内,确定为没有存在第q+1个关键帧时,将距离第q个关键帧起始位置为基准时长的位置为第q个切片的结束位置;The third determining unit is further configured to determine that the qth key is the distance when there is no q+1th key frame in the first duration and/or the second duration of the qth key frame start position. The position where the frame start position is the reference duration is the end position of the qth slice;
相应的,所述第一切分单元,还配置为在第q帧起始位置及结束位置处,对当前原始直播源进行切分,形成第q个切片。Correspondingly, the first segmentation unit is further configured to slice the current original live broadcast source at the start position and the end position of the qth frame to form a qth slice.
上述方案中,所述第一获取单元,还配置为:In the foregoing solution, the first acquiring unit is further configured to:
获取当前原始直播源的关键帧长度;Get the key frame length of the current original live broadcast source;
获取用于缓存当前原始直播源的视频缓存检验器VBV长度;Obtaining a video buffer checker VBV length for buffering the current original live broadcast source;
求取关键帧长度、VBV长度及第一预设阈值之和;Obtaining a sum of a key frame length, a VBV length, and a first preset threshold;
将所求取的和值作为切片的基准时长。The sum value obtained is taken as the reference duration of the slice.
上述方案中,所述服务器还包括:In the above solution, the server further includes:
第一接收单元,配置为接收当前原始直播源;The first receiving unit is configured to receive the current original live broadcast source;
第一转换单元,配置为转换当前原始直播源为实时传输协议RTP码流,并标识出所述RTP码流的关键帧信息;The first converting unit is configured to convert the current original live broadcast source into a real-time transport protocol RTP stream, and identify key frame information of the RTP stream;
第一处理单元,配置为对所述RTP码流进行缓存、排序、解析处理; a first processing unit, configured to cache, sort, and parse the RTP stream;
第一删除单元,配置为删除经所述第一处理单元处理后的RTP码流中的RTP包头,形成RTP净载荷数据;a first deleting unit, configured to delete an RTP header in the RTP stream processed by the first processing unit to form RTP payload data;
相应的,corresponding,
所述第二获取单元,还配置为在所述RTP净载荷数据中,依据关键帧信息,获取第q个关键帧。The second acquiring unit is further configured to acquire, in the RTP payload data, the qth key frame according to the key frame information.
上述方案中,所述服务器还包括:In the above solution, the server further includes:
第三获取单元、第一配置单元、第四确定单元、第二配置单元;其中,a third obtaining unit, a first configuration unit, a fourth determining unit, and a second configuration unit; wherein
所述第三获取单元,配置为从当前原始直播源中获取节目关联表PAT和节目映射表PMT;The third obtaining unit is configured to obtain a program association table PAT and a program mapping table PMT from the current original live broadcast source;
所述第一配置单元,配置为配置PAT和PMT至每个切片的初始位置,以方便切片所承载节目内容的播放;The first configuration unit is configured to configure PAT and PMT to an initial position of each slice to facilitate playing of the program content carried by the slice;
所述第四确定单元,配置为确定出当前原始直播源存在有至少两种码率时,触发所述第二配置单元;The fourth determining unit, configured to determine that the current original live broadcast source has at least two code rates, triggering the second configuration unit;
所述第二配置单元,配置为配置不同码率的切片所承载的节目内容的长度为相同,以方便不同码率切片的切换。The second configuration unit is configured to configure the lengths of the program content carried by the slices of different code rates to be the same, so as to facilitate switching of different code rate slices.
本发明实施例还提供了一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行前述的获取直播视频切片的方法。The embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the foregoing method for obtaining a live video slice.
本发明实施例提供的获取直播视频切片的方法、服务器及计算机存储介质,所述方法包括:获取切片的基准时长;确定基准时长与第一预设时长之和为第一时长,和/或确定基准时长与第一预设时长之差为第二时长;获取当前原始直播源的第q个关键帧;确定第q个关键帧的起始位置为第q个切片的起始位置;在第q个关键帧起始位置的第一时长和/或第二时长内,确定为存在有第q+1个关键帧时,确定所述第q+1个关键帧的起始位置为第q个切片的结束位置;在第q帧起始位置及结束位置处,对当前原始直 播源进行切分,形成第q个切片;其中,q为正整数。利用本发明实施例的技术方案,可保证切片长度在基准时长左右波动,进而能够解决切片的直播画面出现较慢、相邻两切片之间的直播画面存在有不连续等情况,从而可提高直播视频播放流畅性、播放画面质量,提升用户观看体验。The method for obtaining a live video slice, the server, and the computer storage medium provided by the embodiment of the present invention include: obtaining a reference duration of the slice; determining a sum of the reference duration and the first preset duration as a first duration, and/or determining The difference between the reference duration and the first preset duration is the second duration; obtaining the qth key frame of the current original live broadcast source; determining the starting position of the qth keyframe as the starting position of the qth slice; Determining that the q+1th key frame is the qth slice when the q+1th key frame exists in the first duration and/or the second duration of the start position of the key frame End position; at the beginning and end of the qth frame, the current original straight The broadcast source performs segmentation to form a qth slice; wherein q is a positive integer. With the technical solution of the embodiment of the present invention, the slice length can be fluctuated around the reference duration, and the live broadcast picture of the slice can be slowed down, and the live picture between the adjacent two slices is discontinuous, thereby improving the live broadcast. The smoothness of video playback and the quality of the playback picture enhance the user's viewing experience.
图1为本发明实施例提供的获取直播视频切片的方法流程示意图;FIG. 1 is a schematic flowchart of a method for obtaining a live video slice according to an embodiment of the present invention;
图2为本发明实施例提供的应用场景一示意图;2 is a schematic diagram of an application scenario according to an embodiment of the present invention;
图3为本发明实施例提供的获取直播视频切片的方法的一具体实现流程示意图;FIG. 3 is a schematic diagram of a specific implementation process of a method for obtaining a live video slice according to an embodiment of the present disclosure;
图4为本发明实施例提供的应用场景二示意图;4 is a schematic diagram of an application scenario 2 according to an embodiment of the present invention;
图5为本发明实施例提供的服务器的组成示意图。FIG. 5 is a schematic structural diagram of a server according to an embodiment of the present invention.
以下结合附图对本发明的优选实施例进行详细说明,应当理解,以下所说明的优选实施例仅用于说明和解释本发明,并不用于限定本发明。The preferred embodiments of the present invention are described in detail below with reference to the accompanying drawings.
图1为本发明实施例提供的获取直播视频切片的方法流程示意图;如图1所示,所述方法包括:FIG. 1 is a schematic flowchart of a method for obtaining a live video slice according to an embodiment of the present invention; as shown in FIG. 1 , the method includes:
步骤11:获取切片的基准时长;Step 11: Obtain a reference duration of the slice;
这里,网络侧、具体是网络侧服务器接收原始直播源码流、如接收直播源MPEG系统发送来的MPEG-TS码流,因为原始直播源码流是直播源系统源源不断发送至服务器的,所以服务器对每次接收的原始直播源码流的处理均相同,请参见以下描述。Here, the network side, specifically the network side server receives the original live source stream, such as the MPEG-TS stream sent by the live broadcast source MPEG system, because the original live source stream is continuously sent to the server by the live source system, so the server pair The processing of the original live source stream received each time is the same, please see the description below.
服务器将MPEG-TS码流转换成实时传输协议(RTP,Real-time Transport Protocol)码流,并标识出RTP码流中的关键帧信息,对RTP码流进行缓存、排序、解析等处理;删除经上述处理后的RTP码流的RTP包头,得到 RTP净载荷数据;其中,所述关键帧信息包括:关键帧帧头、帧尾;获取RTP码流中的关键帧长度,以及用于缓存该码流的视频缓存检验器(VBV,Video Buffering Verifier)的长度,并将关键帧长度、VBV长度以及第一阈值三者求和,求和结果作为切片的基准时长,也就是说,如果关键帧长度为KP、VBV长度为V、第一阈值为A,那么切片的基准时长BS=KP+V+A。The server converts the MPEG-TS code stream into a Real-time Transport Protocol (RTP) code stream, and identifies key frame information in the RTP code stream, and performs processing such as buffering, sorting, and parsing the RTP stream; After the RTP header of the RTP stream processed as described above, RTP payload data; wherein the key frame information includes: a key frame header, a frame tail; a key frame length in the RTP stream, and a video buffer verifier for buffering the code stream (VBV, Video Buffering Verifier) The length of the key frame length, the VBV length, and the first threshold are summed, and the summation result is used as the reference duration of the slice, that is, if the key frame length is KP, the VBV length is V, and the first threshold is A, then the base time of the slice is BS=KP+V+A.
在对RTP码流进行缓存、排序、解析等处理的过程中,如果原始直播源码流已被加扰(去扰),本方案中还需要去扰(加扰);如果在后续切分成切片时还需要对切片加密,本方案中还需要进行加密处理,依据具体应用情况而处理。In the process of buffering, sorting, parsing, etc. of the RTP stream, if the original live source stream has been scrambled (descrambled), the scheme also needs to be scrambled (scrambled); if it is divided into slices later It is also necessary to encrypt the slice. In this solution, encryption processing is also required, which is processed according to the specific application.
其中,所述第一阈值A为预先设置的,可根据MPEG-TS码流的实际长度而自行设定,例如,可以预先设置A为1,也可以预先设置为2;所述基准时长、关键帧长度、V、A的单位均可以为秒s、或分min、或时hour等,通常取为秒。The first threshold A is preset, and may be set according to the actual length of the MPEG-TS code stream. For example, A may be set to 1 in advance, or may be set to 2 in advance; the reference duration and key are The unit of frame length, V, and A can be seconds s, minutes min, hour hours, etc., and is usually taken as seconds.
其中,所述关键帧也可以称之为I帧;在RTP码流中的标识出关键帧信息的目的在步骤13中说明。The key frame may also be referred to as an I frame; the purpose of identifying key frame information in the RTP code stream is illustrated in
步骤12:确定基准时长与第一预设时长之和为第一时长,和/或确定基准时长与第一预设时长之差为第二时长;Step 12: determining that the sum of the reference duration and the first preset duration is the first duration, and/or determining that the difference between the reference duration and the first preset duration is the second duration;
这里,所述第一预设时长根据实际应用情况而设置;以第一预设时长为时长B为例,计算基准时长BS与B之和,并将该两者之和作为第一时长;和/或,计算基准时长BS与B之差,将该两者之差作为第二时长。Here, the first preset duration is set according to the actual application situation; taking the first preset duration as the duration B as an example, calculating the sum of the reference durations BS and B, and taking the sum of the two as the first duration; / or, calculate the difference between the base duration BS and B, and use the difference between the two as the second duration.
步骤13:获取当前原始直播源的第q个关键帧;Step 13: Obtain the qth key frame of the current original live broadcast source.
这里,依据对RTP码流作出的关键帧信息,识别出第q个关键帧;其中,q为正整数。Here, based on the key frame information made to the RTP stream, the qth key frame is identified; wherein q is a positive integer.
步骤14:确定第q个关键帧的起始位置为第q个切片的起始位置; Step 14: determining that the starting position of the qth key frame is the starting position of the qth slice;
步骤15:在第q个关键帧起始位置的第一时长和/或第二时长内,确定为存在有第q+1个关键帧时,确定所述第q+1个关键帧的起始位置为第q个切片的结束位置;Step 15: Determine, in the first duration and/or the second duration of the start position of the qth key frame, that the q+1th key frame exists, determine the start of the q+1th key frame The position is the end position of the qth slice;
这里,在第q个关键帧起始位置的第一时长和/或第二时长内,查找是否存在有第q+1个关键帧,查找到时,确定所述第q+1个关键帧的起始位置为第q个切片的结束位置。Here, in the first duration and/or the second duration of the start position of the qth key frame, it is searched whether there is a q+1th key frame, and when found, the q+1th key frame is determined. The starting position is the end position of the qth slice.
步骤16:在第q帧起始位置及结束位置处,对当前原始直播源进行切分,形成第q个切片;其中,q为正整数。Step 16: At the start position and the end position of the qth frame, the current original live broadcast source is segmented to form a qth slice; wherein q is a positive integer.
这里,在第q个关键帧起始位置及结束位置处进行切分,形成第q个切片;也就是说,第q个切片的起始位置为第q个关键帧起始位置,第q个切片的结束位置为第q+1个关键帧起始位置。Here, the q-th slice is formed at the start position and the end position of the qth key frame to form a q-th slice; that is, the start position of the q-th slice is the q-th key frame start position, the qth The end position of the slice is the starting position of the q+1th key frame.
在一个实施例中,在第q个关键帧起始位置的第一时长和/或第二时长内,确定为没有存在第q+1个关键帧时,将距离第q个关键帧起始位置为基准时长的位置为第q个切片的结束位置,在第q帧起始位置及结束位置处,对当前原始直播源进行切分,形成第q个切片。In one embodiment, within the first duration and/or the second duration of the start position of the qth key frame, it is determined that the qth key frame start position is not present when the q+1th key frame is not present. The position of the reference duration is the end position of the qth slice, and at the start position and the end position of the qth frame, the current original live broadcast source is segmented to form a qth slice.
举个例子,以基准时长BS=10s、第一预设时长B=1s为例,第一时长为9s、第二时长为11s;在RTP净载荷数据中,依据对RTP码流作出的关键帧信息,识别出第1个关键帧,以第1个关键帧的起始位置为当前原始直播源的第1个切片的起始位置,以第1个关键帧起始位置为0s,从0s位置处查找至9s-11s时长处,在该9s-11s的时长内,确定存在有第2个关键帧时,将第2个关键帧的起始位置作为第1个切片的结束位置,在第1个切片的起始位置及结束位置处进行切分,形成当前原始直播源的第1个切片;同时,第2个关键帧的起始位置作为当前原始直播源的第2个切片的起始位置,以第2个切片起始位置为0s,从0s位置处再查找至9s-11s时长处,在该9s-11s的时长内,确定存在有第3个关键帧时,将第3个关键帧 的起始位置作为第2个切片的结束位置,在第2个切片的起始位置及结束位置处进行切分,形成当前原始直播源的第2个切片;以此类推,服务器对每次接收到的原始直播源进行切片的切分。也就是说,RTP净载荷数据中,第q个关键帧的起始位置(开头位置)为第q个切片的起始位置(开头位置),第q+1个关键帧的起始位置为第q个切片的结束位置。For example, the base duration BS=10s and the first preset duration B=1s are taken as an example, the first duration is 9s and the second duration is 11s; in the RTP payload data, according to the key frame made to the RTP stream The information identifies the first key frame, and the start position of the first key frame is the start position of the first slice of the current original live broadcast source, and the start position of the first key frame is 0s, from the 0s position. Find the time to 9s-11s. In the duration of the 9s-11s, when the second key frame is determined, the start position of the second key frame is taken as the end position of the first slice. The start position and the end position of the slice are segmented to form the first slice of the current original live broadcast source; meanwhile, the start position of the second key frame is used as the start position of the second slice of the current original live broadcast source. The starting position of the second slice is 0s, and then searching from the 0s position to the time of 9s-11s. During the duration of the 9s-11s, it is determined that there is a third key frame, and the third key frame is present. The starting position is used as the ending position of the second slice, and is segmented at the start position and the end position of the second slice to form a second slice of the current original live broadcast source; and so on, the server pairs each receive The original live source to the slice is sliced. That is to say, in the RTP payload data, the starting position (the beginning position) of the qth key frame is the starting position (the beginning position) of the qth slice, and the starting position of the q+1th key frame is the The end position of q slices.
由此可见,上述方案中,可将一个关键帧切分至同一个切片中去,本方案中,以关键帧所在位置为切分位置、或以距离第q个关键帧起始位置为基准时长的位置为切分位置,对原始直播源码流进行切分,能够保证HLS切片长度在基准时长左右波动,使得关键帧切分至同一个切片中,解决了切片边缘存在数据不完整或者数据冗余的现象,从而解决了切片的直播画面出现较慢、相邻两切片之间的直播画面存在有不连续等问题,提高了直播视频播放流畅性、播放画面质量,提升了用户观看体验。It can be seen that in the above solution, a key frame can be divided into the same slice. In this solution, the position of the key frame is the segmentation position, or the distance from the q-th key frame start position is used as the reference duration. The location is the segmentation location, and the original live source stream is segmented to ensure that the HLS slice length fluctuates around the reference duration, so that the key frames are sliced into the same slice, which solves the incomplete data or data redundancy of the slice edge. The phenomenon of the live broadcast of the slice is slow, and the live picture between the adjacent two slices is discontinuous, which improves the smoothness of the live video playback, the quality of the playback picture, and improves the user viewing experience.
在对原始直播源码流进行切片的切分时,被切分的切片还需要满足:When slicing the original live source stream, the sliced slice also needs to be satisfied:
1)从直播源码流中获取节目关联表(PAT,Program Association Table)和节目映射表(PMT,Program Map Table),并配置PAT和PMT在每个切片的初始位置,以方便切片所承载节目内容的播放;1) Obtain a program association table (PAT, Program Association Table) and a program map table (PMT) from the live source stream, and configure PAT and PMT at the initial position of each slice to facilitate slicing the program content carried. Play
其中,PAT表中主要包括节目频道号码和每一个频道对应的PMT的包识别码(PID,Packet Identifier)号码;PMT表中包括有各个频道的所有视频流Video数据的PID、所有音频流Audio数据的PID及其他PID;当终端请求播放当前频道的某个Video时,通过该Video的PID即可将该Video数据从该频道中筛选出来;同时,PAT和PMT在原始直播源码流中周期性出现,以方便终端在请求播放视频时可随时接入所述播放视频的码流;The PAT table mainly includes a program channel number and a packet identifier (PID, Packet Identifier) number of the PMT corresponding to each channel; the PMT table includes PIDs of all video streams of each channel, and audio data of all audio streams. The PID and other PIDs; when the terminal requests to play a certain video of the current channel, the Video data can be filtered from the channel through the PID of the Video; meanwhile, the PAT and the PMT periodically appear in the original live source stream. In order to facilitate the terminal to access the code stream of the played video at any time when requesting to play the video;
上述方案中,对于PAT和PMT的描述具体请参见现有相关说明,这里不再赘述。在本方案中,PAT和PMT配置在每个切片的开头位置,能够实现对每个切片的独立播放。 For the description of the PAT and the PMT, refer to the related descriptions, and no further details are provided here. In this scheme, PAT and PMT are configured at the beginning of each slice, enabling independent playback of each slice.
2)当确定出当前原始直播源存在有至少两种码率时,配置不同码率的切片所承载的节目内容的长度为相同,以方便不同码流切片的切换,也就是,为了方便直播视频在不同码率间的切换。2) When it is determined that there are at least two code rates in the current original live broadcast source, the lengths of the program content carried by the slices configured with different code rates are the same, so as to facilitate switching of different code stream slices, that is, in order to facilitate live video Switch between different code rates.
由于HLS协议中,每个切片(也可称为TS切片)均具有自身所支持的播放码率、序号标识、形成时间等信息,所以通过对索引文件(m3u8格式)的查找,可查找到具有同一个播放码率的所有切片,该切片按照切片序号的大小进行排序。Since the HLS protocol, each slice (also referred to as a TS slice) has its own supported play rate, sequence number, formation time, etc., so by looking up the index file (m3u8 format), it can be found All slices of the same play rate, the slices are sorted according to the size of the slice number.
例如,以原始直播源码流为单码率(1024kbps)为例,直播单码率文件包括:主索引文件、子索引文件及TS切片;其中,主索引文件命名为index.m3u8、子索引文件以码率命名为1024.m3u8(码率是1024kbps)、TS切片命名为$time-1024-$seq.ts;其中:$time表示切片的形成时间,1024表示切片码率是1024kbps,$seq表示切片的序号;播放码率相同的切片需要放在同一个子索引文件下。同时,子索引文件1024.m3u8的文件内容能够表征出其所能够索引到的所有切片的名称,例如,当配置子索引文件1024.m3u8最多可索引3个TS切片时,其可索引到命名为20140521160000-1024-1.ts的切片1、命名为20140521160000-1024-2.ts的切片2、及命名为20140521160000-1024-2.ts的切片3。原始直播源码流为多码率与上述原始直播源码流为单码率的描述相类似,只不过在多码率原始直播源码流中,子索引文件的个数等于原始直播源码流所采用的码率的个数。For example, taking the original live source stream as a single code rate (1024 kbps), the live single rate file includes: a main index file, a sub-index file, and a TS slice; wherein the main index file is named index.m3u8, and the sub-index file is The code rate is named 1024.m3u8 (the code rate is 1024 kbps), and the TS slice is named $time-1024-$seq.ts; where: $time indicates the slice formation time, 1024 indicates the slice rate is 1024 kbps, and $seq indicates the slice. The serial number; the slices with the same playback rate need to be placed under the same sub-index file. At the same time, the file content of the sub-index file 1024.m3u8 can represent the names of all the slices that it can index. For example, when the sub-index file 1024.m3u8 can be indexed by up to 3 TS slices, it can be indexed to Slice 1 of 20140521160000-1024-1.ts, slice 2 named 20140521160000-1024-2.ts, and slice 3 named 20140521160000-1024-2.ts. The original live source stream is multi-code rate similar to the description of the original live source stream as the single code rate, except that in the multi-rate original live source stream, the number of sub-index files is equal to the code used in the original live source stream. The number of rates.
由于本发明实施例涉及到的是直播多媒体码流,随着服务器对原始直播源码流的不断获取,对原始直播源码流的不断切分,新切片不断形成,所以需要主、子索引文件随着新切片的形成而不断发生更新,例如,1min内服务器可将原始直播源码流切分为6个TS切片,那么子索引文件每10s更新一次,更新为对6个最新TS切片的索引,并删除对之前6个TS切片 的索引,以适应HLS直播规范的要求;该过程可视为对切片的回滚过程。Since the embodiment of the present invention relates to a live multimedia code stream, as the server continuously acquires the original live source stream, the original live stream is continuously segmented, and new slices are continuously formed, so the main and sub index files are required to be The new slice is continuously updated. For example, within 1 min, the server can split the original live source stream into 6 TS slices, then the sub-index file is updated every 10s, updated to index the 6 latest TS slices, and deleted. For the previous 6 TS slices The index is adapted to the requirements of the HLS live specification; this process can be seen as a rollback process for slices.
上述方案中,对于切片的回滚,及通过对主、子索引文件查找到某个切片的具体过程请参见HLS协议的相关说明,这里不再赘述。In the above solution, for the specific rollback of the slice and the specific process of finding a slice for the primary and secondary index files, refer to the related description of the HLS protocol, and details are not described herein.
图2为本发明实施例的应用场景一示意图;图3为本发明实施例提供的获取直播视频切片的方法的一具体实现流程示意图;结合图2与图3,对本发明实施例作进一步描述。2 is a schematic diagram of an application scenario according to an embodiment of the present invention; FIG. 3 is a schematic flowchart of a specific implementation of a method for obtaining a live video slice according to an embodiment of the present invention; and FIG. 2 and FIG. 3 further describe an embodiment of the present invention.
在图2中,以服务器位于单节点、原始直播源码流为单码率、第一阈值为A=1s、第一预设时长B=1s、第一时长为9s、第二时长为11s为例:In FIG. 2, the server is located in a single node, the original live source stream is a single code rate, the first threshold is A=1s, the first preset duration B=1s, the first duration is 9s, and the second duration is 11s. :
步骤301:节点、具体是位于该节点的服务器接收MPEG系统发送来的原始直播源MPEG-TS码流;Step 301: The node, specifically the server located at the node, receives the original live broadcast source MPEG-TS code stream sent by the MPEG system;
其中,所述服务器支持码流的用户数据报协议(UDP,User Data Protocol)单播和UDP组播。The server supports a User Data Protocol (UDP) unicast and UDP multicast of a code stream.
步骤302:服务器将接收到的MPEG-TS码流转换成RTP码流;Step 302: The server converts the received MPEG-TS code stream into an RTP code stream.
这里,服务器将对MPEG-TS码流增加扩展的RTP包头,确定出VBV的长度、及码流的关键帧信息如关键帧帧头、帧尾、长度等;获取码流的PAT和PMT。Here, the server will add an extended RTP header to the MPEG-TS code stream, determine the length of the VBV, and the key frame information of the code stream such as the key frame header, the end of the frame, the length, etc.; obtain the PAT and PMT of the code stream.
步骤303:服务器对RTP码流进行缓存、排序、解析等处理,以方便后续终端的播放;Step 303: The server performs processing such as buffering, sorting, parsing, and the like on the RTP stream to facilitate playback of the subsequent terminal.
这里,在进行数据缓存、排序、解析等处理后,还可以对数据进行加扰、去扰、加密等处理,视具体应用情况而定。Here, after data caching, sorting, parsing, etc., the data may be scrambled, descrambled, encrypted, etc., depending on the specific application.
步骤304:求取基准时长BS;Step 304: Determine a reference duration BS;
这里,BS=关键帧长度KP+VBV长度V+1。Here, BS = key frame length KP + VBV length V + 1.
步骤305:去掉RTP码流的包头,得到RTP净载荷数据;Step 305: Remove the header of the RTP stream to obtain RTP payload data.
步骤306:在RTP净载荷数据中,获取当前原始直播源的第q个关键帧;确定第q个关键帧的起始位置为第q个切片的起始位置;在第q个关 键帧起始位置的第一时长和/或第二时长内,查找是否存在有第q+1个关键帧;Step 306: In the RTP payload data, obtain the qth key frame of the current original live broadcast source; determine the starting position of the qth key frame as the starting position of the qth slice; Finding whether there is a q+1th key frame in the first duration and/or the second duration of the start position of the key frame;
查找到时,执行步骤307;否则执行步骤308。When it is found, step 307 is performed; otherwise, step 308 is performed.
步骤307:确定所述第q+1个关键帧的起始位置为第q个切片的结束位置;在第q帧起始位置及结束位置处,对当前原始直播源进行切分,形成第q个切片,继续执行步骤309;Step 307: Determine the start position of the q+1th key frame as the end position of the qth slice; at the start position and the end position of the qth frame, segment the current original live broadcast source to form the qth Slice, continue to step 309;
这里,RTP净载荷数据中,第q个关键帧的开头位置为第q个切片的开头位置,第q+1个关键帧的开头位置为第q个切片的结束位置;具体如前所述,此处不再赘述。Here, in the RTP payload data, the beginning position of the qth key frame is the beginning position of the qth slice, and the beginning position of the q+1th key frame is the end position of the qth slice; I will not repeat them here.
步骤308:将距离第q个关键帧起始位置为基准时长的位置为第q个切片的结束位置,在第q帧起始位置及结束位置处,对当前原始直播源进行切分,形成第q个切片,继续执行步骤309;Step 308: The position at which the q-th key frame start position is the reference duration is the end position of the q-th slice, and at the start position and the end position of the q-th frame, the current original live broadcast source is segmented to form a first q slices, continue to step 309;
在一个实施例中,在将RTP净载荷数据切分为切片后,需要将码流的PAT和PMT配置在每个切片开头位置,以便能够实现每个切片的独立播放。In one embodiment, after the RTP payload data is sliced into slices, the PAT and PMT of the code stream need to be placed at the beginning of each slice so that independent playback of each slice can be achieved.
步骤309:服务器依据HLS协议,为形成的切片生成子索引文件;Step 309: The server generates a sub-index file for the formed slice according to the HLS protocol.
这里,由于原始直播源为单码率,所以子索引文件只有一个。Here, since the original live broadcast source is a single code rate, there is only one sub index file.
步骤310:服务器将形成的切片、切片的主索引文件、子索引文件刷新到磁盘,以供存储;Step 310: The server refreshes the formed slice, the sliced primary index file, and the sub-index file to the disk for storage.
这里,在接收到MPEG-TS码流时,服务器依据HLS协议生成主索引文件。Here, upon receiving the MPEG-TS code stream, the server generates a main index file in accordance with the HLS protocol.
步骤311:当终端上报有对频道A当前10s内的视频播放请求时,终端向节点中的下载服务器(DLS,Down Load Server)请求主索引文件;DLS读取磁盘中的频道A的主索引文件,并通过HTTP协议将文件内容发送至终端;终端向DLS请求子索引文件;DLS读取磁盘中的频道A的当前10s内视频所对应的子索引文件,并通过HTTP协议将文件内容发送至终端;终端向DLS请 求对应于该子索引文件的TS切片文件;DLS读取磁盘中的承载频道A的当前10s内视频的TS切片文件,并通过HTTP协议将文件内容发送至终端,终端播放该TS切片,以供用户观看。Step 311: When the terminal reports a video play request for the current 10s of the channel A, the terminal requests the main index file from the download server (DLS, Down Load Server) in the node; the DLS reads the main index file of the channel A in the disk. And sending the file content to the terminal through the HTTP protocol; the terminal requests the sub-index file from the DLS; the DLS reads the sub-index file corresponding to the video within the current 10s of the channel A in the disk, and sends the file content to the terminal through the HTTP protocol. ; terminal to DLS please Finding a TS slice file corresponding to the sub-index file; the DLS reads the TS slice file of the current 10s video carrying the channel A in the disk, and sends the file content to the terminal through the HTTP protocol, and the terminal plays the TS slice for the User watch.
图4为本发明实施例提供的应用场景二示意图;如图4所示,本方案中的服务器还可以应用于多节点的情况;其中,每个节点均可与终端相连接,以方便终端请求直播数据,每个节点均包括服务器、下载服务器DLS;进一步的,中心节点、具体是中心节点的服务器接收MPEG-TS码流,并将MPEG-TS码流传输至区域节点、具体是区域节点的服务器;区域节点的服务器将MPEG-TS码流传输至边缘节点;在位于三个节点中的相应服务器接收到直播源码流后,依据前述步骤302~步骤311进行处理,这里不再赘述。FIG. 4 is a schematic diagram of an application scenario 2 according to an embodiment of the present invention; as shown in FIG. 4, the server in the solution may also be applied to a multi-node scenario; wherein each node may be connected to the terminal to facilitate the terminal request. Live data, each node includes a server and a download server DLS; further, the central node, specifically the server of the central node receives the MPEG-TS code stream, and transmits the MPEG-TS code stream to the regional node, specifically the regional node The server of the area node transmits the MPEG-TS code stream to the edge node; after the corresponding server in the three nodes receives the live source source stream, the processing is performed according to the foregoing steps 302 to 311, and details are not described herein again.
本发明实施例还提供了一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于前述的获取直播视频切片的方法。The embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used in the foregoing method for obtaining a live video slice.
基于上述获取直播视频切片的方法,本发明实施例还提供了一种服务器,图5为本发明实施例提供的服务器的组成示意图;如图5所示,所述服务器包括:第一获取单元500、第一确定单元501、第二获取单元502、第二确定单元503、第三确定单元504、第一切分单元505;Based on the foregoing method for obtaining a live video slice, the embodiment of the present invention further provides a server, and FIG. 5 is a schematic diagram of a server according to an embodiment of the present invention; as shown in FIG. 5, the server includes: a first acquiring unit 500. a first determining unit 501, a second obtaining unit 502, a second determining unit 503, a third determining unit 504, and a first splitting unit 505;
所述服务器还包括第一接收单元、第一转换单元、第一处理单元及第一删除单元;其中,The server further includes a first receiving unit, a first converting unit, a first processing unit, and a first deleting unit; wherein
第一获取单元500,配置为获取切片的基准时长;The first obtaining unit 500 is configured to acquire a reference duration of the slice;
这里,所述服务器、具体是第一接收单元接收原始直播源码流如接收来自MPEG系统的MPEG-TS码流,将所接收到的MPEG-TS码流传输至第一转换单元;所述第一转换单元转换MPEG-TS码流为RTP码流,并标识出RTP码流中的关键帧信息;第一处理单元对RTP码流进行缓存、排序、解析等处理;第一删除单元删除经第一处理单元处理后的RTP码流中的 RTP包头,形成RTP净载荷数据;第一获取单元500获取RTP码流中的关键帧长度及VBV长度,并将关键帧长度、VBV长度以及第一阈值三者求和,求和结果作为切片的基准时长,也就是说,如果关键帧长度为KP、VBV长度为V、第一阈值为A,那么第一获取单元500确定出切片的基准时长BS=KP+V+A。其中,第一处理单元在对RTP码流进行缓存、排序、解析等处理的过程中,如果原始直播源码流已被加扰(去扰),本方案中第一处理单元还需要执行去扰(加扰)操作;如果在后续切分成切片时还需要对切片加密,第一处理单元还需要进行加密处理。Here, the server, specifically the first receiving unit, receives the original live source stream, such as receiving an MPEG-TS stream from the MPEG system, and transmits the received MPEG-TS stream to the first converting unit; The converting unit converts the MPEG-TS code stream into an RTP code stream, and identifies key frame information in the RTP code stream; the first processing unit buffers, sorts, parses, etc. the RTP code stream; the first deleting unit deletes the first frame Processing unit processing RTP code stream The RTP packet header forms the RTP payload data; the first obtaining unit 500 obtains the key frame length and the VBV length in the RTP code stream, and sums the key frame length, the VBV length, and the first threshold, and the summation result is used as a slice. The reference duration, that is, if the key frame length is KP, the VBV length is V, and the first threshold is A, the first obtaining unit 500 determines the reference duration of the slice BS=KP+V+A. The first processing unit in the process of buffering, sorting, parsing, etc. processing the RTP stream, if the original live source stream has been scrambled (descrambled), the first processing unit in the solution needs to perform descrambling ( Scrambling) operation; if the slice needs to be encrypted when it is subsequently divided into slices, the first processing unit also needs to perform encryption processing.
第一确定单元501,配置为确定基准时长与第一预设时长之和为第一时长,和/或确定基准时长与第一预设时长之差为第二时长;The first determining unit 501 is configured to determine that the sum of the reference duration and the first preset duration is a first duration, and/or determine that the difference between the reference duration and the first preset duration is a second duration;
这里,以第一预设时长为时长B为例,第一确定单元501计算基准时长BS与B之和,并将该两者之和作为第一时长;和/或,计算基准时长BS与B之差,将该两者之差作为第二时长。Here, taking the first preset duration as the duration B, the first determining unit 501 calculates the sum of the reference durations BS and B, and uses the sum of the two as the first duration; and/or calculates the reference durations BS and B. The difference between the two is taken as the second duration.
第二获取单元502,配置为获取当前原始直播源的第q个关键帧;The second obtaining unit 502 is configured to acquire the qth key frame of the current original live broadcast source;
这里,第二获取单元502在RTP净载荷数据中,依据关键帧信息,识别出第q个关键帧。Here, the second obtaining unit 502 identifies the qth key frame according to the key frame information in the RTP payload data.
第二确定单元503,配置为确定第q个关键帧的起始位置为第q个切片的起始位置;a second determining unit 503, configured to determine that a starting position of the qth key frame is a starting position of the qth slice;
第三确定单元504,配置为在第q个关键帧起始位置的第一时长和/或第二时长内,确定为存在有第q+1个关键帧时,确定所述第q+1个关键帧的起始位置为第q个切片的结束位置;The third determining unit 504 is configured to determine, when the q+1th key frame exists in the first duration and/or the second duration of the qth key frame start position, the q+1th The starting position of the key frame is the end position of the qth slice;
这里,第三确定单元504在第q个关键帧起始位置的第一时长和/或第二时长内,查找是否存在有第q+1个关键帧,查找到时,确定所述第q+1个关键帧的起始位置为第q个切片的结束位置。Here, the third determining unit 504 searches for the q+1th key frame in the first duration and/or the second duration of the qth key frame start position, and when found, determines the q+th The starting position of one key frame is the end position of the qth slice.
第一切分单元505,配置为在第q帧起始位置及结束位置处,对当前 原始直播源进行切分,形成第q个切片;其中,q为正整数。The first unit 505 is configured to be at the start position and the end position of the qth frame, for the current The original live broadcast source is segmented to form a qth slice; wherein q is a positive integer.
这里,第一切分单元505在第q个关键帧起始位置及结束位置处进行切分,形成第q个切片;也就是说,第q个切片的起始位置为第q个关键帧起始位置,第q个切片的结束位置为第q+1个关键帧起始位置。Here, the first slicing unit 505 performs segmentation at the qth key frame start position and end position to form a qth slice; that is, the qth slice starts from the qth key frame. The starting position, the end position of the qth slice is the q+1th key frame starting position.
所述第三确定单元504,还配置为在第q个关键帧起始位置的第一时长和/或第二时长内,确定为没有存在第q+1个关键帧时,将距离第q个关键帧起始位置为基准时长的位置为第q个切片的结束位置;The third determining unit 504 is further configured to: when the q+1th key frame is not present, the qth distance is determined in the first duration and/or the second duration of the qth key frame start position. The position where the key frame start position is the reference duration is the end position of the qth slice;
相应的,所述第一切分单元505,还配置为在第q帧起始位置及结束位置处,对当前原始直播源进行切分,形成第q个切片。Correspondingly, the first segmentation unit 505 is further configured to segment the current original live broadcast source at the start position and the end position of the qth frame to form a qth slice.
举个例子,以基准时长BS=10s、第一预设时长B=1s为例,第一时长为9s、第二时长为11s;在RTP净载荷数据中,第二获取单元502依据对RTP码流作出的关键帧信息,识别出第1个关键帧,第二确定单元503确定第1个关键帧的起始位置为当前原始直播源的第1个切片的起始位置,第三确定单元504以第1个关键帧起始位置为0s,从0s位置处查找至9s-11s时长处,在该9s-11s的时长内,确定存在有第2个关键帧时,将第2个关键帧的起始位置作为第1个切片的结束位置,第一切分单元505在第1个切片的起始位置及结束位置处进行切分,形成当前原始直播源的第1个切片;同时,第二确定单元503确定第2个关键帧的起始位置为当前原始直播源的第2个切片的起始位置,第三确定单元504以第2个切片起始位置为0s,从0s位置处再查找至9s-11s时长处,在该9s-11s的时长内,确定存在有第3个关键帧时,将第3个关键帧的起始位置作为第2个切片的结束位置,第一切分单元505在第2个切片的起始位置及结束位置处进行切分,形成当前原始直播源的第2个切片;以此类推,对每次接收到的原始直播源进行切片的切分。For example, the base duration BS=10s and the first preset duration B=1s are taken as an example, the first duration is 9s and the second duration is 11s; in the RTP payload data, the second obtaining unit 502 is based on the RTP code. The key frame information of the stream identifies the first key frame, and the second determining unit 503 determines that the start position of the first key frame is the start position of the first slice of the current original live broadcast source, and the third determining unit 504 The starting position of the first key frame is 0s, and the position from the 0s position is searched to the time of 9s-11s. During the period of 9s-11s, it is determined that there is a second key frame, and the second key frame is The start position is the end position of the first slice, and the first segmentation unit 505 performs segmentation at the start position and the end position of the first slice to form the first slice of the current original live broadcast source; meanwhile, the second The determining unit 503 determines that the starting position of the second key frame is the starting position of the second slice of the current original live broadcast source, and the third determining unit 504 searches for the second slice starting position as 0s, and then searches from the 0s position. Up to the 9s-11s duration, within the duration of the 9s-11s, it is determined that there is a third key In the frame, the start position of the third key frame is taken as the end position of the second slice, and the first segmentation unit 505 performs segmentation at the start position and the end position of the second slice to form the current original live broadcast source. The second slice; and so on, the slice of the original live feed received each time.
由此可见,上述方案中,确定第q个关键帧的开头位置为第q个切片 的起始位置(开头位置),确定第q+1个关键帧的起始位置(开头位置)为第q个切片的结束位置。It can be seen that in the above solution, the beginning position of the qth key frame is determined to be the qth slice. The starting position (the beginning position) determines that the starting position (the beginning position) of the q+1th key frame is the ending position of the qth slice.
所述服务器还包括:The server further includes:
第三获取单元、第一配置单元、第四确定单元、第二配置单元(图5中均未示意出);其中,a third acquisition unit, a first configuration unit, a fourth determination unit, and a second configuration unit (not illustrated in FIG. 5);
所述第三获取单元,配置为从当前原始直播源码流中获取节目关联表PAT和节目映射表PMT;The third obtaining unit is configured to obtain a program association table PAT and a program mapping table PMT from the current original live source stream;
所述第一配置单元,配置为配置PAT和PMT至每个切片的初始位置,以方便切片所承载节目内容的播放;The first configuration unit is configured to configure PAT and PMT to an initial position of each slice to facilitate playing of the program content carried by the slice;
其中,PAT表中主要包括节目频道号码和每一个频道对应的PMT的PID,码;PMT表中包括有各个频道的所有视频流Video数据的PID、所有音频流Audio数据的PID及其他PID;当终端请求播放当前频道的某个Video时,通过该Video的PID即可将该Video数据从该频道中筛选出来;同时,PAT和PMT在原始直播源码流中周期性出现,以方便终端在请求播放视频时可随时接入所述播放视频的码流;The PAT table mainly includes a program channel number and a PID of the PMT corresponding to each channel, and a code; the PMT table includes PIDs of all video streams of each channel, PIDs of all audio streams, and other PIDs; When the terminal requests to play a certain video of the current channel, the Video data can be filtered out from the channel through the PID of the Video; meanwhile, the PAT and the PMT periodically appear in the original live source stream to facilitate the terminal to request playback. The code stream of the played video can be accessed at any time during the video;
所述第四确定单元,配置为确定出当前原始直播源存在有至少两种码率时,触发所述第二配置单元;The fourth determining unit, configured to determine that the current original live broadcast source has at least two code rates, triggering the second configuration unit;
所述第二配置单元,配置为配置不同码率的切片所承载的节目内容的长度为相同,以方便不同码率切片的切换。The second configuration unit is configured to configure the lengths of the program content carried by the slices of different code rates to be the same, so as to facilitate switching of different code rate slices.
在本方案中,PAT和PMT配置在每个切片的开头位置,能够实现对每个TS切片的独立播放。In this scheme, PAT and PMT are configured at the beginning of each slice, enabling independent playback of each TS slice.
上述方案中,以关键帧所在位置为切分位置、或以距离第q个关键帧起始位置为基准时长的位置为切分位置,对原始直播源码流进行切分,够保证HLS切片长度在基准时长左右波动,使得关键帧切分至同一个切片中,解决了切片边缘存在数据不完整或者数据冗余的现象,从而解决了切片的 直播画面出现较慢、相邻两切片之间的直播画面存在有不连续等问题,提高了直播视频播放流畅性、播放画面质量,提升了用户观看体验。In the above scheme, the original broadcast source stream is segmented by taking the position of the key frame as the segmentation position or the position of the q-th key frame starting position as the reference position, and ensuring the HLS slice length is The base time fluctuates around the reference time, so that the key frame is split into the same slice, which solves the problem that the data of the slice edge is incomplete or the data is redundant, thereby solving the sliced The live broadcast screen appears slower, and the live video between adjacent two slices has discontinuous problems, which improves the smoothness of live video playback, the quality of the playback picture, and improves the user viewing experience.
本领域技术人员应当理解,图5中所示的服务器中的各处理单元的实现功能可参照前述获取直播视频切片的方法的相关描述而理解。本领域技术人员应当理解,图5所示的服务器中各处理单元的功能可通过运行于处理器上的程序而实现,也可通过具体的逻辑电路而实现。Those skilled in the art should understand that the implementation functions of the processing units in the server shown in FIG. 5 can be understood by referring to the related description of the foregoing method for obtaining live video slices. Those skilled in the art should understand that the functions of the processing units in the server shown in FIG. 5 can be implemented by a program running on the processor, or can be implemented by a specific logic circuit.
在实际应用中,所述第一获取单元500、第一确定单元501、第二获取单元502、第二确定单元503、第三确定单元504、第一切分单元505均可由中央处理单元(CPU,Central Processing Unit)、或数字信号处理(DSP,Digital Signal Processor)、或微处理器(MPU,Micro Processor Unit)、或现场可编程门阵列(FPGA,Field Programmable Gate Array)等来实现;所述CPU、DSP、MPU、FPGA均可内置于节点中、具体是服务器中。In a practical application, the first obtaining unit 500, the first determining unit 501, the second obtaining unit 502, the second determining unit 503, the third determining unit 504, and the first splitting unit 505 may each be configured by a central processing unit (CPU). Central Processing Unit), or a digital signal processing (DSP), or a microprocessor (MPU, Micro Processor Unit), or a Field Programmable Gate Array (FPGA); The CPU, DSP, MPU, and FPGA can all be built into the node, specifically the server.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。 The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。The above is only the preferred embodiment of the present invention and is not intended to limit the scope of the present invention.
本发明实施例提供了一种获取直播视频切片的方法、服务器及计算机存储介质,以关键帧所在位置为切分位置、或以距离第q个关键帧起始位置为基准时长的位置为切分位置,对原始直播源码流进行切分,能够保证HLS切片长度在基准时长左右波动,使得关键帧切分至同一个切片中,解决了切片边缘存在数据不完整或者数据冗余的现象,从而解决了切片的直播画面出现较慢、相邻两切片之间的直播画面存在有不连续等问题,提高了直播视频播放流畅性、播放画面质量,提升了用户观看体验。 An embodiment of the present invention provides a method, a server, and a computer storage medium for acquiring a live video slice, where the location of the key frame is a segmentation position, or the location of the q-th key frame starting position is a segmentation time. The location, the original live source stream is segmented, which can ensure that the HLS slice length fluctuates around the reference duration, so that the key frame is split into the same slice, which solves the problem that the slice edge has incomplete data or data redundancy, thereby solving the problem. The live broadcast screen of the slice appears slower, and there are problems such as discontinuity in the live video between the adjacent two slices, which improves the smoothness of the live video playback, the quality of the playback picture, and improves the user viewing experience.
Claims (11)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201410351477.4A CN105282627B (en) | 2014-07-22 | 2014-07-22 | A kind of method and server obtaining live video slice |
| CN201410351477.4 | 2014-07-22 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2016011823A1 true WO2016011823A1 (en) | 2016-01-28 |
Family
ID=55150816
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2015/074766 Ceased WO2016011823A1 (en) | 2014-07-22 | 2015-03-20 | Method for acquiring live video slice, server, and storage medium |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN105282627B (en) |
| WO (1) | WO2016011823A1 (en) |
Cited By (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107968948A (en) * | 2016-10-19 | 2018-04-27 | 北京新唐思创教育科技有限公司 | Online video playing method and system |
| CN114979721A (en) * | 2022-05-18 | 2022-08-30 | 咪咕文化科技有限公司 | Video slicing method, apparatus, equipment and storage medium |
| CN115119009A (en) * | 2022-06-29 | 2022-09-27 | 北京奇艺世纪科技有限公司 | Video alignment method, video encoding device and storage medium |
| CN115134622A (en) * | 2022-06-29 | 2022-09-30 | 北京奇艺世纪科技有限公司 | Video data alignment method, device, equipment and storage medium |
| CN115174578A (en) * | 2022-07-25 | 2022-10-11 | 上海网达软件股份有限公司 | Kubernetes-based on-demand parallel transcoding method and device and storage medium |
| CN116828229A (en) * | 2023-08-30 | 2023-09-29 | 湖南马栏山视频先进技术研究院有限公司 | A transmission method and system for audio and video streams |
| CN117156172A (en) * | 2023-10-30 | 2023-12-01 | 江西云眼视界科技股份有限公司 | Video slice reporting method, system, storage medium and computer |
| WO2024046124A1 (en) * | 2022-08-29 | 2024-03-07 | 抖音视界有限公司 | Video processing method and apparatus, and server |
Families Citing this family (16)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105763960B (en) * | 2016-03-01 | 2019-01-01 | 聚好看科技股份有限公司 | A kind of method and apparatus that network video plays |
| CN107659538A (en) * | 2016-07-25 | 2018-02-02 | 北京优朋普乐科技有限公司 | A kind of method and apparatus of Video processing |
| CN106303671B (en) * | 2016-08-16 | 2019-04-16 | 任晋军 | A kind of playback method of Streaming Media |
| CN106330922B (en) * | 2016-08-26 | 2019-08-27 | 天脉聚源(北京)教育科技有限公司 | A kind of video fragment naming method and device |
| CN106657123A (en) * | 2016-12-30 | 2017-05-10 | 杭州当虹科技有限公司 | Live broadcast time shifting scheme based on hls protocol |
| CN107579920B (en) * | 2017-09-25 | 2021-06-01 | 盛科网络(苏州)有限公司 | Data stream transmission method and device, storage medium and processor |
| CN109218745B (en) * | 2018-10-31 | 2021-07-23 | 网宿科技股份有限公司 | A live broadcast method, server, client and readable storage medium |
| CN109348292B (en) * | 2018-11-20 | 2021-05-04 | 广州易方信息科技股份有限公司 | Video slicing method based on byte threshold of slice file |
| CN109525893A (en) * | 2018-11-20 | 2019-03-26 | 广州易方信息科技股份有限公司 | Video segment method based on slice file duration threshold value |
| CN109525901B (en) * | 2018-11-27 | 2020-08-25 | Oppo广东移动通信有限公司 | Video processing method, apparatus, electronic device and computer readable medium |
| CN110087142B (en) * | 2019-04-16 | 2022-01-25 | 咪咕文化科技有限公司 | Video slicing method, device, terminal and storage medium |
| CN110996129A (en) * | 2019-12-20 | 2020-04-10 | 杭州当虹科技股份有限公司 | Method for supporting MPEG-DASH output slice number continuity |
| CN113259694A (en) * | 2021-04-22 | 2021-08-13 | 北京金山云网络技术有限公司 | Data slicing method and device and electronic equipment |
| CN114339291B (en) * | 2021-12-31 | 2024-05-28 | 杭州当虹科技股份有限公司 | Method for zooming and playing streaming video |
| CN115550746B (en) * | 2022-10-11 | 2024-09-10 | 杭州视洞科技有限公司 | HLS low-delay method based on network camera |
| CN115761583B (en) * | 2022-11-18 | 2025-07-15 | 北京百度网讯科技有限公司 | Live video processing method and device |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101645927A (en) * | 2009-09-02 | 2010-02-10 | 中兴通讯股份有限公司 | System, method and server for slicing media files |
| CN103037203A (en) * | 2012-12-11 | 2013-04-10 | 浙江宇视科技有限公司 | Method and device for index recovery based on block storage |
| CN103442259A (en) * | 2013-08-21 | 2013-12-11 | 杭州浦禾通信技术有限公司 | Method and device for reconstructing media data |
| CN103873956A (en) * | 2012-12-12 | 2014-06-18 | 中国电信股份有限公司 | Media file playing method and system, player, terminal and media storage platform |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102932670B (en) * | 2012-11-29 | 2015-09-02 | 百视通网络电视技术发展有限责任公司 | A kind of Streaming Media dicing method and system |
-
2014
- 2014-07-22 CN CN201410351477.4A patent/CN105282627B/en active Active
-
2015
- 2015-03-20 WO PCT/CN2015/074766 patent/WO2016011823A1/en not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101645927A (en) * | 2009-09-02 | 2010-02-10 | 中兴通讯股份有限公司 | System, method and server for slicing media files |
| CN103037203A (en) * | 2012-12-11 | 2013-04-10 | 浙江宇视科技有限公司 | Method and device for index recovery based on block storage |
| CN103873956A (en) * | 2012-12-12 | 2014-06-18 | 中国电信股份有限公司 | Media file playing method and system, player, terminal and media storage platform |
| CN103442259A (en) * | 2013-08-21 | 2013-12-11 | 杭州浦禾通信技术有限公司 | Method and device for reconstructing media data |
Cited By (15)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107968948A (en) * | 2016-10-19 | 2018-04-27 | 北京新唐思创教育科技有限公司 | Online video playing method and system |
| CN114979721A (en) * | 2022-05-18 | 2022-08-30 | 咪咕文化科技有限公司 | Video slicing method, apparatus, equipment and storage medium |
| CN114979721B (en) * | 2022-05-18 | 2024-02-23 | 咪咕文化科技有限公司 | Video slicing method, device, equipment and storage medium |
| CN115119009B (en) * | 2022-06-29 | 2023-09-01 | 北京奇艺世纪科技有限公司 | Video alignment method, video encoding device and storage medium |
| CN115134622B (en) * | 2022-06-29 | 2023-09-01 | 北京奇艺世纪科技有限公司 | Video data alignment method, device, equipment and storage medium |
| CN115134622A (en) * | 2022-06-29 | 2022-09-30 | 北京奇艺世纪科技有限公司 | Video data alignment method, device, equipment and storage medium |
| CN115119009A (en) * | 2022-06-29 | 2022-09-27 | 北京奇艺世纪科技有限公司 | Video alignment method, video encoding device and storage medium |
| CN115174578A (en) * | 2022-07-25 | 2022-10-11 | 上海网达软件股份有限公司 | Kubernetes-based on-demand parallel transcoding method and device and storage medium |
| CN115174578B (en) * | 2022-07-25 | 2023-10-20 | 上海网达软件股份有限公司 | Kubernetes-based on-demand parallel transcoding method, device and storage medium |
| WO2024046124A1 (en) * | 2022-08-29 | 2024-03-07 | 抖音视界有限公司 | Video processing method and apparatus, and server |
| CN117676273A (en) * | 2022-08-29 | 2024-03-08 | 抖音视界有限公司 | Video processing method, device and server |
| CN116828229A (en) * | 2023-08-30 | 2023-09-29 | 湖南马栏山视频先进技术研究院有限公司 | A transmission method and system for audio and video streams |
| CN116828229B (en) * | 2023-08-30 | 2023-11-24 | 湖南马栏山视频先进技术研究院有限公司 | Transmission method and system for audio and video streams |
| CN117156172A (en) * | 2023-10-30 | 2023-12-01 | 江西云眼视界科技股份有限公司 | Video slice reporting method, system, storage medium and computer |
| CN117156172B (en) * | 2023-10-30 | 2024-01-16 | 江西云眼视界科技股份有限公司 | Video slice reporting method, system, storage medium and computer |
Also Published As
| Publication number | Publication date |
|---|---|
| CN105282627A (en) | 2016-01-27 |
| CN105282627B (en) | 2019-09-10 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2016011823A1 (en) | Method for acquiring live video slice, server, and storage medium | |
| JP7036962B2 (en) | Playback method and playback device | |
| US12052462B2 (en) | Fast tune-in for low latency streaming | |
| TWI623226B (en) | Directory limit based system and method for storing media segments | |
| CN104683884B (en) | A kind of stream media live broadcasting method and system | |
| CN102238419B (en) | Method and apparatus for playing live content | |
| CN102713883B (en) | Audio splitting with codec-enforced frame size | |
| KR102301333B1 (en) | Method and apparatus for streaming dash content over broadcast channels | |
| WO2012096372A1 (en) | Content reproduction device, content reproduction method, delivery system, content reproduction program, recording medium, and data structure | |
| JP2016538754A (en) | Method and apparatus for content distribution | |
| US10887646B2 (en) | Live streaming with multiple remote commentators | |
| WO2017101369A1 (en) | Live video transcoding method and apparatus | |
| WO2013152689A1 (en) | Background control method and system for video playing | |
| CN109587514B (en) | A video playback method, medium and related device | |
| JP2017529726A (en) | Client and server operating method for streaming service | |
| CN116346794B (en) | Methods and apparatus for receiving media data and non-volatile computer-readable storage media | |
| WO2018103696A1 (en) | Media file playback method, server, client, and system | |
| CN109151491B (en) | Data distribution system, method and computer-readable storage medium | |
| WO2015192683A1 (en) | Content distribution method, device and system based on adaptive streaming technology | |
| US20180191803A1 (en) | Low latency media streaming | |
| KR101743228B1 (en) | Streaming apparatus and method thereof, streaming service system using the streaming apparatus and computer readable recording medium | |
| WO2013185514A1 (en) | System and method for playing streaming media | |
| CN105049873B (en) | A kind of flow-medium transmission method, device and system | |
| CN106658226A (en) | Play method and apparatus | |
| KR102137858B1 (en) | Transmission device, transmission method, reception device, reception method, and program |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 15824255 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 15824255 Country of ref document: EP Kind code of ref document: A1 |