WO2017035783A1 - Streaming media transmission and play method, and transmission and play device - Google Patents

Streaming media transmission and play method, and transmission and play device Download PDF

Info

Publication number
WO2017035783A1
WO2017035783A1 PCT/CN2015/088762 CN2015088762W WO2017035783A1 WO 2017035783 A1 WO2017035783 A1 WO 2017035783A1 CN 2015088762 W CN2015088762 W CN 2015088762W WO 2017035783 A1 WO2017035783 A1 WO 2017035783A1
Authority
WO
WIPO (PCT)
Prior art keywords
streaming media
fragment
file
media data
cdn
Prior art date
Application number
PCT/CN2015/088762
Other languages
French (fr)
Chinese (zh)
Inventor
严映军
周逻理
Original Assignee
深圳好视网络科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳好视网络科技有限公司 filed Critical 深圳好视网络科技有限公司
Priority to PCT/CN2015/088762 priority Critical patent/WO2017035783A1/en
Publication of WO2017035783A1 publication Critical patent/WO2017035783A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/83Generation or processing of protective or descriptive data associated with content; Content structuring
    • H04N21/845Structuring of content, e.g. decomposing content into time segments

Definitions

  • the invention belongs to the field of network technologies, and particularly relates to a method for transmitting and playing a streaming medium, and a transmission and playback device.
  • HLS HTTP Live Streaming
  • the device provides audio and video live and on-demand programs.
  • the biggest feature of the HLS protocol is that the client does not get a complete data stream, HLS.
  • the protocol stores the streaming media file on the server side as multiple consecutive, very short TS fragment files, and then creates a m3u8 corresponding to these TS fragment files.
  • the index file is based on the fragmented transmission of the streaming media file, so that the streaming media is played on the client.
  • CDN content distribution network
  • the prior art introduces a content distribution network (Content Delivery) in the streaming media playback system.
  • Network , CDN Network
  • CDN content distribution network
  • the purpose of which is to distribute streaming media data to the network 'edge' closest to the client by adding a new layer of network architecture to the existing network. So that the client can obtain the required content in the vicinity, solve the network congestion situation, and improve the response speed of the client to obtain streaming media data.
  • CDN In order to give users a smooth viewing experience, CDN
  • the adoption of technology requires a large amount of server resources to be laid out on the Internet, which greatly increases the system cost of the streaming media playback system.
  • the purpose of the embodiments of the present invention is to provide a streaming media transmission and playing method, and a transmission and playback device to alleviate the complete dependence on the CDN.
  • the server layout pressure brought by streaming media transmission and playback reduces the system cost of the streaming media playback system.
  • the embodiment of the present invention is implemented by the method for transmitting a streaming media, including:
  • Another object of the embodiments of the present invention is to provide a streaming media transmission apparatus, including:
  • a first dividing unit configured to cut the streaming media data into a plurality of first fragment files according to the HLS protocol, and generate the streaming media data M3u8 index file;
  • a second dividing unit configured to cut the streaming media data into a plurality of second fragment files according to a P2P protocol
  • An information adding unit for the m3u8 Adding association information in the index file, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file;
  • a sending unit configured to deliver the first fragment file and the m3u8 index file to a content distribution network CDN And sending the second fragment file to the P2P network, so that the streaming media client obtains the streaming media data from the CDN and the P2P network and plays the data.
  • the streaming media data is simultaneously laid out in the CDN and the P2P network, and the HLS protocol is utilized.
  • the m3u8 index file is used to establish an association relationship between the fragmented files of the streaming media data in the two networks, so as to simultaneously rely on the two networks to deliver streaming media data to the streaming media playback client, thereby effectively reducing the CDN.
  • the server pressure saves the server cost of the streaming system.
  • Another object of the embodiments of the present invention is to provide a method for playing a streaming media, including:
  • the m3u8 of the streaming media data returned by the CDN And a first fragment file of the streaming media data in the index file and the preset playing duration, where the first fragment file is a fragment file obtained by cutting the streaming media data according to the HLS protocol, the m3u8
  • the index file is added with association information, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file, the second Fragment file based a slice file obtained by cutting the streaming media data by the P2P protocol;
  • the received first fragment file and the second fragment file are sequentially played.
  • Another object of the present invention is to provide a streaming media playback device, including:
  • a detecting unit configured to detect a playlist, and determine a program to be played
  • a first sending unit configured to send, to the content distribution network CDN, a first request for acquiring streaming media data of the program
  • a first receiving unit configured to receive the m3u8 of the streaming media data returned by the CDN And a first fragment file of the streaming media data in the index file and the preset playing duration, where the first fragment file is a fragment file obtained by cutting the streaming media data according to the HLS protocol, the m3u8
  • the index file is added with association information, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file, the second Fragment file based a slice file obtained by cutting the streaming media data by the P2P protocol;
  • Determining unit for the m3u8 Determining, in the index file, a second slice sequence number of the second slice file associated with the first slice sequence number of the first first slice file after the preset play duration;
  • Second sending unit for P2P The network sends a second request for acquiring the streaming media data, where the second request carries the second fragment serial number;
  • a second receiving unit for receiving P2P The second fragment file of the streaming media data returned by the network starting from the second fragment serial number;
  • a playing unit configured to sequentially play the received first fragment file and the second fragment file.
  • the streaming media plays the client from the CDN.
  • the network obtains the streaming media data of the rest of the streaming program, so as to ensure the smoothness of the online broadcast of the streaming program, the entire online playing process does not cause greater server pressure on the CDN, thereby saving the CDN. Server input costs.
  • FIG. 1 is an architectural diagram of a streaming media system according to an embodiment of the present invention
  • FIG. 2 is a flowchart of implementing a method for transmitting a streaming media according to an embodiment of the present invention
  • FIG. 3 is a specific implementation flow diagram of a method for transmitting a streaming media S203 according to an embodiment of the present invention
  • FIG. 4 is a flowchart showing an implementation of a method for playing a streaming media according to an embodiment of the present invention
  • FIG. 5 is a flowchart of an implementation of a method for playing a streaming media according to another embodiment of the present invention.
  • FIG. 6 is a flowchart of an implementation of a method for playing a streaming media according to another embodiment of the present invention.
  • FIG. 7 is a structural block diagram of a streaming media transmission apparatus according to an embodiment of the present invention.
  • FIG. 8 is a structural block diagram of a streaming media playback apparatus according to an embodiment of the present invention.
  • FIG 1 The streaming media transmission and playback method and the streaming media system architecture diagram applicable to the transmission and playback apparatus provided by the embodiments of the present invention are shown. For the convenience of description, only the parts related to the embodiment are shown.
  • the streaming media system is mainly composed of a first server module 11, a second server module 12, and a CDN 13,
  • the P2P network 14 and the streaming media playing client 15 are constructed.
  • the functions of each part of the architecture in the streaming media system are as follows:
  • First server module 11 A source server or a source server group as a streaming media, configured to provide streaming media resources for a streaming media system, or to store and manage streaming media resources.
  • the second server module 12 may exist in the form of a server or a server group for use from the first server module 11
  • the streaming media data is extracted, the streaming media data is processed, the streaming media data is fragmented, and the fragmentation index file is generated, and the processed data is separately output to the CDN 13 and the P2P network. Medium.
  • Streaming Media Player 15 Based on the user's program playback needs, from CDN 13 and P2P networks 14 The streaming media data corresponding to the program is pulled to realize the playback of the streaming media program.
  • the system architecture shown can transmit and play streaming media data, thereby enabling online on-demand or live streaming of streaming programs.
  • the following is based on a specific implementation example, respectively, based on the second server module 12
  • the method and device for transmitting the implemented streaming media, and the playing method and device for streaming media implemented by the streaming media playing client 15 are elaborated:
  • FIG. 2 is a flowchart showing an implementation process of a streaming media transmission method according to an embodiment of the present invention, which is described in detail as follows:
  • the streaming media data is cut into a plurality of first fragment files according to the HLS protocol, and the streaming media data is generated. M3u8 index file.
  • the streaming media data is cut into a plurality of second fragment files according to a P2P protocol.
  • the streaming media data is fragmented under the HLS protocol, and the streaming media data is fragmented into continuous, short duration fragment files (MPED-TS format), for example, sharding streaming media data into several shard files with a playback duration of 10 seconds; while splicing the streaming media data, according to HLS According to the protocol, the m3u8 index file of these fragment files is generated, and the fragment number and playback duration of each fragment file are recorded in the generated m3u8 index file.
  • MPED-TS format MPED-TS format
  • the streaming media data is fragmented under the protocol, and the streaming media data is sliced into consecutive file files of the same amount of data.
  • the streaming media data is fragmented into a plurality of fragment files having a data volume of 1 k.
  • the m3u8 The association information is added to the index file such that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file.
  • the data offset length refers to the data head of the streaming media data as a reference point, and the offset of the data is calculated backward, and the data offset length of the fragment file is the data header of the fragment file relative to the data header.
  • the offset of the data header of the associated streaming media data refers to the data head of the streaming media data as a reference point, and the offset of the data is calculated backward, and the data offset length of the fragment file is the data header of the fragment file relative to the data header.
  • index file is further processed to add association information thereto, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated.
  • S203 can be implemented by using the embodiment shown in FIG. 3:
  • the streaming media data is fragmented according to the playing duration. Therefore, based on the playing duration, the playing frame rate, and the image resolution of all the fragment files before the current fragment file, the current fragment file can be calculated to be in the stream. The length of the data offset in the media data.
  • the streaming media data is fragmented according to the amount of data. Therefore, based on the sum of the data amounts of all the fragment files before the current fragment file, the data of the current fragment file in the streaming media data can be calculated. Offset length.
  • the second fragment sequence number is associated with the first fragment sequence number of each of the first fragment files, and the second fragment sequence number is the data offset length from the first fragment file.
  • the second slice sequence number of the second slice file is associated with the first slice sequence number of the first slice file whose data offset length is the same, thereby completing the addition of the m3u8 index file association information.
  • the first fragment file and the m3u8 index file are delivered to the content distribution network CDN. And sending the second fragment file to the P2P network, so that the streaming media client obtains the streaming media data from the CDN and the P2P network and plays the data.
  • the first fragment file generated based on the HLS protocol and the associated information are added.
  • the m3u8 index file is delivered to the distributed storage in the CDN
  • the second fragment file generated based on the P2P protocol is delivered to the P2P.
  • Distributed storage in the network When the streaming media playback client needs to play the corresponding program, the streaming media data is pulled from both the CDN and the P2P network, and a part of the streaming media data is from the CDN. In the pull, the remaining part of the streaming media data is pulled from the P2P network, so that the CDN can be effectively alleviated compared to the prior art method of completely obtaining streaming media data from the CDN.
  • Server pressure correspondingly reducing the number of servers in the CDN, saving system costs for streaming media systems.
  • a playlist is detected to determine which program needs to be played.
  • the client locally detects the playlist, determines the current streaming program to be played according to the sequence of the programs in the playlist, and obtains a unique identifier of the streaming program, for example, a 64-bit number of the streaming program. ID, in the subsequent step, when sending a request to the CDN or P2P network to obtain streaming media data, the unique identifier is carried in the request to make the CDN or P2P
  • One end of the network can smoothly locate the streaming media data that needs to be returned to the client.
  • a first request for acquiring streaming media data of the program is sent to the CDN.
  • the starting data portion of the streaming media data is from the CDN.
  • the purpose of this is to speed up the loading of streaming data and to enable streaming of the streaming program on the client as soon as possible. Therefore, after sending the first request to the CDN, the CDN Returns the starting data portion of the streaming media data to the client, and returns the m3u8 index file to which the associated information was added.
  • the starting data portion of the streaming media data includes a plurality of first fragment files for realizing content playback within a preset playback duration of the streaming media program.
  • the preset playing time is one minute
  • the playing time of each first piece file is 10 seconds
  • the CDN returns to the client the 6 first fragment files of the streaming media data starting from the data start position, based on 6
  • the first fragment file can realize the content playback of the first minute of the streaming program.
  • the preset playing duration is a value that can be set.
  • the value of the preset playing duration may be pre-existing in the streaming media system.
  • the method further includes:
  • the user can set the preset playback duration in the setting interface provided by the client according to the actual network environment. For example, in the case of a poor network environment, the preset playback duration can be appropriately extended. While speeding up the loading speed of streaming programs, ensure that the client has enough time to P2P network pulls data to avoid playing data source from CDN to P2P In the case of network conversion, the default playback time can be appropriately shortened to minimize the server pressure of the CDN.
  • the S402 can be implemented by S409 in FIG. 5:
  • the client needs to write the preset playing duration in the first request before sending the first request, thereby thereby, the CDN
  • the number of the first fragment files that need to be sent to the client is determined according to the preset playback duration obtained by the parsing, thereby implementing the delivery of the streaming media data.
  • the network sends a second request for acquiring the streaming media data, where the second request carries the second fragment sequence number.
  • the client is getting the CDN After the first fragment files are delivered, the remaining part of the streaming media data needs to be pulled. Therefore, the client first locates the slave CDN in the m3u8 index file. Pulling the last first fragment file to find the first fragment number of the next first fragment file of the first fragment file, thereby obtaining m3u8 according to m3u8
  • the association information included in the index file obtains the second fragment sequence number associated with the first fragment sequence number to determine the first second fragment file corresponding to the uncompleted streaming media data. Two-segment number, and the second fragment number is written in the second request and sent to P2P network. The P2P network returns the remaining streaming media data according to the second request of the client.
  • the received first fragment file and the second fragment file are sequentially played.
  • the client is from the CDN
  • the first fragment file corresponding to the beginning of the streaming program is received in the network
  • the second fragment file corresponding to the remaining part of the streaming program is received in the network, and the fragment files are sequentially played according to the fragment serial number of the received fragment file, thereby realizing online play of the streaming program.
  • the streaming media plays the client from the CDN.
  • the network obtains the streaming media data of the rest of the streaming program, so as to ensure the smoothness of the online broadcast of the streaming program, the entire online playing process does not cause greater server pressure on the CDN, thereby saving the CDN. Server input costs.
  • the user may adjust the progress of the program according to his or her own viewing intention, for example, fast forward playback or reverse playback, when the current playback progress of the streaming program jumps to a new one.
  • his or her own viewing intention for example, fast forward playback or reverse playback
  • the current playback progress of the streaming program jumps to a new one.
  • the diagram 4 The same streaming media data acquisition idea is shown in the embodiment, and part of the streaming media data starting from the playing position is pulled from the CDN to implement fast loading of the streaming media program, and then from P2P. Pull out the remaining streaming media data in the network to relieve the server pressure on the CDN.
  • the specific scheme is shown in Figure 6. Compared to the embodiment shown in Figure 4, the scheme is after S406, S407. Previously, the following steps were added:
  • S410 Receive a play position indication instruction, and detect a play position of the program indicated by the play position indication instruction.
  • the play position indication instruction is used to indicate a new play time point, and after receiving the play position indication instruction, the streaming program will start playing from the play time point indicated by the instruction.
  • the playback time point indicated by the playback position indication instruction and M3u8 The playing time of each first fragment file recorded in the index file may determine which first fragment file corresponds to the playback position, and may obtain the first fragment of the first fragment file. Serial number. On the basis of determining the first slice serial number, the second slice serial number of the second slice file that needs to be played after the preset play duration starts from the play position may be further determined.
  • the network sends a fourth request for acquiring the streaming media data, where the fourth request carries a first first fragment serial number associated with the preset playing duration starting from the playing position. Second slice number.
  • the client carries the first fragment sequence number and the second fragment sequence number found in S411 in the acquisition request of the streaming media data, and sends the result to the acquisition request of the streaming media data respectively.
  • CDN and P2P networks respectively, to obtain CDN and P2P
  • the streaming media data after the playback position returned by the network according to the corresponding request enables fast and smooth playback of the streaming program.
  • the client can also quickly select and switch the bit rate of the online play to adapt to the playback environment under different bandwidth conditions.
  • the network congestion condition is to improve the loading speed of each client's online streaming of streaming programs from the CDN.
  • FIG. 7 shows an embodiment of the present invention.
  • a structural block diagram of a streaming media transmission device which may be built in the second server module 12 or the second server module 12 Software units, hardware units, or units that are combined with software and hardware within the application system. For the convenience of explanation, only the parts related to the present embodiment are shown.
  • the device includes:
  • the first dividing unit 71 cuts the streaming media data into a plurality of first fragment files according to the HLS protocol, and generates the streaming media data. M3u8 index file.
  • the streaming media data is fragmented under the protocol, and the streaming media data is fragmented into continuous, short-length fragment files; while the streaming media data is fragmented, these fragments are generated according to the HLS protocol.
  • Documentary The m3u8 index file records the fragment number and playback duration of each fragment file in the generated m3u8 index file.
  • the second dividing unit 72 cuts the streaming media data into a plurality of second fragment files according to a P2P protocol.
  • the streaming media data is fragmented under the protocol, and the streaming media data is sliced into consecutive file files of the same amount of data.
  • the streaming media data is fragmented into a plurality of fragment files having a data volume of 1 k.
  • association information is added to the index file such that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file.
  • the data offset length refers to the data head of the streaming media data as a reference point, and the offset of the data is calculated backward, and the data offset length of the fragment file is the data header of the fragment file relative to the data header.
  • the offset of the data header of the associated streaming media data is information addition unit In 73, the m3u8 generated based on the HLS protocol The index file is further processed to add association information thereto, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated.
  • the issuing unit 74 delivers the first fragment file and the m3u8 index file to the content distribution network CDN And sending the second fragment file to the P2P network, so that the streaming media client obtains the streaming media data from the CDN and the P2P network and plays the data.
  • the first fragment file generated based on the HLS protocol and the associated information are added.
  • the m3u8 index file is delivered to the distributed storage in the CDN
  • the second fragment file generated based on the P2P protocol is delivered to the P2P.
  • Distributed storage in the network When the streaming media playback client needs to play the corresponding program, the streaming media data is pulled from both the CDN and the P2P network, and a part of the streaming media data is from the CDN. In the pull, the remaining part of the streaming media data is pulled from the P2P network, so that the CDN can be effectively alleviated compared to the prior art method of completely obtaining streaming media data from the CDN.
  • Server pressure correspondingly reducing the number of servers in the CDN, saving system costs for streaming media systems.
  • the information adding unit 73 includes:
  • a first calculating subunit calculating a data offset length of each of the first fragment files in the streaming media data
  • a second calculating subunit calculating a data offset length of each of the second fragment files in the streaming media data
  • the second fragment sequence number is associated with the first fragment sequence number of each of the first fragment files, and the second fragment sequence number is the data offset length from the first fragment file.
  • FIG. 8 shows the playing of the streaming media provided by the embodiment of the present invention.
  • the streaming media playing device may be built in the streaming media playing client 15 or the streaming media playing client 15 Software units, hardware units, or units that are combined with software and hardware within the application system. For the convenience of explanation, only the parts related to the present embodiment are shown.
  • the device includes:
  • the detecting unit 81 detects a playlist and determines a program to be played.
  • the client locally detects its playlist, determines the current streaming media program to be played according to the order of the programs in the playlist, and obtains the unique identifier of the streaming media program, in subsequent CDN or P2P
  • the unique identifier is carried in the request, so that one end of the CDN or the P2P network can successfully locate the streaming media data that needs to be returned to the client.
  • the first transmitting unit 82 transmits a first request for acquiring streaming media data of the program to the content distribution network CDN.
  • the first receiving unit 83 receives the m3u8 of the streaming media data returned by the CDN And a first fragment file of the streaming media data in the index file and the preset playing duration, where the first fragment file is a fragment file obtained by cutting the streaming media data according to the HLS protocol, the m3u8
  • the index file is added with association information, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file, the second Fragment file based
  • the P2P protocol cuts the obtained streaming media data into a fragment file.
  • the starting data portion of the streaming media data is from the CDN.
  • the purpose of this is to speed up the loading of streaming data and to enable streaming of the streaming program on the client as soon as possible. Therefore, after sending the first request to the CDN, the CDN Returns the starting data portion of the streaming media data to the client, and returns the m3u8 index file to which the associated information was added.
  • Determining unit 84 at the m3u8 Determining, in the index file, a second slice sequence number of the second slice file associated with the first slice sequence number of the first first slice file after the preset play duration.
  • Second transmitting unit 85 to P2P
  • the network sends a second request for acquiring the streaming media data, where the second request carries the second fragment serial number.
  • the second receiving unit 86 receives the second fragment file starting from the second fragment serial number of the streaming media data returned by the P2P network. .
  • the client is getting the CDN After the first fragment files are delivered, the remaining part of the streaming media data needs to be pulled. Therefore, the client first locates the slave CDN in the m3u8 index file. Pulling the last first fragment file to find the first fragment number of the next first fragment file of the first fragment file, thereby obtaining m3u8 according to m3u8
  • the association information included in the index file obtains the second fragment sequence number associated with the first fragment sequence number to determine the first second fragment file corresponding to the uncompleted streaming media data. Two-segment number, and the second fragment number is written in the second request and sent to P2P network. The P2P network returns the remaining streaming media data according to the second request of the client.
  • the playing unit 87 plays the received first fragment file and the second fragment file sequentially.
  • the client receives the first fragment file corresponding to the beginning of the streaming program from the CDN network, and from the P2P
  • the second fragment file corresponding to the remaining part of the streaming program is received in the network, and the fragment files are sequentially played according to the fragment serial number of the received fragment file, thereby realizing online play of the streaming program.
  • the device further includes:
  • a setting unit configured to set the preset playing duration
  • the first sending unit 82 includes:
  • the client needs to write the preset playing duration in the first request before sending the first request, thereby thereby, the CDN
  • the number of the first fragment files that need to be sent to the client is determined according to the preset playback duration obtained by the parsing, thereby implementing the delivery of the streaming media data.
  • the user can set the preset playback duration in the setting interface provided by the client according to the actual network environment. For example, in the case of a poor network environment, the preset playback duration can be appropriately extended, and the streaming program is accelerated. At the same time of loading speed, ensure that the client has enough time to P2P network pulls data to avoid playing data source from CDN to P2P In the case of network conversion, the default playback time can be appropriately shortened to minimize the server pressure of the CDN.
  • the user may adjust the progress of the program according to his or her own viewing intention, for example, fast forward playback or reverse playback, when the current playback progress of the streaming program jumps to a new one.
  • the device When playing the position, from The CDN pulls part of the streaming media data starting from the playing position to implement fast loading of the streaming program, and then pulls the remaining streaming media data from the P2P network to mitigate the CDN. Server pressure. Therefore, optionally, the device further includes:
  • the instruction receiving unit receives the play position indication instruction, and detects a play position of the program indicated by the play position indication instruction.
  • the play position indication instruction is used to indicate a new play time point, and after receiving the play position indication instruction, the streaming program will start playing from the play time point indicated by the instruction.
  • Search unit based on the m3u8 An index file, searching for a first slice serial number corresponding to the play position, and searching for a second slice serial number associated with the first first slice serial number after the preset play duration starting from the play position .
  • the playback time point indicated by the playback position indication instruction and M3u8 The playing time of each first fragment file recorded in the index file may determine which first fragment file corresponds to the playback position, and may obtain the first fragment of the first fragment file. Serial number. On the basis of determining the first slice serial number, the second slice serial number of the second slice file that needs to be played after the preset play duration starts from the play position may be further determined.
  • Third sending unit to CDN Sending a third request for acquiring the streaming media data, where the third request carries a first fragment sequence number corresponding to the play location;
  • Third receiving unit receiving CDN And the first fragment file within the preset playing duration starting from the playing position by the streaming media data returned according to the first fragment serial number;
  • the network sends a fourth request for acquiring the streaming media data, where the fourth request carries a first first fragment serial number associated with the preset playing duration starting from the playing position. Second slice serial number;
  • the fourth receiving unit receives the second fragment file starting from the second fragment serial number of the P2P network.
  • the first fragment sequence number and the second fragment sequence number that the client finds are carried in the acquisition request of the streaming media data, and are respectively sent to the CDN and
  • the P2P network obtains the streaming media data after the playback position returned by the CDN and the P2P network according to the corresponding request, so as to quickly and smoothly realize the jump play of the streaming program.
  • the disclosed apparatus and method may be implemented in other manners.
  • the system embodiment described above is merely illustrative.
  • the division of the module or unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be used. Combinations can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • the medium includes a number of instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor ( Processor) Performs all or part of the steps of the method described in the various embodiments of the embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, and a read only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) )
  • ROM Read-Only Memory
  • RAM Random Access Memory

Landscapes

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

Abstract

The present invention relates to the technical field of networks, and provides a streaming media transmission and play method, and transmission and play device. The method comprises: dividing, according to the HLS protocol, streaming media data into multiple first fragment files; dividing, according to a P2P protocol, the streaming media data into multiple second fragment files; adding association information to an m3u8 index file; and sending the first fragment files and m3u8 index file to a CDN, and sending the second fragment files to a P2P network, such that a streaming media player client end obtains the streaming media data respectively from the CDN and P2P network and plays the same. The present invention effectively reduces, by employing a CDN and P2P network to send streaming media data to a streaming media player client end and establishing an association relationship between fragment files of the streaming media data in said two networks with an m3u8 index file of the HLS protocol, a stress on a CDN server, thereby reducing a server cost of a streaming media system.

Description

流媒体的传输、播放方法及传输、播放装置 Streaming media transmission and playing method, and transmission and playback device 技术领域Technical field
本发明属于 网络技术领域 ,尤其涉及 流媒体的传输、播放方法及传输、播放装置 。  The invention belongs to the field of network technologies, and particularly relates to a method for transmitting and playing a streaming medium, and a transmission and playback device.
背景技术Background technique
HLS ( HTTP Live Streaming )是一种流媒体传输播放协议,主要为 iOS 设备提供音视频直播和点播方案。 HLS 协议最大的特点在于,客户端获取到的并不是一个完整的数据流, HLS 协议在服务器端将流媒体文件切割存储为多个连续的、很短时长的 TS 分片文件,然后建立一个与这些 TS 分片文件相对应的 m3u8 索引文件,基于此对流媒体文件进行碎片化传输,从而实现流媒体在客户端的播放。 HLS (HTTP Live Streaming) is a streaming media playback protocol, mainly for iOS. The device provides audio and video live and on-demand programs. The biggest feature of the HLS protocol is that the client does not get a complete data stream, HLS. The protocol stores the streaming media file on the server side as multiple consecutive, very short TS fragment files, and then creates a m3u8 corresponding to these TS fragment files. The index file is based on the fragmented transmission of the streaming media file, so that the streaming media is played on the client.
为了满足流媒体文件的传输、播放需要占用大量的服务器资源和网络带宽的应用需求,现有技术在流媒体播放系统中引入了内容分发网络( Content Delivery Network , CDN )技术,其目的是通过在现有的网络中增加一层新的网络架构,将流媒体数据发布到最接近客户端的网络 ' 边缘 ' ,使客户端可以就近取得所需的内容,解决网络拥塞状况,提高客户端获取流媒体数据的响应速度。然而,为了使用户获得流畅的观看体验, CDN 技术的采用需要在互联网上布局大量的服务器资源,大大增加了流媒体播放系统的系统成本。 In order to meet the application requirements of streaming media files for transmission and playback, which require a large amount of server resources and network bandwidth, the prior art introduces a content distribution network (Content Delivery) in the streaming media playback system. Network , CDN ) technology, the purpose of which is to distribute streaming media data to the network 'edge' closest to the client by adding a new layer of network architecture to the existing network. So that the client can obtain the required content in the vicinity, solve the network congestion situation, and improve the response speed of the client to obtain streaming media data. However, in order to give users a smooth viewing experience, CDN The adoption of technology requires a large amount of server resources to be laid out on the Internet, which greatly increases the system cost of the streaming media playback system.
技术问题technical problem
本发明实施例的目的在于提供流媒体的传输、播放方法及传输、播放装置,以减轻完全依赖 CDN 进行流媒体传输和播放所带来的服务器布局压力,降低流媒体播放系统的系统成本。  The purpose of the embodiments of the present invention is to provide a streaming media transmission and playing method, and a transmission and playback device to alleviate the complete dependence on the CDN. The server layout pressure brought by streaming media transmission and playback reduces the system cost of the streaming media playback system.
技术解决方案Technical solution
本发明实施例是这样实现的,一种流媒体的传输方法,包括: The embodiment of the present invention is implemented by the method for transmitting a streaming media, including:
根据 HLS 协议将流媒体数据切割成多个第一分片文件,并生成所述流媒体数据的 m3u8 索引文件; Cutting the streaming media data into a plurality of first fragment files according to the HLS protocol, and generating the m3u8 of the streaming media data Index file
根据 P2P 协议将所述流媒体数据切割成多个第二分片文件; Cutting the streaming media data into a plurality of second fragment files according to a P2P protocol;
为所述 m3u8 索引文件中添加关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和所述第二分片文件在所述 m3u8 索引文件中产生关联; For the m3u8 Adding association information in the index file, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file;
将所述第一分片文件和所述 m3u8 索引文件下发至内容分发网络 CDN ,将所述第二分片文件下发至 P2P 网络,以使流媒体播放客户端分别从 CDN 和 P2P 网络中获取所述流媒体数据并播放。 And sending the first fragment file and the m3u8 index file to the content distribution network CDN, and sending the second fragment file to the The P2P network, so that the streaming media client obtains the streaming media data from the CDN and the P2P network and plays the data.
本发明实施例的另一目的在于提供 一种流媒体的传输装置,包括: Another object of the embodiments of the present invention is to provide a streaming media transmission apparatus, including:
第一分割单元,用于根据 HLS 协议将流媒体数据切割成多个第一分片文件,并生成所述流媒体数据的 m3u8 索引文件; a first dividing unit, configured to cut the streaming media data into a plurality of first fragment files according to the HLS protocol, and generate the streaming media data M3u8 index file;
第二分割单元,用于根据 P2P 协议将所述流媒体数据切割成多个第二分片文件; a second dividing unit, configured to cut the streaming media data into a plurality of second fragment files according to a P2P protocol;
信息添加单元,用于为所述 m3u8 索引文件中添加关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和所述第二分片文件在所述 m3u8 索引文件中产生关联; An information adding unit for the m3u8 Adding association information in the index file, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file;
下发单元,用于将所述第一分片文件和所述 m3u8 索引文件下发至内容分发网络 CDN ,将所述第二分片文件下发至 P2P 网络,以使流媒体播放客户端分别从 CDN 和 P2P 网络中获取所述流媒体数据并播放。 a sending unit, configured to deliver the first fragment file and the m3u8 index file to a content distribution network CDN And sending the second fragment file to the P2P network, so that the streaming media client obtains the streaming media data from the CDN and the P2P network and plays the data.
本发明实施例中,将流媒体数据同时布局在 CDN 和 P2P 网络中,并利用 HLS 协议的 m3u8 索引文件来建立流媒体数据在上述两个网络中的分片文件之间的关联关系,以同时依赖上述两个网络来为流媒体播放客户端下发流媒体数据,有效地减轻了 CDN 的服务器压力,节省了流媒体系统的服务器成本。 In the embodiment of the present invention, the streaming media data is simultaneously laid out in the CDN and the P2P network, and the HLS protocol is utilized. The m3u8 index file is used to establish an association relationship between the fragmented files of the streaming media data in the two networks, so as to simultaneously rely on the two networks to deliver streaming media data to the streaming media playback client, thereby effectively reducing the CDN. The server pressure saves the server cost of the streaming system.
本发明实施例的另一目的在于提供 一种流媒体的播放方法,包括: Another object of the embodiments of the present invention is to provide a method for playing a streaming media, including:
检测播放列表,确定需要播放的节目; Detecting playlists and determining which programs need to be played;
向内容分发网络 CDN 发送用于获取所述节目的流媒体数据的第一请求; Transmitting, to the content distribution network CDN, a first request for acquiring streaming media data of the program;
接收 CDN 返回的所述流媒体数据的 m3u8 索引文件和预设播放时长内的所述流媒体数据的第一分片文件,所述第一分片文件为根据 HLS 协议将所述流媒体数据切割得到的分片文件,所述 m3u8 索引文件被添加了关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和第二分片文件在所述 m3u8 索引文件中产生关联,所述第二分片文件为根据 P2P 协议将所述流媒体数据切割得到的分片文件; Receiving the m3u8 of the streaming media data returned by the CDN And a first fragment file of the streaming media data in the index file and the preset playing duration, where the first fragment file is a fragment file obtained by cutting the streaming media data according to the HLS protocol, the m3u8 The index file is added with association information, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file, the second Fragment file based a slice file obtained by cutting the streaming media data by the P2P protocol;
在所述 m3u8 索引文件中确定所述预设播放时长之后的第一个所述第一分片文件的第一分片序号所关联的所述第二分片文件的第二分片序号; In the m3u8 Determining, in the index file, a second slice sequence number of the second slice file associated with the first slice sequence number of the first first slice file after the preset play duration;
向 P2P 网络发送用于获取所述流媒体数据的第二请求,所述第二请求中携带了该第二分片序号; Sending, to the P2P network, a second request for acquiring the streaming media data, where the second request carries the second fragment serial number;
接收 P2P 网络返回的所述流媒体数据从该第二分片序号起始的所述第二分片文件; Receiving, by the second slice file, the streaming media data returned by the P2P network starting from the second fragment sequence number;
依序播放接收到的所述第一分片文件和所述第二分片文件。 The received first fragment file and the second fragment file are sequentially played.
本发明实施例的另一目的在于提供 一种流媒体的播放装置,包括: Another object of the present invention is to provide a streaming media playback device, including:
检测单元,用于检测播放列表,确定需要播放的节目; a detecting unit, configured to detect a playlist, and determine a program to be played;
第一发送单元,用于向内容分发网络 CDN 发送用于获取所述节目的流媒体数据的第一请求; a first sending unit, configured to send, to the content distribution network CDN, a first request for acquiring streaming media data of the program;
第一接收单元,用于接收 CDN 返回的所述流媒体数据的 m3u8 索引文件和预设播放时长内的所述流媒体数据的第一分片文件,所述第一分片文件为根据 HLS 协议将所述流媒体数据切割得到的分片文件,所述 m3u8 索引文件被添加了关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和第二分片文件在所述 m3u8 索引文件中产生关联,所述第二分片文件为根据 P2P 协议将所述流媒体数据切割得到的分片文件; a first receiving unit, configured to receive the m3u8 of the streaming media data returned by the CDN And a first fragment file of the streaming media data in the index file and the preset playing duration, where the first fragment file is a fragment file obtained by cutting the streaming media data according to the HLS protocol, the m3u8 The index file is added with association information, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file, the second Fragment file based a slice file obtained by cutting the streaming media data by the P2P protocol;
确定单元,用于在所述 m3u8 索引文件中确定所述预设播放时长之后的第一个所述第一分片文件的第一分片序号所关联的所述第二分片文件的第二分片序号; Determining unit for the m3u8 Determining, in the index file, a second slice sequence number of the second slice file associated with the first slice sequence number of the first first slice file after the preset play duration;
第二发送单元,用于向 P2P 网络发送用于获取所述流媒体数据的第二请求,所述第二请求中携带了该第二分片序号; Second sending unit for P2P The network sends a second request for acquiring the streaming media data, where the second request carries the second fragment serial number;
第二接收单元,用于接收 P2P 网络返回的所述流媒体数据从该第二分片序号起始的所述第二分片文件; a second receiving unit for receiving P2P The second fragment file of the streaming media data returned by the network starting from the second fragment serial number;
播放单元,用于依序播放接收到的所述第一分片文件和所述第二分片文件。 a playing unit, configured to sequentially play the received first fragment file and the second fragment file.
有益效果Beneficial effect
本发明实施例中,在流媒体节目加载之初,由流媒体播放客户端从 CDN 中获取流媒体节目起始部分的流媒体数据,以保证流媒体节目的加载速度,之后,由流媒体播放客户端从 P2P 网络中获取流媒体节目剩余部分的流媒体数据,从而在保证流媒体节目在线播放的流畅性的同时,使得整个在线播放过程不会对 CDN 造成较大的服务器压力,节省了 CDN 的服务器投入成本。  In the embodiment of the present invention, at the beginning of loading of the streaming media program, the streaming media plays the client from the CDN. Obtaining streaming media data at the beginning of the streaming media program to ensure the loading speed of the streaming media program, and then playing the client from the streaming media from the P2P The network obtains the streaming media data of the rest of the streaming program, so as to ensure the smoothness of the online broadcast of the streaming program, the entire online playing process does not cause greater server pressure on the CDN, thereby saving the CDN. Server input costs.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。 In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the embodiments or the description of the prior art will be briefly described below. It is obvious that the drawings in the following description are only the present invention. For some embodiments, other drawings may be obtained from those of ordinary skill in the art in light of the inventive workability.
图 1 是 本发明实施例提供的流媒体系统的架构图; 1 is an architectural diagram of a streaming media system according to an embodiment of the present invention;
图 2 是本发明 实施例提供的流媒体的传输方法的实现流程图; 2 is a flowchart of implementing a method for transmitting a streaming media according to an embodiment of the present invention;
图 3 是本发明实施例提供的 流媒体的传输方法 S203 的具体实现流程 图; 3 is a specific implementation flow diagram of a method for transmitting a streaming media S203 according to an embodiment of the present invention;
图 4 是本发明实施例提供的 流媒体的播放方法的实现流程 图; 4 is a flowchart showing an implementation of a method for playing a streaming media according to an embodiment of the present invention;
图 5 是本发明另一实施例提供的 流媒体的播放方法的实现流程 图; FIG. 5 is a flowchart of an implementation of a method for playing a streaming media according to another embodiment of the present invention; FIG.
图 6 是本发明另一实施例提供的 流媒体的播放方法的实现流程 图 ; FIG. 6 is a flowchart of an implementation of a method for playing a streaming media according to another embodiment of the present invention; FIG.
图 7 是本发明实施例提供的 流媒体的传输 装置的结构框图; 7 is a structural block diagram of a streaming media transmission apparatus according to an embodiment of the present invention;
图 8 是本发明实施例提供的 流媒体的播放 装置的结构框图。 FIG. 8 is a structural block diagram of a streaming media playback apparatus according to an embodiment of the present invention.
本发明的实施方式Embodiments of the invention
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透切理解本发明实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本发明。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本发明的描述。 In the following description, for purposes of illustration and description However, it will be apparent to those skilled in the art that the present invention may be practiced in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the invention.
为了说明本发明所述的技术方案,下面通过具体实施例来进行说明 。 In order to explain the technical solutions described in the present invention, the following description will be made by way of specific embodiments.
图 1 示出了本发明实施例提供的流媒体传输、播放方法及传输、播放装置所适用的流媒体系统架构图,为了便于说明,仅示出了与本实施例相关的部分。 figure 1 The streaming media transmission and playback method and the streaming media system architecture diagram applicable to the transmission and playback apparatus provided by the embodiments of the present invention are shown. For the convenience of description, only the parts related to the embodiment are shown.
参照图 1 ,该流媒体系统主要由第一服务器模块 11 、第二服务器模块 12 、 CDN 13 、 P2P 网络 14 及流媒体播放客户端 15 架构而成,该架构中各部分在流媒体系统中的功能简述如下: Referring to FIG. 1, the streaming media system is mainly composed of a first server module 11, a second server module 12, and a CDN 13, The P2P network 14 and the streaming media playing client 15 are constructed. The functions of each part of the architecture in the streaming media system are as follows:
第一服务器模块 11 作为流媒体的源服务器或者源服务器组,用于为流媒体系统提供流媒体资源,或者对流媒体资源进行存储和管理。 First server module 11 A source server or a source server group as a streaming media, configured to provide streaming media resources for a streaming media system, or to store and manage streaming media resources.
第二服务器模块 12 可以以服务器或者服务器组的形式存在,其用于从第一服务器模块 11 中拉取流媒体数据,对流媒体数据进行处理,将流媒体数据进行分片及生成分片索引文件之后,将处理得到的数据分别输出到 CDN 13 和 P2P 网络 14 中。 The second server module 12 may exist in the form of a server or a server group for use from the first server module 11 The streaming media data is extracted, the streaming media data is processed, the streaming media data is fragmented, and the fragmentation index file is generated, and the processed data is separately output to the CDN 13 and the P2P network. Medium.
流媒体播放客户端 15 根据用户的节目播放需求,从 CDN 13 和 P2P 网络 14 中拉取节目对应的流媒体数据,以实现对流媒体节目的播放。 Streaming Media Player 15 Based on the user's program playback needs, from CDN 13 and P2P networks 14 The streaming media data corresponding to the program is pulled to realize the playback of the streaming media program.
基于图 1 所示的系统架构,可以对流媒体数据进行传输和播放,从而实现流媒体节目的在线点播或者直播。以下结合具体的实现例,分别对基于第二服务器模块 12 实现的流媒体的传输方法、装置,以及基于流媒体播放客户端 15 实现的流媒体的播放方法、装置进行详细阐述: Based on Figure 1 The system architecture shown can transmit and play streaming media data, thereby enabling online on-demand or live streaming of streaming programs. The following is based on a specific implementation example, respectively, based on the second server module 12 The method and device for transmitting the implemented streaming media, and the playing method and device for streaming media implemented by the streaming media playing client 15 are elaborated:
图 2 示出了本发明实施例提供的 流媒体的传输方法的实现流程,详述如下: FIG. 2 is a flowchart showing an implementation process of a streaming media transmission method according to an embodiment of the present invention, which is described in detail as follows:
在 S201 中,根据 HLS 协议将流媒体数据切割成多个第一分片文件,并生成所述流媒体数据的 m3u8 索引文件。 In S201, the streaming media data is cut into a plurality of first fragment files according to the HLS protocol, and the streaming media data is generated. M3u8 index file.
在 S202 中,根据 P2P 协议将所述流媒体数据切割成多个第二分片文件。 In S202, the streaming media data is cut into a plurality of second fragment files according to a P2P protocol.
在 S201 和 S202 中,基于 HLS 协议和 P2P 协议分别对流媒体节目的流媒体数据进行分片处理,具体地: In S201 and S202, based on HLS protocol and P2P The protocol separately processes the streaming media data of the streaming media program, specifically:
在 HLS 协议之下对流媒体数据进行分片处理,将流媒体数据分片为连续的、很短时长的分片文件( MPED-TS 格式),例如,将流媒体数据分片为播放时长均为 10 秒的若干个分片文件;在对流媒体数据进行分片处理的同时,按照 HLS 协议的规定,生成这些分片文件的 m3u8 索引文件,在生成的 m3u8 索引文件中记录了个每个分片文件的分片序号、播放时长等信息。 The streaming media data is fragmented under the HLS protocol, and the streaming media data is fragmented into continuous, short duration fragment files ( MPED-TS format), for example, sharding streaming media data into several shard files with a playback duration of 10 seconds; while splicing the streaming media data, according to HLS According to the protocol, the m3u8 index file of these fragment files is generated, and the fragment number and playback duration of each fragment file are recorded in the generated m3u8 index file.
在 P2P 协议之下对流媒体数据进行分片处理,将流媒体数据分片为连续的、数据量相同的分片文件,例如,将流媒体数据分片为数据量为 1k 的若干分片文件。 At P2P The streaming media data is fragmented under the protocol, and the streaming media data is sliced into consecutive file files of the same amount of data. For example, the streaming media data is fragmented into a plurality of fragment files having a data volume of 1 k.
在 S203 中,为所述 m3u8 索引文件中添加关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和所述第二分片文件在所述 m3u8 索引文件中产生关联。 In S203, the m3u8 The association information is added to the index file such that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file.
所述数据偏移长度,是指以流媒体数据的数据头作为基准点,向后开始计算数据的偏移量,分片文件的数据偏移长度,即该分片文件的数据头相对于其所属的流媒体数据的数据头的偏移量。 The data offset length refers to the data head of the streaming media data as a reference point, and the offset of the data is calculated backward, and the data offset length of the fragment file is the data header of the fragment file relative to the data header. The offset of the data header of the associated streaming media data.
基于 S201 和 S202 的分片结果,在 S203 中,对基于 HLS 协议生成的 m3u8 索引文件进行进一步处理,为其添加关联信息,以使得在流媒体数据中数据偏移长度相同的第一分片文件和第二分片文件产生关联。 Based on the fragmentation results of S201 and S202, in S203, m3u8 generated based on HLS protocol The index file is further processed to add association information thereto, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated.
具体地, S203 可以通过图 3 所示实施例实现: Specifically, S203 can be implemented by using the embodiment shown in FIG. 3:
在 S301 中,计算每个所述第一分片文件在所述流媒体数据中的数据偏移长度。 In S301, a data offset length of each of the first slice files in the streaming media data is calculated.
由于在 HLS 协议中,流媒体数据是根据播放时长来进行分片的,因此,基于当前分片文件之前的所有分片文件的播放时长、播放帧率和图像分辨率,可以计算出当前分片文件在流媒体数据中的数据偏移长度。 Due to HLS In the protocol, the streaming media data is fragmented according to the playing duration. Therefore, based on the playing duration, the playing frame rate, and the image resolution of all the fragment files before the current fragment file, the current fragment file can be calculated to be in the stream. The length of the data offset in the media data.
在 S302 中,计算每个所述第一分片文件在所述流媒体数据中的数据偏移长度。 In S302, a data offset length of each of the first slice files in the streaming media data is calculated.
由于在 P2P 协议中,流媒体数据是根据数据量来进行分片的,因此,基于当前分片文件之前的所有分片文件的数据量之和,即可以计算出当前分片文件在流媒体数据中的数据偏移长度。 Due to P2P In the protocol, the streaming media data is fragmented according to the amount of data. Therefore, based on the sum of the data amounts of all the fragment files before the current fragment file, the data of the current fragment file in the streaming media data can be calculated. Offset length.
在 S303 中,查找出所述数据偏移长度相同的所述第一分片文件和所述第二分片文件。 In S303, the first fragment file and the second fragment file with the same data offset length are found.
基于 S301 和 S302 的计算结果,对第一分片文件和第二分片文件进行两两匹配,得出数据偏移长度相同的第一分片文件和第二分片文件。 Based on S301 and S302 As a result of the calculation, the first fragment file and the second fragment file are matched in pairs, and the first fragment file and the second fragment file having the same data offset length are obtained.
在 S304 中,根据所述查找的结果,在所述 m3u8 索引文件中,为每个所述第一分片文件的第一分片序号关联第二分片序号,所述第二分片序号为与所述第一分片文件的所述数据偏移长度相同的所述第二分片文件的分片序号。 In S304, according to the result of the searching, in the m3u8 In the index file, the second fragment sequence number is associated with the first fragment sequence number of each of the first fragment files, and the second fragment sequence number is the data offset length from the first fragment file. The same slice number of the second slice file.
根据 S303 的处理结果,在 m3u8 索引文件中,将第二分片文件的第二分片序号关联至与其数据偏移长度相同的第一分片文件的第一分片序号中,从而完成对 m3u8 索引文件关联信息的添加。 According to the processing result of S303, in m3u8 In the index file, the second slice sequence number of the second slice file is associated with the first slice sequence number of the first slice file whose data offset length is the same, thereby completing the addition of the m3u8 index file association information.
在 S204 中,将所述第一分片文件和所述 m3u8 索引文件下发至内容分发网络 CDN ,将所述第二分片文件下发至 P2P 网络,以使流媒体播放客户端分别从 CDN 和 P2P 网络中获取所述流媒体数据并播放。 In S204, the first fragment file and the m3u8 index file are delivered to the content distribution network CDN. And sending the second fragment file to the P2P network, so that the streaming media client obtains the streaming media data from the CDN and the P2P network and plays the data.
在完成了对流媒体数据的分片处理之后,将基于 HLS 协议生成的第一分片文件及添加了关联信息的 m3u8 索引文件下发至 CDN 中分布存储,将基于 P2P 协议生成的第二分片文件下发至 P2P 网络中分布存储,当流媒体播放客户端需要播放相应的节目时,会从 CDN 及 P2P 网络中均进行流媒体数据的拉取,一部分流媒体数据从 CDN 中拉取,剩余部分的流媒体数据从 P2P 网络中拉取,这样一来,相比于现有技术完全从 CDN 中获取流媒体数据的方式,可以有效地减轻 CDN 的服务器压力,相应地减少 CDN 中服务器的布局数量,节省流媒体系统的系统成本。 After the fragmentation processing of the streaming media data is completed, the first fragment file generated based on the HLS protocol and the associated information are added. The m3u8 index file is delivered to the distributed storage in the CDN, and the second fragment file generated based on the P2P protocol is delivered to the P2P. Distributed storage in the network. When the streaming media playback client needs to play the corresponding program, the streaming media data is pulled from both the CDN and the P2P network, and a part of the streaming media data is from the CDN. In the pull, the remaining part of the streaming media data is pulled from the P2P network, so that the CDN can be effectively alleviated compared to the prior art method of completely obtaining streaming media data from the CDN. Server pressure, correspondingly reducing the number of servers in the CDN, saving system costs for streaming media systems.
基于图 2 实施例所述的流媒体的传输方法,接下来,对流媒体播放客户端(以下简称客户端)执行的流媒体播放方法进行详细阐述,如图 4 所示: Based on Figure 2 The streaming media transmission method described in the embodiment is followed by a detailed description of the streaming media playing method performed by the streaming media playing client (hereinafter referred to as the client), as shown in FIG. 4:
在 S401 中,检测播放列表,确定需要播放的节目。 In S401, a playlist is detected to determine which program needs to be played.
客户端本地检测其播放列表,根据播放列表中节目的先后顺序,确定当前需要播放的流媒体节目,并获取该流媒体节目的唯一标识,例如,由 64 位数字组成的该流媒体节目的 ID ,在后续步骤中向 CDN 或者 P2P 网络发送请求以获取流媒体数据时,在请求中均会携带该唯一标识,以使 CDN 或者 P2P 网络一端能够顺利定位到需要向客户端返回的流媒体数据。 The client locally detects the playlist, determines the current streaming program to be played according to the sequence of the programs in the playlist, and obtains a unique identifier of the streaming program, for example, a 64-bit number of the streaming program. ID, in the subsequent step, when sending a request to the CDN or P2P network to obtain streaming media data, the unique identifier is carried in the request to make the CDN or P2P One end of the network can smoothly locate the streaming media data that needs to be returned to the client.
在 S402 中,向 CDN 发送用于获取所述节目的流媒体数据的第一请求。 In S402, a first request for acquiring streaming media data of the program is sent to the CDN.
在 S403 中,接收 CDN 返回的所述流媒体数据的 m3u8 索引文件和预设播放时长内的所述流媒体数据的第一分片文件,所述第一分片文件为根据 HLS 协议将所述流媒体数据切割得到的分片文件,所述 m3u8 索引文件被添加了关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和第二分片文件在所述 m3u8 索引文件中产生关联,所述第二分片文件为根据 P2P 协议将所述流媒体数据切割得到的分片文件。 In S403, receiving the m3u8 of the streaming media data returned by the CDN And a first fragment file of the streaming media data in the index file and the preset playing duration, where the first fragment file is a fragment file obtained by cutting the streaming media data according to the HLS protocol, the m3u8 The index file is added with association information, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file, the second Fragment file based The P2P protocol cuts the obtained streaming media data into a fragment file.
在本实施例中,在客户端进行流媒体数据加载的初始阶段,流媒体数据的起始数据部分是从 CDN 中拉取的,这样做的目的是为了加快流媒体数据的加载速度,尽快地在客户端实现流媒体节目的播放,因此,向 CDN 发送第一请求后, CDN 向客户端返回流媒体数据的起始数据部分,以及返回前述添加了关联信息的 m3u8 索引文件。 In this embodiment, in the initial stage of loading the streaming data data by the client, the starting data portion of the streaming media data is from the CDN. The purpose of this is to speed up the loading of streaming data and to enable streaming of the streaming program on the client as soon as possible. Therefore, after sending the first request to the CDN, the CDN Returns the starting data portion of the streaming media data to the client, and returns the m3u8 index file to which the associated information was added.
流媒体数据的起始数据部分包括了若干第一分片文件,用于实现流媒体节目初始的预设播放时长内的内容播放。例如,所述预设播放时长为一分钟,而每个第一分片文件的播放时长为 10 秒,则 CDN 向客户端返回的是该流媒体数据从数据起始位置开始的 6 个第一分片文件,基于这 6 个第一分片文件,可以实现流媒体节目最初一分钟长度的内容播放。 The starting data portion of the streaming media data includes a plurality of first fragment files for realizing content playback within a preset playback duration of the streaming media program. For example, the preset playing time is one minute, and the playing time of each first piece file is 10 seconds, the CDN returns to the client the 6 first fragment files of the streaming media data starting from the data start position, based on 6 The first fragment file can realize the content playback of the first minute of the streaming program.
这里,预设播放时长为一个可以设置的值,作为一种实现方式,该预设播放时长的取值可以为流媒体系统所预先在 CDN 和客户端之间约定好的一个值;作为另一种实现方式,该预设播放时长的取值也可以由客户端单方面进行要求,如图 5 所示,在 S401 之前,所述方法还包括: Here, the preset playing duration is a value that can be set. As an implementation manner, the value of the preset playing duration may be pre-existing in the streaming media system. A value agreed between the CDN and the client; as another implementation, the value of the preset playback duration can also be unilaterally requested by the client, as shown in Figure 5, in S401. Previously, the method further includes:
S408 ,设置所述预设播放时长。 S408. Set the preset playing duration.
在客户端本地,用户可以根据实际的网络环境,在客户端提供的设置界面中对预设播放时长进行设置,例如,在实际的网络环境较差的情况下,可以适当延长预设播放时长,在加快流媒体节目加载速度的同时,保证客户端有足够的时间可以从 P2P 网络拉取数据,避免在播放数据源由 CDN 向 P2P 网络转换时出现卡顿;相反地,在实际的网络环境较优的情况下,可以适当缩短预设播放时长,以最大程度地减轻 CDN 的服务器压力。 On the client side, the user can set the preset playback duration in the setting interface provided by the client according to the actual network environment. For example, in the case of a poor network environment, the preset playback duration can be appropriately extended. While speeding up the loading speed of streaming programs, ensure that the client has enough time to P2P network pulls data to avoid playing data source from CDN to P2P In the case of network conversion, the default playback time can be appropriately shortened to minimize the server pressure of the CDN.
此时,所述 S402 可以通过图 5 中的 S409 实现: At this time, the S402 can be implemented by S409 in FIG. 5:
在所述第一请求中写入所述预设播放时长; Writing the preset playing duration in the first request;
向 CDN 发送携带了所述预设播放时长的所述第一请求。 Sending the first request carrying the preset playing duration to the CDN.
即,客户端在发送第一请求之前,需要在第一请求中写入预设播放时长,由此一来, CDN 在解析第一请求的过程中,会根据解析得到的预设播放时长确定需要向客户端发送的第一分片文件的数量,由此来实现流媒体数据的下发。 That is, the client needs to write the preset playing duration in the first request before sending the first request, thereby thereby, the CDN In the process of parsing the first request, the number of the first fragment files that need to be sent to the client is determined according to the preset playback duration obtained by the parsing, thereby implementing the delivery of the streaming media data.
在 S404 中,在所述 m3u8 索引文件中确定所述预设播放时长之后的第一个所述第一分片文件的第一分片序号所关联的所述第二分片文件的第二分片序号。 In S404, in the m3u8 Determining, in the index file, a second slice sequence number of the second slice file associated with the first slice sequence number of the first first slice file after the preset play duration.
在 S405 中,向 P2P 网络发送用于获取所述流媒体数据的第二请求,所述第二请求中携带了该第二分片序号。 In S405, to P2P The network sends a second request for acquiring the streaming media data, where the second request carries the second fragment sequence number.
在 S406 中,接收 P2P 网络返回的所述流媒体数据从该第二分片序号起始的所述第二分片文件。 In S406, receive P2P The second piece file of the streaming media data returned by the network starting from the second slice number.
客户端在获取到 CDN 下发的若干第一分片文件之后,需要完成流媒体数据剩余部分的拉取,因此,客户端首先在 m3u8 索引文件中定位到从 CDN 拉取的最后一个第一分片文件,查找到该第一分片文件的下一个第一分片文件的第一分片序号,从而根据 m3u8 索引文件中包含的关联信息,获取到该第一分片序号所关联的第二分片序号,以将其确定为未完成拉取的流媒体数据对应的第一个第二分片文件的第二分片序号,并将该第二分片序号写入第二请求中发送至 P2P 网络。 P2P 网络根据客户端的第二请求,返回剩余的流媒体数据。 The client is getting the CDN After the first fragment files are delivered, the remaining part of the streaming media data needs to be pulled. Therefore, the client first locates the slave CDN in the m3u8 index file. Pulling the last first fragment file to find the first fragment number of the next first fragment file of the first fragment file, thereby obtaining m3u8 according to m3u8 The association information included in the index file obtains the second fragment sequence number associated with the first fragment sequence number to determine the first second fragment file corresponding to the uncompleted streaming media data. Two-segment number, and the second fragment number is written in the second request and sent to P2P network. The P2P network returns the remaining streaming media data according to the second request of the client.
在 S407 中,依序播放接收到的所述第一分片文件和所述第二分片文件。 In S407, the received first fragment file and the second fragment file are sequentially played.
基于图 4 的上述步骤,客户端分别从 CDN 网络中接收到流媒体节目起始部分对应的第一分片文件,以及从 P2P 网络中接收到流媒体节目剩余部分对应的第二分片文件,在本地根据接收到的分片文件的分片序号,依序播放这些分片文件,从而实现了流媒体节目的在线播放。 Based on the above steps in Figure 4, the client is from the CDN The first fragment file corresponding to the beginning of the streaming program is received in the network, and from the P2P The second fragment file corresponding to the remaining part of the streaming program is received in the network, and the fragment files are sequentially played according to the fragment serial number of the received fragment file, thereby realizing online play of the streaming program.
本发明实施例中,在流媒体节目加载之初,由流媒体播放客户端从 CDN 中获取流媒体节目起始部分的流媒体数据,以保证流媒体节目的加载速度,之后,由流媒体播放客户端从 P2P 网络中获取流媒体节目剩余部分的流媒体数据,从而在保证流媒体节目在线播放的流畅性的同时,使得整个在线播放过程不会对 CDN 造成较大的服务器压力,节省了 CDN 的服务器投入成本。 In the embodiment of the present invention, at the beginning of loading of the streaming media program, the streaming media plays the client from the CDN. Obtaining streaming media data at the beginning of the streaming media program to ensure the loading speed of the streaming media program, and then playing the client from the streaming media from the P2P The network obtains the streaming media data of the rest of the streaming program, so as to ensure the smoothness of the online broadcast of the streaming program, the entire online playing process does not cause greater server pressure on the CDN, thereby saving the CDN. Server input costs.
在客户端播放流媒体节目的过程中,用户可能会根据自身的观看意愿对节目的播放进度进行调整,例如,快进播放或者倒退重播,当流媒体节目的当前播放进度跳转至一个新的播放位置时,按照与图 4 所示实施例相同的流媒体数据获取思路,从 CDN 拉取从该播放位置起始的部分流媒体数据,以实现流媒体节目的快速加载,再从 P2P 网络中拉取剩余的流媒体数据,以减轻 CDN 的服务器压力。具体方案如图 6 所示,相比于图 4 所示实施例,该方案在 S406 之后, S407 之前,增加了如下步骤: During the process of playing the streaming program on the client, the user may adjust the progress of the program according to his or her own viewing intention, for example, fast forward playback or reverse playback, when the current playback progress of the streaming program jumps to a new one. When playing the position, follow the diagram 4 The same streaming media data acquisition idea is shown in the embodiment, and part of the streaming media data starting from the playing position is pulled from the CDN to implement fast loading of the streaming media program, and then from P2P. Pull out the remaining streaming media data in the network to relieve the server pressure on the CDN. The specific scheme is shown in Figure 6. Compared to the embodiment shown in Figure 4, the scheme is after S406, S407. Previously, the following steps were added:
S410 ,接收播放位置指示指令,检测所述播放位置指示指令指示的所述节目的播放位置。 S410. Receive a play position indication instruction, and detect a play position of the program indicated by the play position indication instruction.
在本实施例中,所述播放位置指示指令用于指示一个新的播放时间点,当接收到播放位置指示指令之后,流媒体节目将会从该指令指示的播放时间点上开始播放。 In this embodiment, the play position indication instruction is used to indicate a new play time point, and after receiving the play position indication instruction, the streaming program will start playing from the play time point indicated by the instruction.
S411 ,基于所述 m3u8 索引文件,查找所述播放位置对应的第一分片序号,以及查找从所述播放位置起始的所述预设播放时长之后的第一个第一分片序号所关联的第二分片序号。 S411, based on the m3u8 An index file, searching for a first slice serial number corresponding to the play position, and searching for a second slice serial number associated with the first first slice serial number after the preset play duration starting from the play position .
由于第一分片文件是按照播放时长来进行划分的,因此,根据播放位置指示指令所指示的播放时间点以及 m3u8 索引文件中记录的每个第一分片文件的播放时长,可以确定出该播放位置对应的是哪一个第一分片文件,且可以由此获取到该第一分片文件的第一分片序号。在确定出第一分片序号的基础之上,可以进一步确定出从该播放位置起始,预设播放时长之后所需要播放的第二分片文件的第二分片序号。 Since the first slice file is divided according to the play duration, the playback time point indicated by the playback position indication instruction and M3u8 The playing time of each first fragment file recorded in the index file may determine which first fragment file corresponds to the playback position, and may obtain the first fragment of the first fragment file. Serial number. On the basis of determining the first slice serial number, the second slice serial number of the second slice file that needs to be played after the preset play duration starts from the play position may be further determined.
S412 ,向 CDN 发送用于获取所述流媒体数据的第三请求,所述第三请求中携带了所述播放位置对应的第一分片序号。 S412, to CDN Sending a third request for acquiring the streaming media data, where the third request carries a first fragment sequence number corresponding to the play location.
S413 ,接收 CDN 根据该第一分片序号返回的所述流媒体数据从所述播放位置起始的所述预设播放时长内的所述第一分片文件。 S413, receiving CDN And the first fragment file within the preset playing duration starting from the playing position, according to the first fragment serial number.
S414 ,向 P2P 网络发送用于获取所述流媒体数据的第四请求,所述第四请求中携带了从所述播放位置起始的所述预设播放时长之后的第一个第一分片序号所关联的第二分片序号。 S414, to P2P The network sends a fourth request for acquiring the streaming media data, where the fourth request carries a first first fragment serial number associated with the preset playing duration starting from the playing position. Second slice number.
S415 ,接收 P2P 网络从该第二分片序号起始的所述第二分片文件。 S415. Receive the second fragment file that is started by the P2P network from the second fragment sequence number.
客户端将 S411 中查找出的第一分片序号和第二分片序号携带在流媒体数据的获取请求中,分别发送给 CDN 和 P2P 网络,由此分别获取到 CDN 和 P2P 网络根据相应的请求而返回的所述播放位置之后的流媒体数据,以快速、流畅地实现流媒体节目的跳转播放。 The client carries the first fragment sequence number and the second fragment sequence number found in S411 in the acquisition request of the streaming media data, and sends the result to the acquisition request of the streaming media data respectively. CDN and P2P networks, respectively, to obtain CDN and P2P The streaming media data after the playback position returned by the network according to the corresponding request enables fast and smooth playback of the streaming program.
在上述流媒体播放过程中,对于流媒体节目的起始部分,由于是从 CDN 中获取数据,因此,一方面加快了流媒体节目在线播放的加载速度,另一方面,由于第一分片文件为基于 HLS 协议切割得到的 TS 分片文件,每个分片的播放时长很短,因此,在客户端也可以快速地选择和切换在线播放的码率,以适应不同带宽条件下的播放环境。对于流媒体节目的剩余部分,由于是从 P2P 网络中获取数据,因此,能够很大程度地减轻 CDN 的服务器压力,有效地降低了 CDN 的服务器和带宽投入,并减轻 CDN 的网络拥塞状况,以整体提高各个客户端从 CDN 上进行流媒体节目在线播放的加载速度。 In the above streaming media playback process, for the beginning part of the streaming media program, since it is from the CDN Obtaining data, therefore, on the one hand, speeding up the loading speed of online streaming of streaming programs, on the other hand, because the first fragment file is a TS cut based on HLS protocol The fragmentation file has a short playback time for each slice. Therefore, the client can also quickly select and switch the bit rate of the online play to adapt to the playback environment under different bandwidth conditions. For the rest of the streaming program, since it is from Obtaining data in a P2P network, thus greatly reducing the server pressure on the CDN, effectively reducing the server and bandwidth investment of the CDN, and reducing the CDN The network congestion condition is to improve the loading speed of each client's online streaming of streaming programs from the CDN.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本发明实施例的实施过程构成任何限定。 It should be understood that the size of the sequence of the steps in the above embodiments does not imply a sequence of executions, and the order of execution of the processes should be determined by its function and internal logic, and should not be construed as limiting the implementation of the embodiments of the present invention.
对应于上文图 2 至图 3 实施例所述的 流媒体的传输 方法,图 7 示出了本发明实施例提供的 流媒体的传输 装置的结构框图, 所述 流媒体的传输 装置 可以是内置于第二服务器模块 12 或第二服务器模块 12 的应用系统内的软件单元、硬件单元或者是软硬结合的单元。 为了便于说明,仅示出了与本实施例相关的部分。 Corresponding to the transmission method of the streaming media described in the foregoing embodiments of FIG. 2 to FIG. 3, FIG. 7 shows an embodiment of the present invention. A structural block diagram of a streaming media transmission device, which may be built in the second server module 12 or the second server module 12 Software units, hardware units, or units that are combined with software and hardware within the application system. For the convenience of explanation, only the parts related to the present embodiment are shown.
参照图 7 ,该装置包括: Referring to Figure 7, the device includes:
第一分割单元 71 ,根据 HLS 协议将流媒体数据切割成多个第一分片文件,并生成所述流媒体数据的 m3u8 索引文件。 The first dividing unit 71 cuts the streaming media data into a plurality of first fragment files according to the HLS protocol, and generates the streaming media data. M3u8 index file.
在 HLS 协议之下对流媒体数据进行分片处理,将流媒体数据分片为连续的、很短时长的分片文件;在对流媒体数据进行分片处理的同时,按照 HLS 协议的规定,生成这些分片文件的 m3u8 索引文件,在生成的 m3u8 索引文件中记录了个每个分片文件的分片序号、播放时长等信息。 At HLS The streaming media data is fragmented under the protocol, and the streaming media data is fragmented into continuous, short-length fragment files; while the streaming media data is fragmented, these fragments are generated according to the HLS protocol. Documentary The m3u8 index file records the fragment number and playback duration of each fragment file in the generated m3u8 index file.
第二分割单元 72 ,根据 P2P 协议将所述流媒体数据切割成多个第二分片文件。 The second dividing unit 72 cuts the streaming media data into a plurality of second fragment files according to a P2P protocol.
在 P2P 协议之下对流媒体数据进行分片处理,将流媒体数据分片为连续的、数据量相同的分片文件,例如,将流媒体数据分片为数据量为 1k 的若干分片文件。 At P2P The streaming media data is fragmented under the protocol, and the streaming media data is sliced into consecutive file files of the same amount of data. For example, the streaming media data is fragmented into a plurality of fragment files having a data volume of 1 k.
信息添加单元 73 ,为所述 m3u8 索引文件中添加关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和所述第二分片文件在所述 m3u8 索引文件中产生关联。 Information adding unit 73, for the m3u8 The association information is added to the index file such that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file.
所述数据偏移长度,是指以流媒体数据的数据头作为基准点,向后开始计算数据的偏移量,分片文件的数据偏移长度,即该分片文件的数据头相对于其所属的流媒体数据的数据头的偏移量。在信息添加单元 73 中,对基于 HLS 协议生成的 m3u8 索引文件进行进一步处理,为其添加关联信息,以使得在流媒体数据中数据偏移长度相同的第一分片文件和第二分片文件产生关联。 The data offset length refers to the data head of the streaming media data as a reference point, and the offset of the data is calculated backward, and the data offset length of the fragment file is the data header of the fragment file relative to the data header. The offset of the data header of the associated streaming media data. Information addition unit In 73, the m3u8 generated based on the HLS protocol The index file is further processed to add association information thereto, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated.
下发单元 74 ,将所述第一分片文件和所述 m3u8 索引文件下发至内容分发网络 CDN ,将所述第二分片文件下发至 P2P 网络,以使流媒体播放客户端分别从 CDN 和 P2P 网络中获取所述流媒体数据并播放。 The issuing unit 74 delivers the first fragment file and the m3u8 index file to the content distribution network CDN And sending the second fragment file to the P2P network, so that the streaming media client obtains the streaming media data from the CDN and the P2P network and plays the data.
在完成了对流媒体数据的分片处理之后,将基于 HLS 协议生成的第一分片文件及添加了关联信息的 m3u8 索引文件下发至 CDN 中分布存储,将基于 P2P 协议生成的第二分片文件下发至 P2P 网络中分布存储,当流媒体播放客户端需要播放相应的节目时,会从 CDN 及 P2P 网络中均进行流媒体数据的拉取,一部分流媒体数据从 CDN 中拉取,剩余部分的流媒体数据从 P2P 网络中拉取,这样一来,相比于现有技术完全从 CDN 中获取流媒体数据的方式,可以有效地减轻 CDN 的服务器压力,相应地减少 CDN 中服务器的布局数量,节省流媒体系统的系统成本。 After the fragmentation processing of the streaming media data is completed, the first fragment file generated based on the HLS protocol and the associated information are added. The m3u8 index file is delivered to the distributed storage in the CDN, and the second fragment file generated based on the P2P protocol is delivered to the P2P. Distributed storage in the network. When the streaming media playback client needs to play the corresponding program, the streaming media data is pulled from both the CDN and the P2P network, and a part of the streaming media data is from the CDN. In the pull, the remaining part of the streaming media data is pulled from the P2P network, so that the CDN can be effectively alleviated compared to the prior art method of completely obtaining streaming media data from the CDN. Server pressure, correspondingly reducing the number of servers in the CDN, saving system costs for streaming media systems.
可选地,所述信息添加单元 73 包括: Optionally, the information adding unit 73 includes:
第一计算子单元,计算每个所述第一分片文件在所述流媒体数据中的数据偏移长度; a first calculating subunit, calculating a data offset length of each of the first fragment files in the streaming media data;
第二计算子单元,计算每个所述第二分片文件在所述流媒体数据中的数据偏移长度; a second calculating subunit, calculating a data offset length of each of the second fragment files in the streaming media data;
查找子单元,查找出所述数据偏移长度相同的所述第一分片文件和所述第二分片文件; Finding a subunit, and finding the first fragment file and the second fragment file with the same data offset length;
关联子单元,根据所述查找的结果,在所述 m3u8 索引文件中,为每个所述第一分片文件的第一分片序号关联第二分片序号,所述第二分片序号为与所述第一分片文件的所述数据偏移长度相同的所述第二分片文件的分片序号。 Associated subunits, according to the result of the finding, in the m3u8 In the index file, the second fragment sequence number is associated with the first fragment sequence number of each of the first fragment files, and the second fragment sequence number is the data offset length from the first fragment file. The same slice number of the second slice file.
对应于上文实施例所述的 流媒体的播放 方法,图 8 示出了本发明实施例提供的 流媒体的播放 装置的结构框图, 所述 流媒体的播放 装置 可以是内置于流媒体播放客户端 15 或流媒体播放客户端 15 的应用系统内的软件单元、硬件单元或者是软硬结合的单元。 为了便于说明,仅示出了与本实施例相关的部分。 Corresponding to the playing method of the streaming media described in the above embodiments, FIG. 8 shows the playing of the streaming media provided by the embodiment of the present invention. A block diagram of the device, the streaming media playing device may be built in the streaming media playing client 15 or the streaming media playing client 15 Software units, hardware units, or units that are combined with software and hardware within the application system. For the convenience of explanation, only the parts related to the present embodiment are shown.
参照图 8 ,该装置包括: Referring to Figure 8, the device includes:
检测单元 81 ,检测播放列表,确定需要播放的节目 。 The detecting unit 81 detects a playlist and determines a program to be played.
客户端本地检测其播放列表,根据播放列表中节目的先后顺序,确定当前需要播放的流媒体节目,并获取该流媒体节目的唯一标识,在后续向 CDN 或者 P2P 网络发送请求以获取流媒体数据时,在请求中均会携带该唯一标识,以使 CDN 或者 P2P 网络一端能够顺利定位到需要向客户端返回的流媒体数据。 The client locally detects its playlist, determines the current streaming media program to be played according to the order of the programs in the playlist, and obtains the unique identifier of the streaming media program, in subsequent CDN or P2P When the network sends a request to obtain the streaming media data, the unique identifier is carried in the request, so that one end of the CDN or the P2P network can successfully locate the streaming media data that needs to be returned to the client.
第一发送单元 82 ,向内容分发网络 CDN 发送用于获取所述节目的流媒体数据的第一请求 。 The first transmitting unit 82 transmits a first request for acquiring streaming media data of the program to the content distribution network CDN.
第一接收单元 83 ,接收 CDN 返回的所述流媒体数据的 m3u8 索引文件和预设播放时长内的所述流媒体数据的第一分片文件,所述第一分片文件为根据 HLS 协议将所述流媒体数据切割得到的分片文件,所述 m3u8 索引文件被添加了关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和第二分片文件在所述 m3u8 索引文件中产生关联,所述第二分片文件为根据 P2P 协议将所述流媒体数据切割得到的分片文件 。 The first receiving unit 83 receives the m3u8 of the streaming media data returned by the CDN And a first fragment file of the streaming media data in the index file and the preset playing duration, where the first fragment file is a fragment file obtained by cutting the streaming media data according to the HLS protocol, the m3u8 The index file is added with association information, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file, the second Fragment file based The P2P protocol cuts the obtained streaming media data into a fragment file.
在本实施例中,在客户端进行流媒体数据加载的初始阶段,流媒体数据的起始数据部分是从 CDN 中拉取的,这样做的目的是为了加快流媒体数据的加载速度,尽快地在客户端实现流媒体节目的播放,因此,向 CDN 发送第一请求后, CDN 向客户端返回流媒体数据的起始数据部分,以及返回前述添加了关联信息的 m3u8 索引文件。 In this embodiment, in the initial stage of loading the streaming data data by the client, the starting data portion of the streaming media data is from the CDN. The purpose of this is to speed up the loading of streaming data and to enable streaming of the streaming program on the client as soon as possible. Therefore, after sending the first request to the CDN, the CDN Returns the starting data portion of the streaming media data to the client, and returns the m3u8 index file to which the associated information was added.
确定单元 84 ,在所述 m3u8 索引文件中确定所述预设播放时长之后的第一个所述第一分片文件的第一分片序号所关联的所述第二分片文件的第二分片序号 。 Determining unit 84 at the m3u8 Determining, in the index file, a second slice sequence number of the second slice file associated with the first slice sequence number of the first first slice file after the preset play duration.
第二发送单元 85 ,向 P2P 网络发送用于获取所述流媒体数据的第二请求,所述第二请求中携带了该第二分片序号 。 Second transmitting unit 85, to P2P The network sends a second request for acquiring the streaming media data, where the second request carries the second fragment serial number.
第二接收单元 86 ,接收 P2P 网络返回的所述流媒体数据从该第二分片序号起始的所述第二分片文件 。 The second receiving unit 86 receives the second fragment file starting from the second fragment serial number of the streaming media data returned by the P2P network. .
客户端在获取到 CDN 下发的若干第一分片文件之后,需要完成流媒体数据剩余部分的拉取,因此,客户端首先在 m3u8 索引文件中定位到从 CDN 拉取的最后一个第一分片文件,查找到该第一分片文件的下一个第一分片文件的第一分片序号,从而根据 m3u8 索引文件中包含的关联信息,获取到该第一分片序号所关联的第二分片序号,以将其确定为未完成拉取的流媒体数据对应的第一个第二分片文件的第二分片序号,并将该第二分片序号写入第二请求中发送至 P2P 网络。 P2P 网络根据客户端的第二请求,返回剩余的流媒体数据。 The client is getting the CDN After the first fragment files are delivered, the remaining part of the streaming media data needs to be pulled. Therefore, the client first locates the slave CDN in the m3u8 index file. Pulling the last first fragment file to find the first fragment number of the next first fragment file of the first fragment file, thereby obtaining m3u8 according to m3u8 The association information included in the index file obtains the second fragment sequence number associated with the first fragment sequence number to determine the first second fragment file corresponding to the uncompleted streaming media data. Two-segment number, and the second fragment number is written in the second request and sent to P2P network. The P2P network returns the remaining streaming media data according to the second request of the client.
播放单元 87 ,依序播放接收到的所述第一分片文件和所述第二分片文件。 The playing unit 87 plays the received first fragment file and the second fragment file sequentially.
客户端分别从 CDN 网络中接收到流媒体节目起始部分对应的第一分片文件,以及从 P2P 网络中接收到流媒体节目剩余部分对应的第二分片文件,在本地根据接收到的分片文件的分片序号,依序播放这些分片文件,从而实现了流媒体节目的在线播放。 The client receives the first fragment file corresponding to the beginning of the streaming program from the CDN network, and from the P2P The second fragment file corresponding to the remaining part of the streaming program is received in the network, and the fragment files are sequentially played according to the fragment serial number of the received fragment file, thereby realizing online play of the streaming program.
可选地,所述装置还包括: Optionally, the device further includes:
设置单元,用于设置所述预设播放时长; a setting unit, configured to set the preset playing duration;
所述第一发送单元 82 包括: The first sending unit 82 includes:
写入子单元,在所述第一请求中写入所述预设播放时长; Writing to the subunit, writing the preset play duration in the first request;
发送子单元,向 CDN 发送携带了所述预设播放时长的所述第一请求。 Sending a subunit, sending the first request carrying the preset playing duration to the CDN.
即,客户端在发送第一请求之前,需要在第一请求中写入预设播放时长,由此一来, CDN 在解析第一请求的过程中,会根据解析得到的预设播放时长确定需要向客户端发送的第一分片文件的数量,由此来实现流媒体数据的下发。 That is, the client needs to write the preset playing duration in the first request before sending the first request, thereby thereby, the CDN In the process of parsing the first request, the number of the first fragment files that need to be sent to the client is determined according to the preset playback duration obtained by the parsing, thereby implementing the delivery of the streaming media data.
用户可以根据实际的网络环境,在客户端提供的设置界面中对预设播放时长进行设置,例如,在实际的网络环境较差的情况下,可以适当延长预设播放时长,在加快流媒体节目加载速度的同时,保证客户端有足够的时间可以从 P2P 网络拉取数据,避免在播放数据源由 CDN 向 P2P 网络转换时出现卡顿;相反地,在实际的网络环境较优的情况下,可以适当缩短预设播放时长,以最大程度地减轻 CDN 的服务器压力。 The user can set the preset playback duration in the setting interface provided by the client according to the actual network environment. For example, in the case of a poor network environment, the preset playback duration can be appropriately extended, and the streaming program is accelerated. At the same time of loading speed, ensure that the client has enough time to P2P network pulls data to avoid playing data source from CDN to P2P In the case of network conversion, the default playback time can be appropriately shortened to minimize the server pressure of the CDN.
在客户端播放流媒体节目的过程中,用户可能会根据自身的观看意愿对节目的播放进度进行调整,例如,快进播放或者倒退重播,当流媒体节目的当前播放进度跳转至一个新的播放位置时,从 CDN 拉取从该播放位置起始的部分流媒体数据,以实现流媒体节目的快速加载,再从 P2P 网络中拉取剩余的流媒体数据,以减轻 CDN 的服务器压力。因此,可选地,所述装置还包括: During the process of playing the streaming program on the client, the user may adjust the progress of the program according to his or her own viewing intention, for example, fast forward playback or reverse playback, when the current playback progress of the streaming program jumps to a new one. When playing the position, from The CDN pulls part of the streaming media data starting from the playing position to implement fast loading of the streaming program, and then pulls the remaining streaming media data from the P2P network to mitigate the CDN. Server pressure. Therefore, optionally, the device further includes:
指令接收单元,接收播放位置指示指令,检测所述播放位置指示指令指示的所述节目的播放位置。 The instruction receiving unit receives the play position indication instruction, and detects a play position of the program indicated by the play position indication instruction.
所述播放位置指示指令用于指示一个新的播放时间点,当接收到播放位置指示指令之后,流媒体节目将会从该指令指示的播放时间点上开始播放。 The play position indication instruction is used to indicate a new play time point, and after receiving the play position indication instruction, the streaming program will start playing from the play time point indicated by the instruction.
查找单元,基于所述 m3u8 索引文件,查找所述播放位置对应的第一分片序号,以及查找从所述播放位置起始的所述预设播放时长之后的第一个第一分片序号所关联的第二分片序号。 Search unit based on the m3u8 An index file, searching for a first slice serial number corresponding to the play position, and searching for a second slice serial number associated with the first first slice serial number after the preset play duration starting from the play position .
由于第一分片文件是按照播放时长来进行划分的,因此,根据播放位置指示指令所指示的播放时间点以及 m3u8 索引文件中记录的每个第一分片文件的播放时长,可以确定出该播放位置对应的是哪一个第一分片文件,且可以由此获取到该第一分片文件的第一分片序号。在确定出第一分片序号的基础之上,可以进一步确定出从该播放位置起始,预设播放时长之后所需要播放的第二分片文件的第二分片序号。 Since the first slice file is divided according to the play duration, the playback time point indicated by the playback position indication instruction and M3u8 The playing time of each first fragment file recorded in the index file may determine which first fragment file corresponds to the playback position, and may obtain the first fragment of the first fragment file. Serial number. On the basis of determining the first slice serial number, the second slice serial number of the second slice file that needs to be played after the preset play duration starts from the play position may be further determined.
第三发送单元,向 CDN 发送用于获取所述流媒体数据的第三请求,所述第三请求中携带了所述播放位置对应的第一分片序号; Third sending unit, to CDN Sending a third request for acquiring the streaming media data, where the third request carries a first fragment sequence number corresponding to the play location;
第三接收单元,接收 CDN 根据该第一分片序号返回的所述流媒体数据从所述播放位置起始的所述预设播放时长内的所述第一分片文件; Third receiving unit, receiving CDN And the first fragment file within the preset playing duration starting from the playing position by the streaming media data returned according to the first fragment serial number;
第四发送单元,向 P2P 网络发送用于获取所述流媒体数据的第四请求,所述第四请求中携带了从所述播放位置起始的所述预设播放时长之后的第一个第一分片序号所关联的第二分片序号; Fourth sending unit, to P2P The network sends a fourth request for acquiring the streaming media data, where the fourth request carries a first first fragment serial number associated with the preset playing duration starting from the playing position. Second slice serial number;
第四接收单元,接收 P2P 网络从该第二分片序号起始的所述第二分片文件。 The fourth receiving unit receives the second fragment file starting from the second fragment serial number of the P2P network.
客户端将查找出的第一分片序号和第二分片序号携带在流媒体数据的获取请求中,分别发送给 CDN 和 P2P 网络,由此分别获取到 CDN 和 P2P 网络根据相应的请求而返回的所述播放位置之后的流媒体数据,以快速、流畅地实现流媒体节目的跳转播放。 The first fragment sequence number and the second fragment sequence number that the client finds are carried in the acquisition request of the streaming media data, and are respectively sent to the CDN and The P2P network obtains the streaming media data after the playback position returned by the CDN and the P2P network according to the corresponding request, so as to quickly and smoothly realize the jump play of the streaming program.
所属领域的技术人员可以清楚地了 解到,为了描 述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。 Those skilled in the art can clearly understand that in order to describe The convenience and simplicity of the description are only exemplified by the division of the above functional units and modules. In practical applications, the above function assignment can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into Different functional units or modules to perform all or part of the functions described above. Each functional unit and module in the embodiment may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit, and the integrated unit may be hardware. Formal implementation can also be implemented in the form of software functional units. In addition, the specific names of the respective functional units and modules are only for the purpose of facilitating mutual differentiation, and are not intended to limit the scope of protection of the present application. For the specific working process of the unit and the module in the foregoing system, reference may be made to the corresponding process in the foregoing method embodiment, and details are not described herein again.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。 Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods for implementing the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present invention.
在本发明所提供的实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的系统实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。 In the embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the system embodiment described above is merely illustrative. For example, the division of the module or unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be used. Combinations can be integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in electrical, mechanical or other form.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。 The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。 In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器( processor )执行本发明实施例各个实施例所述方法的全部或部分步骤。而前述的存储介质包括: U 盘、移动硬盘、只读存储器( ROM , Read-Only Memory )、随机存取存储器( RAM , Random Access Memory )、磁碟或者光盘等各种可以存储程序代码的介质。 The integrated unit, if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the embodiments of the present invention may contribute to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage. The medium includes a number of instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor ( Processor) Performs all or part of the steps of the method described in the various embodiments of the embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, and a read only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) ) A variety of media that can store program code, such as a disk or an optical disk.
以上所述实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明实施例各实施例技术方案的精神和范围 。 The embodiments described above are only for explaining the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art will understand that The technical solutions described in the examples are modified, or some of the technical features are equivalently replaced; and the modifications or substitutions do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. .
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。 The above is only the preferred embodiment of the present invention, and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection of the present invention. Within the scope.

Claims (10)

  1. 一种流媒体的传输方法,其特征在于,包括: A method for transmitting streaming media, characterized in that it comprises:
    根据 HLS 协议将流媒体数据切割成多个第一分片文件,并生成所述流媒体数据的 m3u8 索引文件;Cutting the streaming media data into a plurality of first fragment files according to the HLS protocol, and generating the m3u8 of the streaming media data Index file
    根据 P2P 协议将所述流媒体数据切割成多个第二分片文件;Cutting the streaming media data into a plurality of second fragment files according to a P2P protocol;
    为所述 m3u8 索引文件中添加关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和所述第二分片文件在所述 m3u8 索引文件中产生关联;Adding association information to the m3u8 index file, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are in the An association is generated in the m3u8 index file;
    将所述第一分片文件和所述 m3u8 索引文件下发至内容分发网络 CDN ,将所述第二分片文件下发至 P2P 网络,以使流媒体播放客户端分别从 CDN 和 P2P 网络中获取所述流媒体数据并播放。And sending the first fragment file and the m3u8 index file to the content distribution network CDN, and delivering the second fragment file to the P2P The network is such that the streaming media client obtains the streaming media data from the CDN and the P2P network and plays the data.
  2. 如权利要求 1 所述的方法,其特征在于,所述为所述 m3u8 索引文件添加关联信息包括:The method of claim 1, wherein the adding the associated information to the m3u8 index file comprises:
    计算每个所述第一分片文件在所述流媒体数据中的数据偏移长度;Calculating a data offset length of each of the first fragment files in the streaming media data;
    计算每个所述第二分片文件在所述流媒体数据中的数据偏移长度;Calculating a data offset length of each of the second fragment files in the streaming media data;
    查找出所述数据偏移长度相同的所述第一分片文件和所述第二分片文件;Finding the first fragment file and the second fragment file with the same data offset length;
    根据所述查找的结果,在所述 m3u8 索引文件中,为每个所述第一分片文件的第一分片序号关联第二分片序号,所述第二分片序号为与所述第一分片文件的所述数据偏移长度相同的所述第二分片文件的分片序号。According to the result of the search, in the m3u8 In the index file, the second fragment sequence number is associated with the first fragment sequence number of each of the first fragment files, and the second fragment sequence number is the data offset length from the first fragment file. The same slice number of the second slice file.
  3. 一种流媒体的播放方法,其特征在于,包括:A streaming media playing method, comprising:
    检测播放列表,确定需要播放的节目;Detecting playlists and determining which programs need to be played;
    向内容分发网络 CDN 发送用于获取所述节目的流媒体数据的第一请求;Transmitting, to the content distribution network CDN, a first request for acquiring streaming media data of the program;
    接收 CDN 返回的所述流媒体数据的 m3u8 索引文件和预设播放时长内的所述流媒体数据的第一分片文件,所述第一分片文件为根据 HLS 协议将所述流媒体数据切割得到的分片文件,所述 m3u8 索引文件被添加了关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和第二分片文件在所述 m3u8 索引文件中产生关联,所述第二分片文件为根据 P2P 协议将所述流媒体数据切割得到的分片文件;Receiving the m3u8 of the streaming media data returned by the CDN And a first fragment file of the streaming media data in the index file and the preset playing duration, where the first fragment file is a fragment file obtained by cutting the streaming media data according to the HLS protocol, the m3u8 The index file is added with association information, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file, the second Fragment file based a slice file obtained by cutting the streaming media data by the P2P protocol;
    在所述 m3u8 索引文件中确定所述预设播放时长之后的第一个所述第一分片文件的第一分片序号所关联的所述第二分片文件的第二分片序号;In the m3u8 Determining, in the index file, a second slice sequence number of the second slice file associated with the first slice sequence number of the first first slice file after the preset play duration;
    向 P2P 网络发送用于获取所述流媒体数据的第二请求,所述第二请求中携带了该第二分片序号;Sending, to the P2P network, a second request for acquiring the streaming media data, where the second request carries the second fragment serial number;
    接收 P2P 网络返回的所述流媒体数据从该第二分片序号起始的所述第二分片文件;Receiving, by the second slice file, the streaming media data returned by the P2P network starting from the second fragment sequence number;
    依序播放接收到的所述第一分片文件和所述第二分片文件。The received first fragment file and the second fragment file are sequentially played.
  4. 如权利要求 3 所述的方法,其特征在于,在所述检测播放列表之前,所述方法还包括:The method of claim 3, wherein before the detecting the playlist, the method further comprises:
    设置所述预设播放时长;Setting the preset playing duration;
    所述向 CDN 发送用于获取所述节目的流媒体数据的第一请求包括:The sending, by the CDN, a first request for acquiring streaming media data of the program includes:
    在所述第一请求中写入所述预设播放时长;Writing the preset playing duration in the first request;
    向 CDN 发送携带了所述预设播放时长的所述第一请求。Sending the first request carrying the preset playing duration to the CDN.
  5. 如权利要求 1 所述的方法,其特征在于,在所述接收 P2P 网络返回的所述流媒体数据从该第二分片序号起始的所述第二分片文件之后,所述依序播放接收到的所述第一分片文件和所述第二分片文件之前,所述方法还包括:The method of claim 1 wherein said receiving P2P After the second media file that is returned by the network, the first fragment file and the second fragment file are sequentially played after the second fragment file starting from the second fragment number. Previously, the method further includes:
    接收播放位置指示指令,检测所述播放位置指示指令指示的所述节目的播放位置;Receiving a play position indication instruction, detecting a play position of the program indicated by the play position indication instruction;
    基于所述 m3u8 索引文件,查找所述播放位置对应的第一分片序号,以及查找从所述播放位置起始的所述预设播放时长之后的第一个第一分片序号所关联的第二分片序号;Based on the m3u8 An index file, searching for a first slice serial number corresponding to the play position, and searching for a second slice serial number associated with the first first slice serial number after the preset play duration starting from the play position ;
    向 CDN 发送用于获取所述流媒体数据的第三请求,所述第三请求中携带了所述播放位置对应的第一分片序号;To CDN Sending a third request for acquiring the streaming media data, where the third request carries a first fragment sequence number corresponding to the play location;
    接收 CDN 根据该第一分片序号返回的所述流媒体数据从所述播放位置起始的所述预设播放时长内的所述第一分片文件;Receiving CDN And the first fragment file within the preset playing duration starting from the playing position by the streaming media data returned according to the first fragment serial number;
    向 P2P 网络发送用于获取所述流媒体数据的第四请求,所述第四请求中携带了从所述播放位置起始的所述预设播放时长之后的第一个第一分片序号所关联的第二分片序号;To P2P The network sends a fourth request for acquiring the streaming media data, where the fourth request carries a first first fragment serial number associated with the preset playing duration starting from the playing position. Second slice serial number;
    接收 P2P 网络从该第二分片序号起始的所述第二分片文件。Receiving, by the P2P network, the second fragment file starting from the second fragment sequence number.
  6. 一种流媒体的传输装置,其特征在于,包括:A streaming media transmission device, comprising:
    第一分割单元,用于根据 HLS 协议将流媒体数据切割成多个第一分片文件,并生成所述流媒体数据的 m3u8 索引文件;a first dividing unit, configured to cut the streaming media data into a plurality of first fragment files according to the HLS protocol, and generate the m3u8 of the streaming media data Index file
    第二分割单元,用于根据 P2P 协议将所述流媒体数据切割成多个第二分片文件;a second dividing unit, configured to cut the streaming media data into a plurality of second fragment files according to a P2P protocol;
    信息添加单元,用于为所述 m3u8 索引文件中添加关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和所述第二分片文件在所述 m3u8 索引文件中产生关联;An information adding unit for the m3u8 Adding association information in the index file, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are in the m3u8 An association is generated in the index file;
    下发单元,用于将所述第一分片文件和所述 m3u8 索引文件下发至内容分发网络 CDN ,将所述第二分片文件下发至 P2P 网络,以使流媒体播放客户端分别从 CDN 和 P2P 网络中获取所述流媒体数据并播放。a sending unit, configured to deliver the first fragment file and the m3u8 index file to a content distribution network CDN, and deliver the second fragment file to P2P The network is such that the streaming media client obtains the streaming media data from the CDN and the P2P network and plays the data.
  7. 如权利要求 6 所述的装置,其特征在于,所述信息添加单元包括:The device according to claim 6, wherein the information adding unit comprises:
    第一计算子单元,用于计算每个所述第一分片文件在所述流媒体数据中的数据偏移长度;a first calculating subunit, configured to calculate a data offset length of each of the first fragment files in the streaming media data;
    第二计算子单元,用于计算每个所述第二分片文件在所述流媒体数据中的数据偏移长度;a second calculating subunit, configured to calculate a data offset length of each of the second fragment files in the streaming media data;
    查找子单元,用于查找出所述数据偏移长度相同的所述第一分片文件和所述第二分片文件;a searching subunit, configured to find the first fragment file and the second fragment file with the same data offset length;
    关联子单元,用于根据所述查找的结果,在所述 m3u8 索引文件中,为每个所述第一分片文件的第一分片序号关联第二分片序号,所述第二分片序号为与所述第一分片文件的所述数据偏移长度相同的所述第二分片文件的分片序号。An associated subunit for using the m3u8 based on the result of the lookup In the index file, the second fragment sequence number is associated with the first fragment sequence number of each of the first fragment files, and the second fragment sequence number is the data offset length from the first fragment file. The same slice number of the second slice file.
  8. 一种流媒体的播放装置,其特征在于,包括:A streaming media playing device, comprising:
    检测单元,用于检测播放列表,确定需要播放的节目;a detecting unit, configured to detect a playlist, and determine a program to be played;
    第一发送单元,用于向内容分发网络 CDN 发送用于获取所述节目的流媒体数据的第一请求;a first sending unit, configured to send, to the content distribution network CDN, a first request for acquiring streaming media data of the program;
    第一接收单元,用于接收 CDN 返回的所述流媒体数据的 m3u8 索引文件和预设播放时长内的所述流媒体数据的第一分片文件,所述第一分片文件为根据 HLS 协议将所述流媒体数据切割得到的分片文件,所述 m3u8 索引文件被添加了关联信息,以使在所述流媒体数据中数据偏移长度相同的所述第一分片文件和第二分片文件在所述 m3u8 索引文件中产生关联,所述第二分片文件为根据 P2P 协议将所述流媒体数据切割得到的分片文件;a first receiving unit, configured to receive the m3u8 of the streaming media data returned by the CDN And a first fragment file of the streaming media data in the index file and the preset playing duration, where the first fragment file is a fragment file obtained by cutting the streaming media data according to the HLS protocol, the m3u8 The index file is added with association information, so that the first fragment file and the second fragment file having the same data offset length in the streaming media data are associated in the m3u8 index file, the second Fragment file based a slice file obtained by cutting the streaming media data by the P2P protocol;
    确定单元,用于在所述 m3u8 索引文件中确定所述预设播放时长之后的第一个所述第一分片文件的第一分片序号所关联的所述第二分片文件的第二分片序号;Determining unit for the m3u8 Determining, in the index file, a second slice sequence number of the second slice file associated with the first slice sequence number of the first first slice file after the preset play duration;
    第二发送单元,用于向 P2P 网络发送用于获取所述流媒体数据的第二请求,所述第二请求中携带了该第二分片序号;Second sending unit for P2P The network sends a second request for acquiring the streaming media data, where the second request carries the second fragment serial number;
    第二接收单元,用于接收 P2P 网络返回的所述流媒体数据从该第二分片序号起始的所述第二分片文件;a second receiving unit, configured to receive, by the P2P network, the second fragment file that is started by the second media number of the streaming media data;
    播放单元,用于依序播放接收到的所述第一分片文件和所述第二分片文件。a playing unit, configured to sequentially play the received first fragment file and the second fragment file.
  9. 如权利要求 8 所述的装置,其特征在于,所述装置还包括:The device of claim 8 further comprising:
    设置单元,用于设置所述预设播放时长;a setting unit, configured to set the preset playing duration;
    所述第一发送单元包括:The first sending unit includes:
    写入子单元,用于在所述第一请求中写入所述预设播放时长;Writing to the subunit, configured to write the preset play duration in the first request;
    发送子单元,用于向 CDN 发送携带了所述预设播放时长的所述第一请求。And a sending subunit, configured to send, to the CDN, the first request that carries the preset playing duration.
  10. 如权利要求 8 所述的装置,其特征在于,所述装置还包括:The device of claim 8 further comprising:
    指令接收单元,用于接收播放位置指示指令,检测所述播放位置指示指令指示的所述节目的播放位置;The instruction receiving unit is configured to receive a play position indication instruction, and detect a play position of the program indicated by the play position indication instruction;
    查找单元,用于基于所述 m3u8 索引文件,查找所述播放位置对应的第一分片序号,以及查找从所述播放位置起始的所述预设播放时长之后的第一个第一分片序号所关联的第二分片序号;a search unit for based on the m3u8 An index file, searching for a first slice serial number corresponding to the play position, and searching for a second slice serial number associated with the first first slice serial number after the preset play duration starting from the play position ;
    第三发送单元,用于向 CDN 发送用于获取所述流媒体数据的第三请求,所述第三请求中携带了所述播放位置对应的第一分片序号;a third transmitting unit for transmitting to the CDN Sending a third request for acquiring the streaming media data, where the third request carries a first fragment sequence number corresponding to the play location;
    第三接收单元,用于接收 CDN 根据该第一分片序号返回的所述流媒体数据从所述播放位置起始的所述预设播放时长内的所述第一分片文件;a third receiving unit, configured to receive a CDN And the first fragment file within the preset playing duration starting from the playing position by the streaming media data returned according to the first fragment serial number;
    第四发送单元,用于向 P2P 网络发送用于获取所述流媒体数据的第四请求,所述第四请求中携带了从所述播放位置起始的所述预设播放时长之后的第一个第一分片序号所关联的第二分片序号;Fourth sending unit for P2P The network sends a fourth request for acquiring the streaming media data, where the fourth request carries a first first fragment serial number associated with the preset playing duration starting from the playing position. Second slice serial number;
    第四接收单元,用于接收 P2P 网络从该第二分片序号起始的所述第二分片文件。And a fourth receiving unit, configured to receive the second fragment file that is started by the P2P network from the second fragment serial number.
PCT/CN2015/088762 2015-09-01 2015-09-01 Streaming media transmission and play method, and transmission and play device WO2017035783A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/088762 WO2017035783A1 (en) 2015-09-01 2015-09-01 Streaming media transmission and play method, and transmission and play device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/088762 WO2017035783A1 (en) 2015-09-01 2015-09-01 Streaming media transmission and play method, and transmission and play device

Publications (1)

Publication Number Publication Date
WO2017035783A1 true WO2017035783A1 (en) 2017-03-09

Family

ID=58186617

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/088762 WO2017035783A1 (en) 2015-09-01 2015-09-01 Streaming media transmission and play method, and transmission and play device

Country Status (1)

Country Link
WO (1) WO2017035783A1 (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108391176A (en) * 2018-04-09 2018-08-10 四川百视通科技有限公司 The real time conversion system and its working method of a kind of RTMP agreements to HLS protocol
CN108989426A (en) * 2018-07-17 2018-12-11 深圳市网心科技有限公司 Drawing stream method, system and client and storage medium based on HLS protocol
CN110120930A (en) * 2018-02-06 2019-08-13 阿里巴巴集团控股有限公司 Obtain method, system and the multimedia equipment of transmission file
CN110740342A (en) * 2019-09-06 2020-01-31 浙江大华技术股份有限公司 Storage medium, streaming media transmission and playing method, and slicing method and device
CN111372099A (en) * 2020-03-20 2020-07-03 山东云缦智能科技有限公司 Low-delay HLS live broadcast implementation method
CN111935507A (en) * 2020-08-19 2020-11-13 上海连尚网络科技有限公司 Video switching method and device
CN112866763A (en) * 2020-12-28 2021-05-28 网宿科技股份有限公司 Sequence number generation method of HLS multi-rate stream slice, server and storage medium
CN114124939A (en) * 2021-11-25 2022-03-01 北京奇艺世纪科技有限公司 Pre-cache file processing method and device and file pre-cache system
CN114666627A (en) * 2022-03-01 2022-06-24 深圳市博安智控科技有限公司 Method and device for preloading streaming media video, electronic equipment and storage medium
CN115065859A (en) * 2022-06-07 2022-09-16 北京达佳互联信息技术有限公司 Video data acquisition method, device, equipment and medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102868912A (en) * 2012-08-16 2013-01-09 北京视博数字电视科技有限公司 Method and system for media content transmission based on CDN (Content Distribution Network) and P2P (Peer to Peer) converged infrastructure
CN103051976A (en) * 2013-01-22 2013-04-17 中兴通讯股份有限公司 Method, system and equipment for distributing HLS (HyperText Transfer Protocol Living Steaming) content by CDN (Content Distribute Network)
CN103648019A (en) * 2013-11-29 2014-03-19 乐视致新电子科技(天津)有限公司 Video downloading method and device based on HLS protocol
CN103702171A (en) * 2013-12-12 2014-04-02 乐视网信息技术(北京)股份有限公司 Method for downloading video stream and electronic equipment
US20140344468A1 (en) * 2013-05-14 2014-11-20 Morega Systems Inc. Client proxy for adaptive bitrate selection in http live streaming
CN104462154A (en) * 2013-09-25 2015-03-25 联想(北京)有限公司 Data processing method and data processing device
CN104581374A (en) * 2014-12-31 2015-04-29 深圳市同洲电子股份有限公司 Methods for obtaining slicing files and generating sub m3u8 files, node and server
CN104735044A (en) * 2014-11-18 2015-06-24 深圳市同洲电子股份有限公司 Streaming media live broadcast method and system

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102868912A (en) * 2012-08-16 2013-01-09 北京视博数字电视科技有限公司 Method and system for media content transmission based on CDN (Content Distribution Network) and P2P (Peer to Peer) converged infrastructure
CN103051976A (en) * 2013-01-22 2013-04-17 中兴通讯股份有限公司 Method, system and equipment for distributing HLS (HyperText Transfer Protocol Living Steaming) content by CDN (Content Distribute Network)
US20140344468A1 (en) * 2013-05-14 2014-11-20 Morega Systems Inc. Client proxy for adaptive bitrate selection in http live streaming
CN104462154A (en) * 2013-09-25 2015-03-25 联想(北京)有限公司 Data processing method and data processing device
CN103648019A (en) * 2013-11-29 2014-03-19 乐视致新电子科技(天津)有限公司 Video downloading method and device based on HLS protocol
CN103702171A (en) * 2013-12-12 2014-04-02 乐视网信息技术(北京)股份有限公司 Method for downloading video stream and electronic equipment
CN104735044A (en) * 2014-11-18 2015-06-24 深圳市同洲电子股份有限公司 Streaming media live broadcast method and system
CN104581374A (en) * 2014-12-31 2015-04-29 深圳市同洲电子股份有限公司 Methods for obtaining slicing files and generating sub m3u8 files, node and server

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110120930A (en) * 2018-02-06 2019-08-13 阿里巴巴集团控股有限公司 Obtain method, system and the multimedia equipment of transmission file
CN108391176A (en) * 2018-04-09 2018-08-10 四川百视通科技有限公司 The real time conversion system and its working method of a kind of RTMP agreements to HLS protocol
CN108989426B (en) * 2018-07-17 2021-04-06 深圳市网心科技有限公司 HLS protocol-based stream pulling method, system, client and storage medium
CN108989426A (en) * 2018-07-17 2018-12-11 深圳市网心科技有限公司 Drawing stream method, system and client and storage medium based on HLS protocol
CN110740342A (en) * 2019-09-06 2020-01-31 浙江大华技术股份有限公司 Storage medium, streaming media transmission and playing method, and slicing method and device
CN111372099A (en) * 2020-03-20 2020-07-03 山东云缦智能科技有限公司 Low-delay HLS live broadcast implementation method
CN111935507A (en) * 2020-08-19 2020-11-13 上海连尚网络科技有限公司 Video switching method and device
CN112866763A (en) * 2020-12-28 2021-05-28 网宿科技股份有限公司 Sequence number generation method of HLS multi-rate stream slice, server and storage medium
CN114124939A (en) * 2021-11-25 2022-03-01 北京奇艺世纪科技有限公司 Pre-cache file processing method and device and file pre-cache system
CN114124939B (en) * 2021-11-25 2024-03-26 北京奇艺世纪科技有限公司 Method and device for processing pre-cached file and file pre-caching system
CN114666627A (en) * 2022-03-01 2022-06-24 深圳市博安智控科技有限公司 Method and device for preloading streaming media video, electronic equipment and storage medium
CN115065859A (en) * 2022-06-07 2022-09-16 北京达佳互联信息技术有限公司 Video data acquisition method, device, equipment and medium
CN115065859B (en) * 2022-06-07 2024-05-07 北京达佳互联信息技术有限公司 Video data acquisition method, device, equipment and medium

Similar Documents

Publication Publication Date Title
WO2017035783A1 (en) Streaming media transmission and play method, and transmission and play device
WO2011059272A2 (en) Method and apparatus for providing trick play service
WO2012030178A2 (en) Method and device for providing streaming content
WO2020125251A1 (en) Federated learning-based model parameter training method, device, apparatus, and medium
WO2017035787A1 (en) Method, device, and system for storing streaming media file
WO2011059274A2 (en) Adaptive streaming method and apparatus
WO2014007502A1 (en) Display apparatus, interactive system, and response information providing method
WO2014069783A1 (en) Password-based authentication method, and apparatus for performing same
EP3017395A1 (en) Method and apparatus of data authentication
WO2012011735A2 (en) Method and apparatus for transmitting and receiving adaptive streaming mechanism-based content
WO2011021909A2 (en) Method and apparatus for providing contents via network, method and apparatus for receiving contents via network, and method and apparatus for backing up data via network, backup data providing device, and backup system
WO2018076841A1 (en) Data sharing method, apparatus, storage medium and server
WO2018080060A1 (en) Content output device and control method thereof
WO2016010229A1 (en) Operating method of client and server for streaming service
WO2016171401A1 (en) Method and device for sharing cooperative editing document
WO2016129963A1 (en) Multi-view streaming service supporting method, and device for supporting same
WO2020096148A1 (en) Method and device for switching media service channels
WO2017035786A1 (en) Method, device, and system for playing and checking streaming media file
WO2019137217A1 (en) Method for page jumping in application program, terminal, and storage medium
WO2019223600A1 (en) Bluetooth audio transmission method, device, and computer readable storage medium
WO2016065705A1 (en) Channel list updating method and apparatus, and terminal device
WO2016091000A1 (en) Dynamic code rate switching method, server and system
WO2016021773A1 (en) Qos guaranteed video stream method and system, and transmission server
WO2018076293A1 (en) Method and apparatus for adjusting parameter of multimedia communication, and mobile terminal
WO2010071303A2 (en) Method and apparatus for data transmission

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: 15902590

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: 15902590

Country of ref document: EP

Kind code of ref document: A1