WO2017035787A1 - Method, device, and system for storing streaming media file - Google Patents

Method, device, and system for storing streaming media file Download PDF

Info

Publication number
WO2017035787A1
WO2017035787A1 PCT/CN2015/088766 CN2015088766W WO2017035787A1 WO 2017035787 A1 WO2017035787 A1 WO 2017035787A1 CN 2015088766 W CN2015088766 W CN 2015088766W WO 2017035787 A1 WO2017035787 A1 WO 2017035787A1
Authority
WO
WIPO (PCT)
Prior art keywords
data block
file
streaming media
media file
data
Prior art date
Application number
PCT/CN2015/088766
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/088766 priority Critical patent/WO2017035787A1/en
Publication of WO2017035787A1 publication Critical patent/WO2017035787A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N7/00Television systems
    • H04N7/16Analogue secrecy systems; Analogue subscription systems
    • H04N7/173Analogue secrecy systems; Analogue subscription systems with two-way working, e.g. subscriber sending a programme selection signal

Definitions

  • the invention belongs to the field of the Internet, and in particular relates to a storage method, device and system for streaming media files.
  • the currently used streaming media protocols mainly include HTTP progressive download and RTSP/RTP-based.
  • Real-time streaming protocol mainly include HTTP progressive download and RTSP/RTP-based.
  • HTTP progressive download mainly include HTTP progressive download and RTSP/RTP-based.
  • Real-time streaming protocol mainly include HTTP progressive download and RTSP/RTP-based.
  • HTTP Live Streaming is a method of using the more typical HTTP progressive download.
  • the encoder compresses and encodes the collected audio and video data into an audio/video elementary stream conforming to a specific standard, and can also use the encoded file.
  • the files after the encoding is complete must be H.264 video and AAC audio.
  • the encoded video and audio are then packaged into an MPEG TS format.
  • the encapsulated MPEGTS is stream-divided to split the MPEG transport stream into a plurality of ts. Fragmentation of the file.
  • the segmentation process usually divides the slice by time, for example, it is divided into one slice for 10s duration, and if the code stream is high, the slice can be divided into 5 segments.
  • Second. And generate an index file (suffix m3u8) containing pointers to these small TS fragments, and put the index file and the cut TS fragments into a common WEB server.
  • the index and the slice are downloaded through the standard HTTP protocol, and the video can be clicked or broadcasted. Since the data is transmitted through the HTTP protocol, there is no firewall or proxy problem, and the segment file is in the HLS technology. The duration is very short, and the client can quickly select and switch the bit rate to accommodate playback under different bandwidth conditions.
  • the current HLS playback technology is usually used for data transmission between a single server and a client, and the data transmission speed is slow; if the divided TS fragments are sent to other terminal storage, the number of TS fragments after division is Very much, it needs to consume more system resources to manage it.
  • an embodiment of the present invention provides a method for storing a streaming media file, where the method includes:
  • the index file of the slice pointer
  • the merged file is sequentially cut according to a preset size to obtain a plurality of data blocks, wherein the data block includes a serial number corresponding to the data block, and the data block is sent to a plurality of P2P servers for storage.
  • the storing the data block to a plurality of P2P servers for storing includes:
  • All of the cut data blocks, or the cut partial data blocks, are stored in each of the plurality of P2P servers.
  • the step of cutting the merged file according to a preset size to obtain a plurality of data blocks, where the data block includes a sequence number corresponding to the data block, and sending the data block to multiple P2P servers for storing steps Also includes:
  • Each data block is verified, verification information corresponding to each data block is generated, and the verification information is added to the data block.
  • the method Before the step of performing the segmentation of the streaming media file according to the preset duration, the method further includes:
  • the encoder Encoding the video, the encoder encodes the collected video data into a video of H.264 format, and encodes the collected audio data into audio of ACC format;
  • the encoded video and audio are packaged into a streaming media file in MPEG format.
  • an embodiment of the present invention provides a method for downloading and playing a streaming media file, where the method includes:
  • the data block corresponding to the slice is obtained according to the size of the slice to be played, and the slice formed by the data block is sent to the player for playing.
  • the method Before the step of transmitting the data block to the player playing step, the method further includes:
  • the downloaded data block is verified according to the verification information included in the data block;
  • the data block fails the verification, the data block is re-downloaded to the P2P server.
  • the method further includes: before the step of downloading a data block from one or more P2P servers according to the data block number, the method further includes:
  • the data block download task of the corresponding size is allocated to each P2P server.
  • an embodiment of the present invention provides a streaming media file playing system, where the playing system includes:
  • the P2P server is configured to store the cut data block, where the data block includes a sequence number corresponding to the data block, where the file to be cut is a segment after the segmentation of the streaming media file and an index corresponding to the segment a file after the file is merged, the index file includes an offset of the slice and a pointer to the slice;
  • the P2P client is configured to obtain a data block from one or more P2P servers, obtain an index file according to the sequence number of the data block, parse the index file, and obtain a size of a fragment of the streaming media file to be played, and The data block to be read is sent, and the read data block is fragmented and sent to the player for playback.
  • an embodiment of the present invention provides a storage device for streaming media files, where the device includes:
  • a streaming media file dividing unit configured to obtain a streaming media file to be stored, and divide the streaming media file according to a preset duration, to obtain a plurality of fragments corresponding to the streaming media file, and a fragment that includes the fragment An index file of the offset and the pointer to the slice;
  • a file merging unit configured to merge the index file with the shards of the stream media file to generate a merged file
  • Cutting a storage unit configured to sequentially cut the merged file according to a preset size, to obtain a plurality of data blocks, where the data block includes a serial number corresponding to the data block, and send the data block to multiple P2Ps
  • the server is storing.
  • the cutting storage unit is further configured to:
  • Each data block is verified, verification information corresponding to each data block is generated, and the verification information is added to the data block.
  • the device further includes:
  • a coding unit configured to encode the video, and encode the collected video data into a video of H.264 format, and encode the collected audio data into audio of ACC format;
  • a packaging unit for encapsulating the encoded video and audio into a streaming media file in an MPEG format.
  • the cutting storage unit is further configured to:
  • All of the cut data blocks, or the cut partial data blocks, are stored in each of the plurality of P2P servers.
  • an embodiment of the present invention provides a streaming media file download and playback device, where the device includes:
  • a data block downloading module configured to download a data block from one or more P2P servers according to the data block number
  • An index file parsing module is configured to parse the downloaded index file, and calculate the size of each shard and the shard play order according to the offset in the index file;
  • the data block acquisition sending module is configured to acquire a data block corresponding to the fragment according to the size of the fragment to be played, and send the fragment formed by the data block to the player for playing.
  • the device further includes:
  • the verification module checks the downloaded data block according to the verification information included in the data block, and when the data block fails to pass the verification, the data block is re-downloaded to the P2P server.
  • the device further includes:
  • a communication speed information obtaining module configured to acquire communication speed information between the P2P client and the plurality of P2P servers
  • the task assignment module is configured to allocate a data block download task of a corresponding size to each P2P server according to the communication speed information between the P2P client and the plurality of P2P servers.
  • the streaming media file is divided into a plurality of fragments and indexed files according to a preset duration, and then the divided fragments are combined with the index file and then divided into a plurality of data blocks containing serial numbers according to a preset size. And sending the data block to each P2P server for storage. Since the data block size stored in the present invention is the same and each data block contains a serial number, the data block obtained after cutting can be conveniently stored in different servers. It can download data blocks in multiple servers at the same time, improve download speed, and manage more conveniently and consume less resources.
  • FIG. 1 is a flowchart for implementing a method for storing a streaming media file according to a first embodiment of the present invention
  • FIG. 2 is a flowchart showing an implementation process of a method for storing a streaming media file according to a second embodiment of the present invention
  • FIG. 3 is a flowchart showing an implementation process of a method for storing a streaming media file according to a third embodiment of the present invention
  • FIG. 4 is a flowchart for implementing a method for playing a streaming media file according to a fourth embodiment of the present invention.
  • FIG. 5 is a flowchart for implementing a method for playing a streaming media file according to a fifth embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a storage device for streaming media files according to a seventh embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a playback device for streaming media files according to an eighth embodiment of the present invention.
  • the purpose of the embodiment of the present invention is to solve the problem that in the prior art, when the video is played by using the HLS technology, the video is segmented according to a predetermined length of time, for example, a length of 10 seconds is used to segment the video, and the obtained segmentation is performed.
  • a predetermined length of time for example, a length of 10 seconds is used to segment the video, and the obtained segmentation is performed.
  • indexing files because there are more shards, management is more troublesome. It is not convenient to send shards and index files to other servers for sharing, so that when streaming media files are played, only the video files of the shards can be downloaded from one server. , resulting in slower downloads.
  • the streaming media file is divided into multiple fragments and indexed files according to a preset duration, and then the divided fragments and the index file are combined and divided into a plurality of data with serial numbers according to a preset size.
  • Block and send the data block to each P2P server for storage. Since the data block size stored in the present invention is the same and each data block contains a serial number, the data block obtained after cutting can be conveniently stored in different servers. It can download data blocks in multiple servers at the same time, improve download speed, and manage more conveniently and consume less resources.
  • the following describes the storage and playback of streaming media files from the perspective of the P2P server and the P2P client.
  • Embodiment 1 is a diagrammatic representation of Embodiment 1:
  • FIG. 1 is a flowchart showing an implementation process of a method for storing a streaming media file according to a first embodiment of the present invention, which is described in detail as follows:
  • step S101 the streaming media file to be stored is obtained, and the streaming media file is segmented according to a preset duration to obtain a plurality of fragments corresponding to the streaming media file, and an offset including the fragment. And an index file pointing to the pointer of the shard.
  • the current video source generally includes two categories: an on-demand VOD video data source and a live data source. If it is an on-demand VOD video data source, determine whether the format is MPEG. If not, the video data source needs to be performed. Format conversion.
  • the existing video data source needs to be converted accordingly, and the conversion method can select an existing conversion tool according to the format to be converted and the MPEG format, and the user can call The existing tools are completed, and other formats and MPEG conversion algorithms can be integrated in the system. After the format of the source video data source is judged, the corresponding algorithm is called to complete the format conversion.
  • the format conversion process may include a direct conversion algorithm, and may also include an indirect conversion algorithm, for example, a video data source of an MP4 format or a DVD format may be directly converted into video data of an MPEG format. It is also possible to convert the video data source of the DVD format into the video data of the MP4 format, and then convert the video data of the MP4 format into the video data of the MPEG format.
  • the method includes the following steps:
  • the encoder Encoding the video, the encoder encodes the collected video data into a video of H.264 format, and encodes the collected audio data into audio of ACC format;
  • the encoding process of the collected live data source can be generally performed by an encoder.
  • the encoder can be a hardware device or a software program.
  • the encoder of the hardware device is connected to the satellite receiver or camera to encode the input signal to generate video and AAC conforming to the H.264 standard (English full name is Advanced) Audio Coding, the full name of Chinese: Advanced Audio Coding, standard audio format, and package it as an MPEG TS file.
  • the preset duration of the segmentation of the streaming media file may be based on a different duration value according to the code rate. For example, the correspondence between different code rate ranges and durations can be set.
  • the first duration and the second duration decrease as the code rate increases. That is, the file size of each slice is controlled. For example, for a streaming media file with a normal bit rate, you can use a preset duration of 10s for segmentation. .
  • the streaming media can be divided into 540 fragments.
  • Each shard is formatted as ts, usually with a suffix of '.ts' appended to each file.
  • it also includes generating an index file corresponding to the shards, including an offset of each shard and a pointer to each shard in the index file.
  • the offset of the slice can be understood as the offset of the time or size of each slice from the starting position. Taking the time offset as an example, for example, the offset of the Nth slice is a time. Point, the offset of the N+1th slice is the b time point, then the size of the N+1th slice is the video data within the duration of ba.
  • the size of the slice can be directly obtained by subtracting the offset. For example, if the offset of the Nth slice is a, and the offset of the N+1th slice is b, then the size of the N+1th slice is b-a.
  • the pointer to the slice is used to sequentially play the slice according to the pointer in the index file.
  • the preset duration may be set in an index file, and multiple pointers included in the index file may be used to indicate the name and order of the play.
  • the shard can be associated with a pointer in the index file, and the pointers are sequentially stored in chronological order.
  • step S102 the index file is merged with the slice segmented by the streaming media file to generate a merged file.
  • the index file and the shards are combined, so that a large number of shards can be collectively managed, for example, for one streaming media file, including hundreds of shards, in the prior art.
  • a large number of shards can be collectively managed, for example, for one streaming media file, including hundreds of shards, in the prior art.
  • the present application solves the problem of complicated file management by re-segmenting after packaging and combining, and will be further explained in step S103.
  • the index file and the segmented slice of the streaming media file are merged, and the index file may be selected first, and the segmented slice of the streaming media file may be merged in a later manner. That is, in the merged file, the index file corresponding to the fragment of the streaming media file can be preferentially read. It can be understood that this is only a preferred combination, but it is not limited to this combination.
  • the size information of the index file needs to be included to facilitate distinguishing from the fragmentation of the streaming media file in the merged file.
  • step S103 the merged file is sequentially cut according to a preset size to obtain a plurality of data blocks, where the data block includes a sequence number corresponding to the data block, and the data block is sent to multiple P2P servers.
  • the cut is required, and the cut object may be a set of fragments in the merged file, or the entire merged file may be cut, and the entire merged file is performed by Han.
  • the cut object may be a set of fragments in the merged file, or the entire merged file may be cut, and the entire merged file is performed by Han.
  • it is necessary to record the size information of the index file, so as to facilitate the subsequent calculation of the correspondence between the cut data block and the position of the slice.
  • the merged file is cut to obtain a data block, and the preset size of the data block may be 1 KB or the like.
  • the data block after the cutting is 1 KB.
  • the sliced data block is much smaller than the slice, and therefore, one slice consists of a plurality of data blocks.
  • the size and offset of each slice can be obtained, and the starting point of the data block included in each slice can be obtained by combining the sequence numbers of each data block. position.
  • the cut object may be a set of fragments in the merged file, and the starting position of each slice is calculated according to the manner described in step S101. For example, for one of the fragments, the starting point of the data is 56.52M. The end position is 58.2M, then the size of the fragment can be calculated to be 1.68M, and the corresponding data includes 1680. If the sequence number of the first data block is 1, the corresponding data block of the fragment is the number 56520. A block of data between the serial numbers 58200.
  • the object to be cut includes the index file, it is necessary to remove the data block number occupied by the index file, such as the size of the index file 5K, then if for one of the fragments, the starting point of the data is 56.52M, and the ending position is 58.2M. Then, the size of the slice can be calculated to be 1.68M, and the corresponding data includes 1680. If the sequence number of the first data block is 1, the data block corresponding to the slice is the sequence number 56520+50 to the serial number 58200+50. Data block between.
  • the P2P server described in the embodiment of the present invention may be each terminal when performing streaming media file transmission and playback.
  • the terminal where the user A is located can serve as a P2P server, and provides the downloaded data, which is downloaded by other P2P clients. That is, the terminal where the user is located can serve as both a P2P client and a P2P server.
  • the serial number can be stored in an 8-byte space at a predetermined position in the data block. After the data block is cut and generated, the data block can be stored in a position in any P2P server, and the data block can be obtained from different P2P servers, and the combination of the serial numbers can be used to reassemble the generated fragments, thereby greatly improving the number of blocks.
  • the convenience of management of streaming media files can be distributed to multiple P2P servers for sharing and downloading, which is beneficial to improving the convenience of downloading streaming media files and improving download speed.
  • Embodiment 2 is a diagrammatic representation of Embodiment 1:
  • FIG. 2 is a flowchart showing an implementation process of a method for storing a streaming media file according to a second embodiment of the present invention, which is described in detail as follows:
  • step S201 the streaming media file to be stored is obtained, and the streaming media file is segmented according to a preset duration, and multiple fragments corresponding to the streaming media file are obtained, and an offset including the fragment is obtained. And an index file pointing to the pointer of the shard.
  • step S202 the index file is merged with the slice segmented by the streaming media file to generate a merged file.
  • the steps S201-S202 are substantially the same as the steps S101-S102 in the first embodiment, and are not described herein again.
  • step S203 the merged file is sequentially cut according to a preset size to obtain a plurality of data blocks, where the data block includes a serial number corresponding to the data block, and each of the plurality of P2P servers All the data blocks after cutting are stored in the terminal, or some of the data blocks after cutting.
  • the data stored in the P2P server is specifically limited in the embodiment of the present invention, including the following storage manners:
  • all the data blocks cut by the streaming media file are stored in a plurality of P2P servers, and when the P2P client downloads and plays the streaming media file, the data block of any serial number can be downloaded from any P2P server.
  • the advantage of this method is that when any one of the P2P servers fails, the impact on the P2P client is relatively small, but the P2P server requires a large space for data storage;
  • each P2P server stores only a part of data blocks, for example, in the server 1, the data block numbers are 1-3, 10-12, and the server 2 stores 4-6. 13-15... Store 7-9, 16-18... in server 3.
  • the server 1 stores only a part of data blocks, for example, in the server 1, the data block numbers are 1-3, 10-12, and the server 2 stores 4-6. 13-15... Store 7-9, 16-18... in server 3.
  • P2P clients can be quickly accessed from different P2P servers. Download the data block to improve the smoothness of playback.
  • the third method is a collection of the first mode and the second mode, that is, storing all the data blocks cut by the streaming media file in a part of the P2P server, and storing a part of the data blocks in another part of the P2P server, It can improve the download speed of P2P terminals, and can also reduce the impact on P2P clients when some P2P servers fail.
  • the embodiment of the present invention specifically describes the storage of data, and according to specific needs, different data block storage modes may be selected, which may be beneficial to improve data download speed or save storage space.
  • Embodiment 3 is a diagrammatic representation of Embodiment 3
  • FIG. 3 is a flowchart showing an implementation process of a method for storing a streaming media file according to a third embodiment of the present invention, which is described in detail as follows:
  • step S301 the streaming media file to be stored is obtained, and the streaming media file is segmented according to a preset duration, and multiple fragments corresponding to the streaming media file are obtained, and an offset including the fragment is obtained. And an index file pointing to the pointer of the shard.
  • step S302 the index file is merged with the slice segmented by the streaming media file to generate a merged file.
  • step S303 the merged file is sequentially cut according to a preset size to obtain a plurality of data blocks, where the data block includes a serial number corresponding to the data block, and the data block is sent to multiple P2P servers.
  • the storage is performed, each data block is verified, the verification information corresponding to each data block is generated, and the verification information is added to the data block.
  • CRC Cyclic Redundancy Check
  • Chinese full name is the cyclic redundancy check
  • the embodiment of the present invention is different in that the embodiment of the present invention further includes generating check information for each data block, for example, performing CRC check on each data block, and setting CRC check information.
  • a data block for example, a space of 4 bytes can be allocated for storing CRC check information.
  • the CRC check may be performed on the downloaded data block, that is, the other data in the data block from which the check information storage area is removed is verified, and the result value of the CRC check is obtained, and the school is
  • the result value of the test is compared with the check information stored in the data block. If the check result value matches the stored check information, it means that the data block is not damaged. If it does not match, the data block is damaged, possibly A malfunction of the screen or other image or sound occurs during playback.
  • the data block can be re-downloaded automatically.
  • the integrity of the data block is verified, and the damaged data block is found in time, so that the damaged data can be updated or re-downloaded, thereby further improving the playback quality of the streaming media file.
  • Embodiment 4 is a diagrammatic representation of Embodiment 4:
  • FIG. 4 is a flowchart showing an implementation process of a streaming media file downloading and playing method according to a fourth embodiment of the present invention, which is described in detail as follows:
  • step S401 the data block is downloaded from one or more P2P servers according to the data block number.
  • the method for downloading and playing the streaming media file in the embodiment of the present invention corresponds to the method for storing the streaming media file according to the first to third embodiments, that is, the streaming media file playing method in the embodiment of the present invention is used.
  • the files played are the streaming media files stored in Embodiments 1 to 3.
  • the data block number is stored in the data block, and the data block is downloaded from one or more P2P servers according to the size of the serial number in the data block.
  • a task of downloading a sequence number range of different P2P servers can be set, thereby realizing simultaneous downloading of required data blocks in a plurality of P2P servers, and the downloaded data blocks are not repeated.
  • the downloaded data blocks need to be combined into slices, so the downloaded data blocks can be preferentially stored in the memory and quickly combined through the memory.
  • the index file can be downloaded before the data block is downloaded.
  • the index file may be obtained according to the serial number in the downloaded data and the size of the index file.
  • step S402 the downloaded index file is parsed, and the size of each slice and the slice play order are calculated according to the offset in the index file.
  • the index file in the downloaded data block is parsed. Since the index sequence of the slice is included in the index file, the play sequence of the slice can be obtained by the pointer sequence.
  • the offset of each slice is included in the index file, and the size of the slice can be calculated according to the offset. The calculation of the slice size according to the offset has been specifically described in the first embodiment, and will not be repeated here.
  • step S403 according to the size of the slice to be played, the data block corresponding to the slice is acquired, and the slice formed by the data block is sent to the player for playing.
  • the sequence number range of the data block corresponding to each slice can be obtained.
  • the fragment to be played can be obtained, and the corresponding data block number is searched according to the played fragment, and the request for acquiring the corresponding data block is sent to the P2P server, according to the data block returned by the P2P server.
  • the piece to be played can be obtained, and the piece can be sent to the player to play the streaming file.
  • the size of the downloaded task of the different P2P servers may be set, including:
  • the data block download task of the corresponding size is allocated to each P2P server.
  • the connection speed of the P2P server can be tested before downloading, the number of download tasks of the server with high transmission speed is set, and the number of servers with low transmission speed is set less. By downloading the amount of tasks, the download speed can be further improved, and the network resources of the P2P client can be fully utilized.
  • the embodiment of the present invention corresponds to the method for storing a streaming media file according to the first embodiment.
  • the P2P playback of the HLS based on the HTTP protocol can be realized, that is, the playback speed can be improved, and the data management is facilitated.
  • fast switching of different code rates can be achieved.
  • Embodiment 5 is a diagrammatic representation of Embodiment 5:
  • FIG. 5 is a flowchart of implementing a method for downloading and playing a streaming media file according to an embodiment of the present invention, which is as follows:
  • step S501 the data block is downloaded from one or more P2P servers according to the data block number.
  • step S502 the downloaded index file is parsed, and the size of each slice and the slice play order are calculated according to the offset in the index file.
  • the steps S501-S502 are substantially the same as the steps S401-S402 described in the fourth embodiment, and are not repeatedly described herein.
  • step S503 the data block corresponding to the slice is acquired according to the size of the slice to be played, and the downloaded data block is verified according to the check information included in the data block.
  • the present invention further includes verifying the downloaded data block, that is, verifying the data in the data block, obtaining a verification result, and comparing with the verification information stored in the data block.
  • step S504 when the data block cannot pass the verification, the data block is re-downloaded to the P2P server.
  • the data block may be damaged during transmission. If the damaged data block is played, the screen may be unclear or the sound may be unclear.
  • the file is re-downloaded to the server according to the serial number of the data block until the downloaded file satisfies the requirement.
  • the data block may be re-downloaded according to other servers other than the server that is currently downloaded and the damaged data block is present.
  • step S505 when the data block passes the verification, the slice formed by the data block is sent to the player for playback.
  • the embodiment of the invention can further improve the quality of video playback by verifying the data block.
  • a sixth embodiment of the present invention provides a streaming media file playing system, where the system includes:
  • the P2P server is configured to store the cut data block, where the data block includes a sequence number corresponding to the data block, where the file to be cut is a segment after the segmentation of the streaming media file and an index corresponding to the segment a file after the file is merged, the index file includes an offset of the slice and a pointer to the slice;
  • the P2P client is configured to obtain a data block from one or more P2P servers, obtain an index file according to the sequence number of the data block, parse the index file, and obtain a size of a fragment of the streaming media file to be played, and The data block to be read is sent, and the read data block is fragmented and sent to the player for playback.
  • the manner of the streaming media file stored in the P2P server in the embodiment of the present invention may be any one of the first to third embodiments.
  • the P2P client may select any one of the fourth to fifth embodiments. I will not repeat them here.
  • FIG. 6 is a schematic structural diagram of a storage device for streaming media files according to a seventh embodiment of the present invention, which is described in detail as follows:
  • the streaming media file dividing unit 601 is configured to obtain a streaming media file to be stored, and divide the streaming media file according to a preset duration to obtain a plurality of fragments corresponding to the streaming media file, and include the fragment.
  • a file merging unit 602 configured to merge the index file with the segmented segment of the streaming media file to generate a merged file
  • the cutting storage unit 603 is configured to sequentially cut the merged file according to a preset size to obtain a plurality of data blocks, where the data block includes a serial number corresponding to the data block, and send the data block to multiple The P2P server is stored.
  • the cutting storage unit is further configured to:
  • Each data block is verified, verification information corresponding to each data block is generated, and the verification information is added to the data block.
  • the device further comprises:
  • a coding unit configured to encode the video, and encode the collected video data into a video of H.264 format, and encode the collected audio data into audio of ACC format;
  • a packaging unit for encapsulating the encoded video and audio into a streaming media file in an MPEG format.
  • the cutting storage unit is further specifically configured to:
  • All of the cut data blocks, or the cut partial data blocks, are stored in each of the plurality of P2P servers.
  • the storage device of the streaming media file in the embodiment of the present invention corresponds to the storage method of the streaming media file in the first embodiment to the third embodiment, and details are not described herein.
  • the serial number can be stored in an 8-byte space at a predetermined position in the data block. After the data block is cut and generated, the data block can be stored in a position in any P2P server, and the data block can be obtained from different P2P servers, and the combination of the serial numbers can be used to reassemble the generated fragments, thereby greatly improving the number of blocks.
  • the convenience of management of streaming media files can be distributed to multiple P2P servers for sharing and downloading, which is beneficial to improving the convenience of downloading streaming media files and improving download speed.
  • FIG. 7 is a schematic structural diagram of a streaming media file download and playback apparatus according to an eighth embodiment of the present invention, which is described in detail as follows:
  • a data block downloading module 701, configured to download a data block from one or more P2P servers according to the data block number;
  • the index file parsing module 702 is configured to parse the downloaded index file, and calculate the size of each slice and the slice play order according to the offset in the index file;
  • the data block acquisition and transmission module 703 is configured to acquire a data block corresponding to the fragment according to the size of the fragment to be played, and send the fragment formed by the data block to the player for playing.
  • the device further comprises:
  • the verification module checks the downloaded data block according to the verification information included in the data block, and when the data block fails to pass the verification, the data block is re-downloaded to the P2P server.
  • the device further comprises:
  • a communication speed information obtaining module configured to acquire communication speed information between the P2P client and the plurality of P2P servers
  • the task assignment module is configured to allocate a data block download task of a corresponding size to each P2P server according to the communication speed information between the P2P client and the plurality of P2P servers.
  • the device for playing a streaming media file according to the embodiment of the present invention corresponds to the method for playing the streaming media file according to the fourth to fifth embodiments, and details are not described herein.
  • the merged files generated by combining the fragments and the index files are cut to obtain data blocks, and each data block includes a corresponding serial number, so that the P2P client can
  • the P2P server downloads the data blocks and combines them to obtain the fragmentation, so that the P2P playback of the HLS based on the HTTP protocol can be realized, the playback speed can be improved, the data management can be facilitated, and the fast switching of different code rates can be realized.
  • the disclosed apparatus and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or 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 an 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 technical solution of the present invention which is essential or contributes 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 medium.
  • a number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read only memory (ROM, Read-Only) Memory, random access memory (RAM), disk or optical disk, and other media that can store program code.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

A method for storing a streaming media file comprises: acquiring a streaming media file to be stored, and segmenting the streaming media file according to a preset duration to obtain a plurality of segments corresponding to the streaming media and an index file comprising offsets of the segments and pointers pointing to the segments (S101); combining the index file with the segments of the streaming media file to generate a combined file (S102); sequentially cutting the combined file according to a preset size to obtain a plurality of data blocks, the data blocks comprising their respective serial numbers, and transmitting the data blocks to a plurality of P2P servers for storage (S103). By means of the solution, data blocks are downloaded from a plurality of servers, so that the downloading speed is improved. In addition, the management becomes more convenient, and fewer resources are occupied.

Description

一种流媒体文件的存储方法、装置和系统 Method, device and system for storing streaming media files 技术领域Technical field
本发明属于互联网领域,尤其涉及一种流媒体文件的存储方法、装置和系统。  The invention belongs to the field of the Internet, and in particular relates to a storage method, device and system for streaming media files.
背景技术Background technique
在流媒体文件点播传输时,目前常用的流媒体协议主要有 HTTP 渐进下载和基于 RTSP/RTP 的实时流媒体协议。其中,苹果公开开发的HLS技术(英文全称为: HTTP Live Streaming )是一种使用较为典型的HTTP渐进下载的方法。 At the time of streaming media file on-demand transmission, the currently used streaming media protocols mainly include HTTP progressive download and RTSP/RTP-based. Real-time streaming protocol. Among them, the HLS technology developed by Apple (English full name: HTTP Live Streaming) is a method of using the more typical HTTP progressive download.
在使用HLS技术进行视频点播时,需要对点播的内容进行准备,首先进行视频采集,编码器将采集的音视频数据压缩编码为符合特定标准的音视频基本流,也可以使用编码完后的文件,但编码完成后的文件一定为H.264视频和AAC音频。然后将编码后的视频和音频封装成为MPEGTS格式。 When using HLS technology for video on demand, it is necessary to prepare the content of the on-demand video. First, the video is collected, and the encoder compresses and encodes the collected audio and video data into an audio/video elementary stream conforming to a specific standard, and can also use the encoded file. However, the files after the encoding is complete must be H.264 video and AAC audio. The encoded video and audio are then packaged into an MPEG TS format.
然后对封装后的MPEGTS进行流分割,将 MPEG传输流分割成很多个 ts 的文件的分片。分割过程通常是按时间进行分片,比如分割为一个分片为10s时长,而如果码流高可以分割分片的时长为 5 秒。并生成含有指向这些小TS分片指针的索引文件(后缀为m3u8),将索引文件和切割后的TS分片放到普通的WEB服务器中。 Then, the encapsulated MPEGTS is stream-divided to split the MPEG transport stream into a plurality of ts. Fragmentation of the file. The segmentation process usually divides the slice by time, for example, it is divided into one slice for 10s duration, and if the code stream is high, the slice can be divided into 5 segments. second. And generate an index file (suffix m3u8) containing pointers to these small TS fragments, and put the index file and the cut TS fragments into a common WEB server.
当客户端需要播放时,通过标准的HTTP协议下载索引和分片,即可实现视频的点播或者直播,由于数据通过HTTP协议传输,所以不存在防火墙或者代理的问题,并且HLS技术中分段文件的时长很短,客户端可以很快的选择和切换码率,以适应不同带宽条件下的播放。 When the client needs to play, the index and the slice are downloaded through the standard HTTP protocol, and the video can be clicked or broadcasted. Since the data is transmitted through the HTTP protocol, there is no firewall or proxy problem, and the segment file is in the HLS technology. The duration is very short, and the client can quickly select and switch the bit rate to accommodate playback under different bandwidth conditions.
但是,目前的HLS播放技术通常用于单个服务器与客户端之间的数据传送,数据传输速度较慢;如果将分割后的TS分片发送至其它终端存储时,由于分割后的TS分片数量非常多,需要消耗较多的系统资源对其管理。 However, the current HLS playback technology is usually used for data transmission between a single server and a client, and the data transmission speed is slow; if the divided TS fragments are sent to other terminal storage, the number of TS fragments after division is Very much, it needs to consume more system resources to manage it.
技术问题technical problem
本发明的目的在于提供一种 流媒体文件的存储方法 ,以解决现有技术 通常用于单个服务器与客户端之间的数据传送,数据传输速度较慢;或需要消耗较多的系统资源进行管理 的问题。  It is an object of the present invention to provide a method for storing a streaming media file to solve the prior art. It is usually used for data transfer between a single server and a client, and the data transfer speed is slow; or it requires a large amount of system resources for management.
技术解决方案Technical solution
第一方面,本发明实施例提供了一种 流媒体文件的存储方法,所述方法包括: In a first aspect, an embodiment of the present invention provides a method for storing a streaming media file, where the method includes:
获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割,得到所述流媒体文件对应的多个分片,以及包含所述分片的偏移量和指向所述分片的指针的索引文件; Obtaining a streaming media file to be stored, dividing the streaming media file according to a preset duration, obtaining a plurality of fragments corresponding to the streaming media file, and including an offset of the fragment and pointing to the segment The index file of the slice pointer;
将所述索引文件与所述流媒体文件分割后的分片进行合并,生成合并后的文件; Combining the index file with the segmentation of the stream media file to generate a merged file;
将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,将所述数据块发送至多个P2P服务器进行存储。 The merged file is sequentially cut according to a preset size to obtain a plurality of data blocks, wherein the data block includes a serial number corresponding to the data block, and the data block is sent to a plurality of P2P servers for storage.
结合第一方面,在第一方面的第一种可能实现方式中, 所述将所述数据块发送至多个P2P服务器进行存储步骤包括: In conjunction with the first aspect, in a first possible implementation of the first aspect, The storing the data block to a plurality of P2P servers for storing includes:
在所述多个P2P服务器中的每个终端中存储切割后的所有数据块,或者切割后的部分数据块。 All of the cut data blocks, or the cut partial data blocks, are stored in each of the plurality of P2P servers.
结合第一方面,在第一方面的第二种可能实现方式中, 所述将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,将所述数据块发送至多个P2P服务器进行存储步骤还包括: In conjunction with the first aspect, in a second possible implementation of the first aspect, The step of cutting the merged file according to a preset size to obtain a plurality of data blocks, where the data block includes a sequence number corresponding to the data block, and sending the data block to multiple P2P servers for storing steps Also includes:
对每个数据块进行校验,生成每个数据块对应的校验信息,并将所述校验信息添加到数据块中。 Each data block is verified, verification information corresponding to each data block is generated, and the verification information is added to the data block.
结合第一方面,在第一方面的第三种可能实现方式中, 在所述获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割步骤之前,所述方法还包括: In conjunction with the first aspect, in a third possible implementation of the first aspect, Before the step of performing the segmentation of the streaming media file according to the preset duration, the method further includes:
对视频进行编码,由编码器将采集的视频数据编码为H.264格式的视频,将采集音频数据编码为ACC格式的音频; Encoding the video, the encoder encodes the collected video data into a video of H.264 format, and encodes the collected audio data into audio of ACC format;
将编码后的视频和音频封装为MPEG格式的流媒体文件。 The encoded video and audio are packaged into a streaming media file in MPEG format.
第二方面,本发明实施例提供了一种 流媒体文件下载播放方法,所述方法包括: In a second aspect, an embodiment of the present invention provides a method for downloading and playing a streaming media file, where the method includes:
根据数据块序号,从一个或者多个P2P服务器中下载数据块; Downloading data blocks from one or more P2P servers according to the data block number;
解析下载的索引文件,根据索引文件中偏移量计算每个分片的大小以及分片播放顺序; Parsing the downloaded index file, calculating the size of each shard and the shard play order according to the offset in the index file;
根据需要播放的分片的大小,获取所述分片对应的数据块,将数据块构成的分片发送至播放器播放。 The data block corresponding to the slice is obtained according to the size of the slice to be played, and the slice formed by the data block is sent to the player for playing.
结合第二方面,在第二方面的第一种可能实现方式中, 在所述将数据块构成的分片发送至播放器播放步骤之前,所述方法还包括: In conjunction with the second aspect, in a first possible implementation of the second aspect, Before the step of transmitting the data block to the player playing step, the method further includes:
根据数据块中包括的校验信息,对下载的数据块进行校验; The downloaded data block is verified according to the verification information included in the data block;
当所述数据块不能通过校验时,则重新向P2P服务器下载所述数据块。 When the data block fails the verification, the data block is re-downloaded to the P2P server.
结合第二方面,在第二方面的第二种可能实现方式中, 所述根据数据块序号,从一个或者多个P2P服务器中下载数据块步骤之前,所述方法还包括: In conjunction with the second aspect, in a second possible implementation of the second aspect, The method further includes: before the step of downloading a data block from one or more P2P servers according to the data block number, the method further includes:
获取P2P客户端与多个P2P服务器之间的通信速度信息; Obtaining communication speed information between the P2P client and multiple P2P servers;
根据所述P2P客户端与多个P2P服务器之间的通信速度信息,分配相应大小的数据块下载任务至各个P2P服务器。 And according to the communication speed information between the P2P client and the plurality of P2P servers, the data block download task of the corresponding size is allocated to each P2P server.
第三方面,本发明实施例提供了一种流媒体文件的播放系统,所述播放系统包括: In a third aspect, an embodiment of the present invention provides a streaming media file playing system, where the playing system includes:
P2P 服务器,所述P2P服务器用于存放切割后的数据块,所述数据块中包括数据块对应的序号,其中待切割的文件为流媒体文件进行分割后的分片以及所述分片对应的索引文件合并后的文件,所述索引文件中包含所述分片的偏移量以及指向所述分片的指针; P2P a server, the P2P server is configured to store the cut data block, where the data block includes a sequence number corresponding to the data block, where the file to be cut is a segment after the segmentation of the streaming media file and an index corresponding to the segment a file after the file is merged, the index file includes an offset of the slice and a pointer to the slice;
P2P 客户端,所述P2P客户端用于从一个或者多个P2P服务器中获取数据块,根据数据块的序号得到索引文件,解析所述索引文件,得到需要播放的流媒体文件的分片的大小以及需要读取的数据块,并将读取的数据块构成分片发送至播放器进行播放。 P2P a client, the P2P client is configured to obtain a data block from one or more P2P servers, obtain an index file according to the sequence number of the data block, parse the index file, and obtain a size of a fragment of the streaming media file to be played, and The data block to be read is sent, and the read data block is fragmented and sent to the player for playback.
第四方面,本发明实施例提供了一种 流媒体文件的存储装置,所述装置包括: In a fourth aspect, an embodiment of the present invention provides a storage device for streaming media files, where the device includes:
流媒体文件分割单元,用于获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割,得到所述流媒体文件对应的多个分片,以及包含所述分片的偏移量和指向所述分片的指针的索引文件; a streaming media file dividing unit, configured to obtain a streaming media file to be stored, and divide the streaming media file according to a preset duration, to obtain a plurality of fragments corresponding to the streaming media file, and a fragment that includes the fragment An index file of the offset and the pointer to the slice;
文件合并单元,用于将所述索引文件与所述流媒体文件分割后的分片进行合并,生成合并后的文件; a file merging unit, configured to merge the index file with the shards of the stream media file to generate a merged file;
切割存储单元,用于将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,将所述数据块发送至多个P2P服务器进行存储。 Cutting a storage unit, configured to sequentially cut the merged file according to a preset size, to obtain a plurality of data blocks, where the data block includes a serial number corresponding to the data block, and send the data block to multiple P2Ps The server is storing.
结合第四方面,在第四方面的第一种可能实现方式中,所述切割存储单元还用于: In conjunction with the fourth aspect, in a first possible implementation manner of the fourth aspect, the cutting storage unit is further configured to:
对每个数据块进行校验,生成每个数据块对应的校验信息,并将所述校验信息添加到数据块中。 Each data block is verified, verification information corresponding to each data block is generated, and the verification information is added to the data block.
结合第四方面,在第四方面的第二种可能实现方式中, 所述装置还包括: With reference to the fourth aspect, in a second possible implementation manner of the fourth aspect, the device further includes:
编码单元,用于对视频进行编码,由编码器将采集的视频数据编码为H.264格式的视频,将采集音频数据编码为ACC格式的音频; a coding unit, configured to encode the video, and encode the collected video data into a video of H.264 format, and encode the collected audio data into audio of ACC format;
封装单元,用于将编码后的视频和音频封装为MPEG格式的流媒体文件。 A packaging unit for encapsulating the encoded video and audio into a streaming media file in an MPEG format.
结合第四方面,在第四方面的第三种可能实现方式中,所述 切割存储单元还具体用于: In conjunction with the fourth aspect, in a third possible implementation manner of the fourth aspect, the cutting storage unit is further configured to:
在所述多个P2P服务器中的每个终端中存储切割后的所有数据块,或者切割后的部分数据块。 All of the cut data blocks, or the cut partial data blocks, are stored in each of the plurality of P2P servers.
第五方面,本发明实施例提供了一种 流媒体文件下载播放装置,所述装置包括: In a fifth aspect, an embodiment of the present invention provides a streaming media file download and playback device, where the device includes:
数据块下载模块,用于根据数据块序号,从一个或者多个P2P服务器中下载数据块; a data block downloading module, configured to download a data block from one or more P2P servers according to the data block number;
索引文件解析模块,用于解析下载的索引文件,根据索引文件中偏移量计算每个分片的大小以及分片播放顺序; An index file parsing module is configured to parse the downloaded index file, and calculate the size of each shard and the shard play order according to the offset in the index file;
数据块获取发送模块,用于根据需要播放的分片的大小,获取所述分片对应的数据块,将数据块构成的分片发送至播放器播放。 The data block acquisition sending module is configured to acquire a data block corresponding to the fragment according to the size of the fragment to be played, and send the fragment formed by the data block to the player for playing.
结合第五方面,在第五方面的第一种可能实现方式中, 所述装置还包括: With reference to the fifth aspect, in a first possible implementation manner of the fifth aspect, the device further includes:
校验模块,根据数据块中包括的校验信息,对下载的数据块进行校验,当所述数据块不能通过校验时,则重新向P2P服务器下载所述数据块。 The verification module checks the downloaded data block according to the verification information included in the data block, and when the data block fails to pass the verification, the data block is re-downloaded to the P2P server.
结合第五方面,在第五方面的第二种可能实现方式中,所述装置还包括: With reference to the fifth aspect, in a second possible implementation manner of the fifth aspect, the device further includes:
通信速度信息获取模块,用于获取P2P客户端与多个P2P服务器之间的通信速度信息; a communication speed information obtaining module, configured to acquire communication speed information between the P2P client and the plurality of P2P servers;
下载任务分配模块,用于根据所述P2P客户端与多个P2P服务器之间的通信速度信息,分配相应大小的数据块下载任务至各个P2P服务器。 The task assignment module is configured to allocate a data block download task of a corresponding size to each P2P server according to the communication speed information between the P2P client and the plurality of P2P servers.
有益效果Beneficial effect
在本发明中,将流媒体文件按预设的时长分割为多个分片并索引文件,然后将分割后的分片与索引文件合并再按预设的大小分割为多个含有序号的数据块,并将数据块发送至各个P2P服务器中进行存储,由于本发明中存储的数据块大小相同并且每个数据块中含有序号,可以将切割后得到的数据块方便的存放至不同的服务器中,可同时在多个服务器中下载数据块,提高下载速度,并且管理更方便,占用资源少。 In the present invention, the streaming media file is divided into a plurality of fragments and indexed files according to a preset duration, and then the divided fragments are combined with the index file and then divided into a plurality of data blocks containing serial numbers according to a preset size. And sending the data block to each P2P server for storage. Since the data block size stored in the present invention is the same and each data block contains a serial number, the data block obtained after cutting can be conveniently stored in different servers. It can download data blocks in multiple servers at the same time, improve download speed, and manage more conveniently and consume less resources.
附图说明DRAWINGS
图1是本发明第一实施例 提供的流媒体文件的存储方法 的实现流程; 1 is a flowchart for implementing a method for storing a streaming media file according to a first embodiment of the present invention;
图2是本发明第二实施例 提供的流媒体文件的存储方法 的实现流程; 2 is a flowchart showing an implementation process of a method for storing a streaming media file according to a second embodiment of the present invention;
图3是本发明第三实施例 提供的流媒体文件的存储方法 的实现流程; 3 is a flowchart showing an implementation process of a method for storing a streaming media file according to a third embodiment of the present invention;
图4是本发明第四实施例 提供的流媒体文件的播放方法 的实现流程; 4 is a flowchart for implementing a method for playing a streaming media file according to a fourth embodiment of the present invention;
图5是本发明第五实施例 提供的流媒体文件的播放方法 的实现流程; 5 is a flowchart for implementing a method for playing a streaming media file according to a fifth embodiment of the present invention;
图6是本发明第七实施例 提供的流媒体文件的存储装置 的 结构示意图 ; 6 is a schematic structural diagram of a storage device for streaming media files according to a seventh embodiment of the present invention;
图7是本发明第八实施例 提供的流媒体文件的播放装置的结构示意图 。 FIG. 7 is a schematic structural diagram of a playback device for streaming media files according to an eighth embodiment of the present invention.
本发明的实施方式Embodiments of the invention
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。 The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
本发明实施例的目的在于解决现有技术中使用HLS技术进行视频播放时,由于在视频分割时,是根据预定的时间长度进行分割,比如10秒的长度对视频进行分割,得到的分片和索引文件后,由于分片较多,管理较为麻烦,不便于将分片和索引文件发送至其它服务器进行共享,从而使得播放流媒体文件时,只能从一台服务器中下载分片的视频文件,导致下载速度较慢。 The purpose of the embodiment of the present invention is to solve the problem that in the prior art, when the video is played by using the HLS technology, the video is segmented according to a predetermined length of time, for example, a length of 10 seconds is used to segment the video, and the obtained segmentation is performed. After indexing files, because there are more shards, management is more troublesome. It is not convenient to send shards and index files to other servers for sharing, so that when streaming media files are played, only the video files of the shards can be downloaded from one server. , resulting in slower downloads.
通过本发明实施例,将流媒体文件按预设的时长分割为多个分片并索引文件,然后将分割后的分片与索引文件合并再按预设的大小分割为多个含有序号的数据块,并将数据块发送至各个P2P服务器中进行存储,由于本发明中存储的数据块大小相同并且每个数据块中含有序号,可以将切割后得到的数据块方便的存放至不同的服务器中,可同时在多个服务器中下载数据块,提高下载速度,并且管理更方便,占用资源少。 According to the embodiment of the present invention, the streaming media file is divided into multiple fragments and indexed files according to a preset duration, and then the divided fragments and the index file are combined and divided into a plurality of data with serial numbers according to a preset size. Block, and send the data block to each P2P server for storage. Since the data block size stored in the present invention is the same and each data block contains a serial number, the data block obtained after cutting can be conveniently stored in different servers. It can download data blocks in multiple servers at the same time, improve download speed, and manage more conveniently and consume less resources.
下面通过实施例,从P2P服务器以及P2P客户端的角度,分别对流媒体文件的存储和播放进行介绍说明。 The following describes the storage and playback of streaming media files from the perspective of the P2P server and the P2P client.
实施例一: Embodiment 1:
图1示出了本发明第一实施例提供的流媒体文件的存储方法的实现流程,详述如下: FIG. 1 is a flowchart showing an implementation process of a method for storing a streaming media file according to a first embodiment of the present invention, which is described in detail as follows:
在步骤S101中,获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割,得到所述流媒体文件对应的多个分片,以及包含所述分片的偏移量和指向所述分片的指针的索引文件。 In step S101, the streaming media file to be stored is obtained, and the streaming media file is segmented according to a preset duration to obtain a plurality of fragments corresponding to the streaming media file, and an offset including the fragment. And an index file pointing to the pointer of the shard.
具体的,目前视频源一般包含两大类:点播的VOD视频数据源和直播的数据源,如果为点播的VOD视频数据源,判断其格式是否为MPEG,如果不是,则需要对视频数据源进行格式的转换。 Specifically, the current video source generally includes two categories: an on-demand VOD video data source and a live data source. If it is an on-demand VOD video data source, determine whether the format is MPEG. If not, the video data source needs to be performed. Format conversion.
比如得到的视频数据源为DVD格式,或者MP4格式等,那么需要对现有的视频数据源进行相应的转换,转换方法可以根据待转换的格式和MPEG格式选择现有的转换工具,通过用户调用现有的工具完成,也可以在系统中集成其它格式与MPEG转换的算法,在对源视频数据源的格式进行判断后,调用相应的算法完成格式的转换。 For example, if the obtained video data source is a DVD format or an MP4 format, then the existing video data source needs to be converted accordingly, and the conversion method can select an existing conversion tool according to the format to be converted and the MPEG format, and the user can call The existing tools are completed, and other formats and MPEG conversion algorithms can be integrated in the system. After the format of the source video data source is judged, the corresponding algorithm is called to complete the format conversion.
其中,格式的转换过程可以包括直接转换算法,也可以包括间接转换算法,比如可以将MP4格式、DVD格式的视频数据源直接转换为MPEG格式的视频数据。也可以将DVD格式的视频数据源先转换为MP4格式的视频数据,然后再将MP4格式的视频数据转换为MPEG格式的视频数据。 The format conversion process may include a direct conversion algorithm, and may also include an indirect conversion algorithm, for example, a video data source of an MP4 format or a DVD format may be directly converted into video data of an MPEG format. It is also possible to convert the video data source of the DVD format into the video data of the MP4 format, and then convert the video data of the MP4 format into the video data of the MPEG format.
如果判断视频源为直播的数据源,则需要包括对直播的数据源进行编码和封装步骤,具体可包括: If the data source is determined to be a live data source, the method includes the following steps:
对视频进行编码,由编码器将采集的视频数据编码为H.264格式的视频,将采集音频数据编码为ACC格式的音频; Encoding the video, the encoder encodes the collected video data into a video of H.264 format, and encodes the collected audio data into audio of ACC format;
将编码后的视频和音频封装为MPEG(英文全称为:Moving Picture Experts Group,中文全称为:动态图像专家组)格式的流媒体文件。 Encapsulate the encoded video and audio into MPEG (English full name: Moving Picture Experts Group, Chinese full name: Dynamic Image Experts Group) format streaming media files.
其中,对所述采集的直播数据源进行编码过程,一般可以由编码器完成。编码器可以是硬件设备,也可以为软件程序。硬件设备的编码器与卫星接收机或摄像机连接,将输入的信号进行编码,生成符合H.264标准的视频和AAC(英文全称为Advanced Audio Coding,中文全称为:高级音频编码)标准音频格式,并将其封装为MPEG的TS文件。 The encoding process of the collected live data source can be generally performed by an encoder. The encoder can be a hardware device or a software program. The encoder of the hardware device is connected to the satellite receiver or camera to encode the input signal to generate video and AAC conforming to the H.264 standard (English full name is Advanced) Audio Coding, the full name of Chinese: Advanced Audio Coding, standard audio format, and package it as an MPEG TS file.
其中,对所述流媒体文件进行分割的预设的时长,可以根据码率的高低而相应的选用不同的时长值。比如可以设定不同的码率范围与时长的对应关系,通过检测待分割的流媒体文件,当码率在第一范围时,则对应第一时长,当码率在第二范围时,对应第二时长。其中,第一时长和第二时长,随着码率的增加而减小。即对于每个分片的文件大小进行控制。比如对于正常码率的流媒体文件,可以选用10s的预设时长进行分割 。 The preset duration of the segmentation of the streaming media file may be based on a different duration value according to the code rate. For example, the correspondence between different code rate ranges and durations can be set. By detecting the streaming media file to be divided, when the code rate is in the first range, the first time length is corresponding, and when the code rate is in the second range, corresponding to the first Two hours long. The first duration and the second duration decrease as the code rate increases. That is, the file size of each slice is controlled. For example, for a streaming media file with a normal bit rate, you can use a preset duration of 10s for segmentation. .
当流媒体时长为1.5小时,预设时长为10s,则可以将流媒体分割为540个分片。每个分片的格式为ts,通常在每个文件的后面添加'.ts'的后缀。 When the streaming time is 1.5 hours and the preset duration is 10s, the streaming media can be divided into 540 fragments. Each shard is formatted as ts, usually with a suffix of '.ts' appended to each file.
为了便于对大量的分片进行管理,还包括生成一个与所述分片对应的索引文件,在所述索引文件中包括每个分片的偏移量以及指向每个分片的指针。 In order to facilitate management of a large number of shards, it also includes generating an index file corresponding to the shards, including an offset of each shard and a pointer to each shard in the index file.
其中,所述分片的偏移量,可以理解为每个分片偏离起点位置的时间或者大小的偏移量,以时间偏移为例,比如第N个分片的偏移量为a时间点,第N+1个分片的偏移量为b时间点,那么第N+1个分片的大小即为b-a的时长内的视频数据。 The offset of the slice can be understood as the offset of the time or size of each slice from the starting position. Taking the time offset as an example, for example, the offset of the Nth slice is a time. Point, the offset of the N+1th slice is the b time point, then the size of the N+1th slice is the video data within the duration of ba.
如果偏移量为数据大小,那么通过偏移量相减,即可直接得到分片的大小。比如第N个分片的偏移量为a,第N+1个分片的偏移量为b,那么第N+1个分片的大小即为b-a。 If the offset is the data size, the size of the slice can be directly obtained by subtracting the offset. For example, if the offset of the Nth slice is a, and the offset of the N+1th slice is b, then the size of the N+1th slice is b-a.
所述指向分片的指针,用于根据索引文件中的指针依次对分片进行调用播放。 The pointer to the slice is used to sequentially play the slice according to the pointer in the index file.
其中,所述预设时长可以在索引文件中进行设定,所述索引文件中包括的多个指针,可以用于指示播放的名称和顺序。比如可将分片与索引文件中的指针相对应,且指针根据时间顺序依次进行存储。 The preset duration may be set in an index file, and multiple pointers included in the index file may be used to indicate the name and order of the play. For example, the shard can be associated with a pointer in the index file, and the pointers are sequentially stored in chronological order.
在步骤S102中,将所述索引文件与所述流媒体文件分割后的分片进行合并,生成合并后的文件。 In step S102, the index file is merged with the slice segmented by the streaming media file to generate a merged file.
在本发明实施例中,将所述索引文件以及分片进行合并,从而可以将数量较多的分片集中进行管理,比如对于一个流媒体文件,其包括数百个分片,现有技术中,通过索引文件对数百个分片进行管理时,需要耗费较多的系统资源,并且不利于将分片发送至其它服务器中进行文件的P2P共享。本申请通过打包合并后重新进行分割来解决文件多管理复杂的问题,将在步骤S103中作进一步的说明。 In the embodiment of the present invention, the index file and the shards are combined, so that a large number of shards can be collectively managed, for example, for one streaming media file, including hundreds of shards, in the prior art. When managing hundreds of shards through an index file, it requires a lot of system resources, and is not conducive to sending shards to other servers for P2P sharing of files. The present application solves the problem of complicated file management by re-segmenting after packaging and combining, and will be further explained in step S103.
在本步骤中,对所述索引文件和所述流媒体文件分割后的分片进行合并的方式,可以选用索引文件在前,所述流媒体文件分割后的分片在后的方式进行合并。即合并后的文件中,可以优先读取所述流媒体文件的分片所对应的索引文件。可以理解的是,这只是一种较佳的合并方式,但并不局限于这种合并方式。 In this step, the index file and the segmented slice of the streaming media file are merged, and the index file may be selected first, and the segmented slice of the streaming media file may be merged in a later manner. That is, in the merged file, the index file corresponding to the fragment of the streaming media file can be preferentially read. It can be understood that this is only a preferred combination, but it is not limited to this combination.
另外,在合并后的文件中,需要包括所述索引文件的大小信息,以便于与合并后的文件中的流媒体文件的分片进行区分。 In addition, in the merged file, the size information of the index file needs to be included to facilitate distinguishing from the fragmentation of the streaming media file in the merged file.
在步骤S103中,将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,将所述数据块发送至多个P2P服务器进行存储。 In step S103, the merged file is sequentially cut according to a preset size to obtain a plurality of data blocks, where the data block includes a sequence number corresponding to the data block, and the data block is sent to multiple P2P servers. Store.
对合并后的文件,需要重新进行切割,所述切割的对象,可以为合并后的文件中的分片构成的集合,也可以对整个合并后的文件进行切割,汉对整个合并后的文件进行切割时,需要记录索引文件的大小信息,以便于后续对切割后的数据块与分片的位置进行对应关系的计算。 For the merged file, the cut is required, and the cut object may be a set of fragments in the merged file, or the entire merged file may be cut, and the entire merged file is performed by Han. When cutting, it is necessary to record the size information of the index file, so as to facilitate the subsequent calculation of the correspondence between the cut data block and the position of the slice.
将所述合并后的文件进行切割得到数据块,所述数据块的预设的大小可以为1KB等,根据上述分割后的分片为10s的方式相比,切割后的数据块为1KB时,切割后的数据块远小于分片,因此,一个分片包括多个数据块构成。 The merged file is cut to obtain a data block, and the preset size of the data block may be 1 KB or the like. When the divided data block is 1 KB, the data block after the cutting is 1 KB. The sliced data block is much smaller than the slice, and therefore, one slice consists of a plurality of data blocks.
另外,根据索引文件中记录的分片的偏移理,可以得到每个分片的大小以及偏移量,结合每个数据块的序号,即可得到每个分片包括的数据块的起始点位置。 In addition, according to the offset of the fragments recorded in the index file, the size and offset of each slice can be obtained, and the starting point of the data block included in each slice can be obtained by combining the sequence numbers of each data block. position.
比如,切割的对象,可以为合并后的文件中的分片构成的集合,根据步骤S101中介绍的方式,计算每个分片的起点位置,比如对于其中一个分片,数据的起点为56.52M,结束位置为58.2M位置,那么可以计算得到该分片的大小为1.68M,对应的数据包括1680个,如果第一个数据块的序号为1,那么该分片对应的数据块为序号56520至序号58200之间的数据块。 For example, the cut object may be a set of fragments in the merged file, and the starting position of each slice is calculated according to the manner described in step S101. For example, for one of the fragments, the starting point of the data is 56.52M. The end position is 58.2M, then the size of the fragment can be calculated to be 1.68M, and the corresponding data includes 1680. If the sequence number of the first data block is 1, the corresponding data block of the fragment is the number 56520. A block of data between the serial numbers 58200.
而如果切割的对象包括索引文件,则需要去除索引文件所占有的数据块序号,比如索引文件的大小5K,那么如果对于其中一个分片,数据的起点为56.52M,结束位置为58.2M位置,那么可以计算得到该分片的大小为1.68M,对应的数据包括1680个,如果第一个数据块的序号为1,那么该分片对应的数据块为序号56520+50至序号58200+50之间的数据块。 If the object to be cut includes the index file, it is necessary to remove the data block number occupied by the index file, such as the size of the index file 5K, then if for one of the fragments, the starting point of the data is 56.52M, and the ending position is 58.2M. Then, the size of the slice can be calculated to be 1.68M, and the corresponding data includes 1680. If the sequence number of the first data block is 1, the data block corresponding to the slice is the sequence number 56520+50 to the serial number 58200+50. Data block between.
另外,在本发明实施例中所述的P2P服务器,可以为进行流媒体文件传输播放时的各个终端。比如用户A在下载了部分流媒体文件对应的数据块后,所述用户A所在的终端即可以作为P2P服务器,提供其已下载的数据,由其它P2P客户端进行下载。也即,用户所在的终端可以同时作为P2P客户端,也可以作为P2P服务器。 In addition, the P2P server described in the embodiment of the present invention may be each terminal when performing streaming media file transmission and playback. For example, after user A downloads a data block corresponding to a part of the streaming media file, the terminal where the user A is located can serve as a P2P server, and provides the downloaded data, which is downloaded by other P2P clients. That is, the terminal where the user is located can serve as both a P2P client and a P2P server.
由于切割后的数据块中均包含有数据块的序号,所述序号可以在数据块中的预定位置设置8字节的空间进行存储。在切割生成数据块后,可以将数据块存储在任意P2P服务器中的位置,通过从不同的P2P服务器中获取数据块,根据其中的序号组合,即可重新组合生成分片,从而大大的提高了对流媒体文件的管理的便利性,并且可以分布至多个P2P服务器进行分享下载,有利于提高流媒体文件下载的便利性,提高下载速度。 Since the data block after the dicing includes the sequence number of the data block, the serial number can be stored in an 8-byte space at a predetermined position in the data block. After the data block is cut and generated, the data block can be stored in a position in any P2P server, and the data block can be obtained from different P2P servers, and the combination of the serial numbers can be used to reassemble the generated fragments, thereby greatly improving the number of blocks. The convenience of management of streaming media files can be distributed to multiple P2P servers for sharing and downloading, which is beneficial to improving the convenience of downloading streaming media files and improving download speed.
实施例二: Embodiment 2:
图2示出了本发明第二实施例提供的流媒体文件的存储方法的实现流程,详述如下: FIG. 2 is a flowchart showing an implementation process of a method for storing a streaming media file according to a second embodiment of the present invention, which is described in detail as follows:
在步骤S201中,获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割,得到所述流媒体文件对应的多个分片,以及包含所述分片的偏移量和指向所述分片的指针的索引文件。 In step S201, the streaming media file to be stored is obtained, and the streaming media file is segmented according to a preset duration, and multiple fragments corresponding to the streaming media file are obtained, and an offset including the fragment is obtained. And an index file pointing to the pointer of the shard.
在步骤S202中,将所述索引文件与所述流媒体文件分割后的分片进行合并,生成合并后的文件。 In step S202, the index file is merged with the slice segmented by the streaming media file to generate a merged file.
步骤S201-S202与实施例一中步骤S101-S102基本相同,在此不作重复赘述。 The steps S201-S202 are substantially the same as the steps S101-S102 in the first embodiment, and are not described herein again.
在步骤S203中,将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,在所述多个P2P服务器中的每个终端中存储切割后的所有数据块,或者切割后的部分数据块。 In step S203, the merged file is sequentially cut according to a preset size to obtain a plurality of data blocks, where the data block includes a serial number corresponding to the data block, and each of the plurality of P2P servers All the data blocks after cutting are stored in the terminal, or some of the data blocks after cutting.
与实施例一不同之处在于,本发明实施例中对P2P服务器中存储的数据进行了具体限定,包括以下存储方式: The difference from the first embodiment is that the data stored in the P2P server is specifically limited in the embodiment of the present invention, including the following storage manners:
第一种方式,在多个P2P服务器中存储所述流媒体文件切割后的所有数据块,在P2P客户进行流媒体文件的下载播放时,可以从任意一台P2P服务器中下载任意序号的数据块,这种方式的好处在于,在其中任意一台P2P服务器出现故障时,对P2P客户的影响比较小,但P2P服务器中需要较大的空间进行数据的存储; In the first mode, all the data blocks cut by the streaming media file are stored in a plurality of P2P servers, and when the P2P client downloads and plays the streaming media file, the data block of any serial number can be downloaded from any P2P server. The advantage of this method is that when any one of the P2P servers fails, the impact on the P2P client is relatively small, but the P2P server requires a large space for data storage;
第二种方式,在多个P2P服务器中,每个P2P服务器只存储一部分数据块,比如在服务器1中存储数据块序号为1-3、10-12……在服务器2中存储4-6,13-15……,在服务器3中存储7-9,16-18……,当然这只是一种举例,通过多个P2P服务器的数据配合,可以使得P2P客户端可以快速的从不同的P2P服务器下载得到数据块,从而提高播放的流畅性。 In the second method, in a plurality of P2P servers, each P2P server stores only a part of data blocks, for example, in the server 1, the data block numbers are 1-3, 10-12, and the server 2 stores 4-6. 13-15... Store 7-9, 16-18... in server 3. Of course, this is just an example. Through the data cooperation of multiple P2P servers, P2P clients can be quickly accessed from different P2P servers. Download the data block to improve the smoothness of playback.
第三种方式,即为第一种方式与第二种方式的集合,即在一部分P2P服务器中存储所述流媒体文件切割后的所有数据块,在另一部分P2P服务器中存储一部分数据块,既可以提高P2P终端下载的速度,也能够尽可能的减小部分P2P服务器出现故障时对P2P客户端造成的影响。 The third method is a collection of the first mode and the second mode, that is, storing all the data blocks cut by the streaming media file in a part of the P2P server, and storing a part of the data blocks in another part of the P2P server, It can improve the download speed of P2P terminals, and can also reduce the impact on P2P clients when some P2P servers fail.
本发明实施例通过对数据的存储进行了具体的说明,根据具体的需要,可以选择不同的数据块存储方式,可以有利于提高数据下载速度,或者可以节省存储空间。 The embodiment of the present invention specifically describes the storage of data, and according to specific needs, different data block storage modes may be selected, which may be beneficial to improve data download speed or save storage space.
实施例三: Embodiment 3:
图3示出了本发明第三实施例提供的流媒体文件的存储方法的实现流程,详述如下: FIG. 3 is a flowchart showing an implementation process of a method for storing a streaming media file according to a third embodiment of the present invention, which is described in detail as follows:
在步骤S301中,获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割,得到所述流媒体文件对应的多个分片,以及包含所述分片的偏移量和指向所述分片的指针的索引文件。 In step S301, the streaming media file to be stored is obtained, and the streaming media file is segmented according to a preset duration, and multiple fragments corresponding to the streaming media file are obtained, and an offset including the fragment is obtained. And an index file pointing to the pointer of the shard.
在步骤S302中,将所述索引文件与所述流媒体文件分割后的分片进行合并,生成合并后的文件。 In step S302, the index file is merged with the slice segmented by the streaming media file to generate a merged file.
在步骤S303中,将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,将所述数据块发送至多个P2P服务器进行存储,对每个数据块进行校验,生成每个数据块对应的校验信息,并将所述校验信息添加到数据块中。 In step S303, the merged file is sequentially cut according to a preset size to obtain a plurality of data blocks, where the data block includes a serial number corresponding to the data block, and the data block is sent to multiple P2P servers. The storage is performed, each data block is verified, the verification information corresponding to each data block is generated, and the verification information is added to the data block.
其中,对每个数据块进行校验,可以采用CRC(英文全称为:Cyclic Redundancy Check,中文全称为循环冗余校验)校验算法进行校验。 Among them, for each data block to be verified, CRC can be used (English full name: Cyclic Redundancy Check, Chinese full name is the cyclic redundancy check) check algorithm to verify.
与实施例一相比,本发明实施例的不同之处在于,本发明实施例还包括对每个数据块生成校验信息,比如对每个数据块进行CRC校验,并将CRC校验信息存储至数据块中,比如可以分配4个字节的空间用于存储CRC校验信息。 Compared with the first embodiment, the embodiment of the present invention is different in that the embodiment of the present invention further includes generating check information for each data block, for example, performing CRC check on each data block, and setting CRC check information. Stored in a data block, for example, a space of 4 bytes can be allocated for storing CRC check information.
当P2P客户端下载数据块时,可以对下载的数据块进行CRC校验,即对数据块中去除校验信息存放区的其它数据进行校验,得到CRC校验的结果值,将所述校验的结果值与数据块中存储的校验信息进行比较,如果校验结果值与存储的校验信息相符,则表示数据块没有受到损坏,如果不相符,则表示数据块受到损坏,可能在播放时出现花屏或者其它图像或声音的故障。可自动重新下载该数据块。 When the P2P client downloads the data block, the CRC check may be performed on the downloaded data block, that is, the other data in the data block from which the check information storage area is removed is verified, and the result value of the CRC check is obtained, and the school is The result value of the test is compared with the check information stored in the data block. If the check result value matches the stored check information, it means that the data block is not damaged. If it does not match, the data block is damaged, possibly A malfunction of the screen or other image or sound occurs during playback. The data block can be re-downloaded automatically.
本发明实施例通过对数据块的完整性进行校验,及时发现受损的数据块,以使得能够对受损的数据进行更新或者重新下载,从而可以进一步提高流媒体文件的播放质量。 In the embodiment of the present invention, the integrity of the data block is verified, and the damaged data block is found in time, so that the damaged data can be updated or re-downloaded, thereby further improving the playback quality of the streaming media file.
实施例四: Embodiment 4:
图4示出了本发明第四实施例提供的流媒体文件下载播放方法的实现流程,详述如下: FIG. 4 is a flowchart showing an implementation process of a streaming media file downloading and playing method according to a fourth embodiment of the present invention, which is described in detail as follows:
在步骤S401中,根据数据块序号,从一个或者多个P2P服务器中下载数据块。 In step S401, the data block is downloaded from one or more P2P servers according to the data block number.
具体的,本发明实施例中所述流媒体文件下载播放方法,与实施例一至三中所述的流媒体文件的存储方法相对应,即本发明实施例中所述流媒体文件播放方法,用于播放的文件为实施例一至三中存储的流媒体文件。 Specifically, the method for downloading and playing the streaming media file in the embodiment of the present invention corresponds to the method for storing the streaming media file according to the first to third embodiments, that is, the streaming media file playing method in the embodiment of the present invention is used. The files played are the streaming media files stored in Embodiments 1 to 3.
与实施例一相对应的,在所述数据块中存储有数据块序号,根据所述数据块中序号的大小,从一个或者多个P2P服务器中下载数据块。 Corresponding to the first embodiment, the data block number is stored in the data block, and the data block is downloaded from one or more P2P servers according to the size of the serial number in the data block.
当从一个P2P服务器中下载数据块,则只需要根据数据块序号的大小,从小到大依次进行下载即可。 When downloading data blocks from a P2P server, it is only necessary to download them in order from the smallest to the largest according to the size of the data block number.
当从多个P2P服务器中下载数据块,则可以设定不同P2P服务器的下载的序号范围的任务,从而实现在多个P2P服务器中同时下载所需要的数据块,并且下载的数据块不会重复。 When downloading data blocks from a plurality of P2P servers, a task of downloading a sequence number range of different P2P servers can be set, thereby realizing simultaneous downloading of required data blocks in a plurality of P2P servers, and the downloaded data blocks are not repeated. .
将下载的数据块需要组合成分片,因此可以优先将下载的数据块存放在内存中,通过内存快速进行组合。 The downloaded data blocks need to be combined into slices, so the downloaded data blocks can be preferentially stored in the memory and quickly combined through the memory.
当下载的数据块中不包括索引文件时,可以在下载数据块前先下载索引文件。当所述索引文件位于所述数据块中时,可根据下载的数据中的序号以及索引文件的大小,得到所述索引文件。 When the index file is not included in the downloaded data block, the index file can be downloaded before the data block is downloaded. When the index file is located in the data block, the index file may be obtained according to the serial number in the downloaded data and the size of the index file.
在步骤S402中,解析下载的索引文件,根据索引文件中偏移量计算每个分片的大小以及分片播放顺序。 In step S402, the downloaded index file is parsed, and the size of each slice and the slice play order are calculated according to the offset in the index file.
对所述下载的数据块中的索引文件进行解析,由于在索引文件中包括分片的指针序列,通过该指针序列可以得到分片的播放顺序。另外,在索引文件中包括每个分片的偏移量,根据偏移量可以计算得到分片的大小。其中根据偏移量计算分片大小已在实施例一中进行了具体的说明,在此不作重复赘述。 The index file in the downloaded data block is parsed. Since the index sequence of the slice is included in the index file, the play sequence of the slice can be obtained by the pointer sequence. In addition, the offset of each slice is included in the index file, and the size of the slice can be calculated according to the offset. The calculation of the slice size according to the offset has been specifically described in the first embodiment, and will not be repeated here.
在步骤S403中,根据需要播放的分片的大小,获取所述分片对应的数据块,将数据块构成的分片发送至播放器播放。 In step S403, according to the size of the slice to be played, the data block corresponding to the slice is acquired, and the slice formed by the data block is sent to the player for playing.
在每个分片的大小都可以计算出来后,根据计算的分片的大小,可以得到每个分片对应的数据块的序号范围。 After the size of each slice can be calculated, according to the calculated size of the slice, the sequence number range of the data block corresponding to each slice can be obtained.
根据索引文件中的指针序列,可以得到需要播放的分片,根据所述播放的分片,查找对应的数据块号,向P2P服务器发送获取对应的数据块的请求,根据P2P服务器返回的数据块进行组合,即可得到需要播放的分片,将所述分片发送至播放器即可进行流媒体文件的播放。 According to the sequence of pointers in the index file, the fragment to be played can be obtained, and the corresponding data block number is searched according to the played fragment, and the request for acquiring the corresponding data block is sent to the P2P server, according to the data block returned by the P2P server. By combining, the piece to be played can be obtained, and the piece can be sent to the player to play the streaming file.
作为本发明实施例中一种优选的实施方式,还可以设定不同的P2P服务器的下载的任务量的大小,具体包括: As a preferred implementation manner of the embodiment of the present invention, the size of the downloaded task of the different P2P servers may be set, including:
获取P2P客户端与多个P2P服务器之间的通信速度信息; Obtaining communication speed information between the P2P client and multiple P2P servers;
根据所述P2P客户端与多个P2P服务器之间的通信速度信息,分配相应大小的数据块下载任务至各个P2P服务器。 And according to the communication speed information between the P2P client and the plurality of P2P servers, the data block download task of the corresponding size is allocated to each P2P server.
由于不同的P2P服务器传输的速率不相同,因此,在下载前可以对P2P服务器的连接速度进行测试,将传输速度高的服务器设置较多的下载任务量,对传输速度低的服务器设置较少的下载任务量,从而能够进一步提高下载的速度的同时,也可以有助于P2P客户端的网络资源的充分利用。 Since the transmission speeds of different P2P servers are different, the connection speed of the P2P server can be tested before downloading, the number of download tasks of the server with high transmission speed is set, and the number of servers with low transmission speed is set less. By downloading the amount of tasks, the download speed can be further improved, and the network resources of the P2P client can be fully utilized.
本发明实施例与实施例一所述的流媒体文件的存储方法对应,通过这种流媒体文件的播放方法,可以实现基于HTTP协议的HLS的P2P播放,即能够提高播放速度,方便数据管理的同时,可以实现不同码率的快速切换。 The embodiment of the present invention corresponds to the method for storing a streaming media file according to the first embodiment. Through the streaming method of the streaming media file, the P2P playback of the HLS based on the HTTP protocol can be realized, that is, the playback speed can be improved, and the data management is facilitated. At the same time, fast switching of different code rates can be achieved.
实施例五: Embodiment 5:
图5为本发明实施例提供的流媒体文件下载播放方法的实现流程图,详述如下: FIG. 5 is a flowchart of implementing a method for downloading and playing a streaming media file according to an embodiment of the present invention, which is as follows:
在步骤S501中,根据数据块序号,从一个或者多个P2P服务器中下载数据块。 In step S501, the data block is downloaded from one or more P2P servers according to the data block number.
在步骤S502中,解析下载的索引文件,根据索引文件中偏移量计算每个分片的大小以及分片播放顺序。 In step S502, the downloaded index file is parsed, and the size of each slice and the slice play order are calculated according to the offset in the index file.
步骤S501-S502与实施例四所述步骤S401-S402基本相同,在此不作重复赘述。 The steps S501-S502 are substantially the same as the steps S401-S402 described in the fourth embodiment, and are not repeatedly described herein.
在步骤S503中,根据需要播放的分片的大小,获取所述分片对应的数据块,根据数据块中包括的校验信息,对下载的数据块进行校验。 In step S503, the data block corresponding to the slice is acquired according to the size of the slice to be played, and the downloaded data block is verified according to the check information included in the data block.
与实施例四不同之处在于,本发明还包括对下载的数据块进行校验,即对数据块中的数据进行校验,得到校验结果,与数据块中存储的校验信息进行比较。 The difference from the fourth embodiment is that the present invention further includes verifying the downloaded data block, that is, verifying the data in the data block, obtaining a verification result, and comparing with the verification information stored in the data block.
在步骤S504中,当所述数据块不能通过校验时,则重新向P2P服务器下载所述数据块。 In step S504, when the data block cannot pass the verification, the data block is re-downloaded to the P2P server.
如果数据块中的校验信息与校验结果不同,则说明数据块在传输过程中可能受到损坏,如果将损坏的数据块进行播放,则可能会出现花屏或者声音不清楚的现象。 If the check information in the data block is different from the check result, the data block may be damaged during transmission. If the damaged data block is played, the screen may be unclear or the sound may be unclear.
为避免花屏或者声音不清楚情况的出现,本发明实施例中根据数据块的序号,重新向服务器下载文件,直到下载的文件满足要求为止。 In order to avoid the occurrence of a floppy or unclear situation, in the embodiment of the present invention, the file is re-downloaded to the server according to the serial number of the data block until the downloaded file satisfies the requirement.
为提高下载的成功率,可以根据当前已下载的出现损坏的数据块对应的服务器以外的其它服务器,进行该数据块的重新下载。 In order to improve the success rate of the download, the data block may be re-downloaded according to other servers other than the server that is currently downloaded and the damaged data block is present.
在步骤S505中,当所述数据块通过校验时,将数据块构成的分片发送至播放器播放。 In step S505, when the data block passes the verification, the slice formed by the data block is sent to the player for playback.
本发明实施例通过对数据块进行校验,可以进一步提高视频播放的质量。 The embodiment of the invention can further improve the quality of video playback by verifying the data block.
实施例六: Example 6:
本发明第六实施例提供了一种流媒体文件的播放系统,所述系统包括: A sixth embodiment of the present invention provides a streaming media file playing system, where the system includes:
P2P 服务器,所述P2P服务器用于存放切割后的数据块,所述数据块中包括数据块对应的序号,其中待切割的文件为流媒体文件进行分割后的分片以及所述分片对应的索引文件合并后的文件,所述索引文件中包含所述分片的偏移量以及指向所述分片的指针; P2P a server, the P2P server is configured to store the cut data block, where the data block includes a sequence number corresponding to the data block, where the file to be cut is a segment after the segmentation of the streaming media file and an index corresponding to the segment a file after the file is merged, the index file includes an offset of the slice and a pointer to the slice;
P2P 客户端,所述P2P客户端用于从一个或者多个P2P服务器中获取数据块,根据数据块的序号得到索引文件,解析所述索引文件,得到需要播放的流媒体文件的分片的大小以及需要读取的数据块,并将读取的数据块构成分片发送至播放器进行播放。 P2P a client, the P2P client is configured to obtain a data block from one or more P2P servers, obtain an index file according to the sequence number of the data block, parse the index file, and obtain a size of a fragment of the streaming media file to be played, and The data block to be read is sent, and the read data block is fragmented and sent to the player for playback.
其中,本发明实施例中所述P2P服务器中存储的流媒体文件的方式,可以通过实施例一至三中任意一种。所述P2P客户端对流媒体文件的播放方式,可以选用实施例四至五中任意一种。在此不作重复的赘述。 The manner of the streaming media file stored in the P2P server in the embodiment of the present invention may be any one of the first to third embodiments. For the playing mode of the streaming media file, the P2P client may select any one of the fourth to fifth embodiments. I will not repeat them here.
实施例七: Example 7:
图6为本发明第七实施例提的流媒体文件的存储装置的结构示意图,详述如下: FIG. 6 is a schematic structural diagram of a storage device for streaming media files according to a seventh embodiment of the present invention, which is described in detail as follows:
本发明实施例中所述流媒体文件的存储装置,包括: The storage device of the streaming media file in the embodiment of the present invention includes:
流媒体文件分割单元601,用于获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割,得到所述流媒体文件对应的多个分片,以及包含所述分片的偏移量和指向所述分片的指针的索引文件; The streaming media file dividing unit 601 is configured to obtain a streaming media file to be stored, and divide the streaming media file according to a preset duration to obtain a plurality of fragments corresponding to the streaming media file, and include the fragment. An offset file and an index file pointing to the pointer of the shard;
文件合并单元602,用于将所述索引文件与所述流媒体文件分割后的分片进行合并,生成合并后的文件; a file merging unit 602, configured to merge the index file with the segmented segment of the streaming media file to generate a merged file;
切割存储单元603,用于将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,将所述数据块发送至多个P2P服务器进行存储。 The cutting storage unit 603 is configured to sequentially cut the merged file according to a preset size to obtain a plurality of data blocks, where the data block includes a serial number corresponding to the data block, and send the data block to multiple The P2P server is stored.
优选的,所述切割存储单元还用于: Preferably, the cutting storage unit is further configured to:
对每个数据块进行校验,生成每个数据块对应的校验信息,并将所述校验信息添加到数据块中。 Each data block is verified, verification information corresponding to each data block is generated, and the verification information is added to the data block.
优选的,所述装置还包括: Preferably, the device further comprises:
编码单元,用于对视频进行编码,由编码器将采集的视频数据编码为H.264格式的视频,将采集音频数据编码为ACC格式的音频; a coding unit, configured to encode the video, and encode the collected video data into a video of H.264 format, and encode the collected audio data into audio of ACC format;
封装单元,用于将编码后的视频和音频封装为MPEG格式的流媒体文件。 A packaging unit for encapsulating the encoded video and audio into a streaming media file in an MPEG format.
优选的, 所述 切割存储单元还具体用于: Preferably, the cutting storage unit is further specifically configured to:
在所述多个P2P服务器中的每个终端中存储切割后的所有数据块,或者切割后的部分数据块。 All of the cut data blocks, or the cut partial data blocks, are stored in each of the plurality of P2P servers.
本发明实施例所述流媒体文件的存储装置,与实施例一至三所述流媒体文件的存储方法相对应,在此不作重复赘述。 The storage device of the streaming media file in the embodiment of the present invention corresponds to the storage method of the streaming media file in the first embodiment to the third embodiment, and details are not described herein.
由于切割后的数据块中均包含有数据块的序号,所述序号可以在数据块中的预定位置设置8字节的空间进行存储。在切割生成数据块后,可以将数据块存储在任意P2P服务器中的位置,通过从不同的P2P服务器中获取数据块,根据其中的序号组合,即可重新组合生成分片,从而大大的提高了对流媒体文件的管理的便利性,并且可以分布至多个P2P服务器进行分享下载,有利于提高流媒体文件下载的便利性,提高下载速度。 Since the data block after the dicing includes the sequence number of the data block, the serial number can be stored in an 8-byte space at a predetermined position in the data block. After the data block is cut and generated, the data block can be stored in a position in any P2P server, and the data block can be obtained from different P2P servers, and the combination of the serial numbers can be used to reassemble the generated fragments, thereby greatly improving the number of blocks. The convenience of management of streaming media files can be distributed to multiple P2P servers for sharing and downloading, which is beneficial to improving the convenience of downloading streaming media files and improving download speed.
实施例八: Example 8:
图7为本发明第八实施例提供的流媒体文件下载播放装置的结构示意图,详述如下: FIG. 7 is a schematic structural diagram of a streaming media file download and playback apparatus according to an eighth embodiment of the present invention, which is described in detail as follows:
本发明实施例所述流媒体文件下载播放装置,包括: The streaming media file downloading and playing device of the embodiment of the invention includes:
数据块下载模块701,用于根据数据块序号,从一个或者多个P2P服务器中下载数据块; a data block downloading module 701, configured to download a data block from one or more P2P servers according to the data block number;
索引文件解析模块702,用于解析下载的索引文件,根据索引文件中偏移量计算每个分片的大小以及分片播放顺序; The index file parsing module 702 is configured to parse the downloaded index file, and calculate the size of each slice and the slice play order according to the offset in the index file;
数据块获取发送模块703,用于根据需要播放的分片的大小,获取所述分片对应的数据块,将数据块构成的分片发送至播放器播放。 The data block acquisition and transmission module 703 is configured to acquire a data block corresponding to the fragment according to the size of the fragment to be played, and send the fragment formed by the data block to the player for playing.
优选的,所述装置还包括: Preferably, the device further comprises:
校验模块,根据数据块中包括的校验信息,对下载的数据块进行校验,当所述数据块不能通过校验时,则重新向P2P服务器下载所述数据块。 The verification module checks the downloaded data block according to the verification information included in the data block, and when the data block fails to pass the verification, the data block is re-downloaded to the P2P server.
优选的,所述装置还包括: Preferably, the device further comprises:
通信速度信息获取模块,用于获取P2P客户端与多个P2P服务器之间的通信速度信息; a communication speed information obtaining module, configured to acquire communication speed information between the P2P client and the plurality of P2P servers;
下载任务分配模块,用于根据所述P2P客户端与多个P2P服务器之间的通信速度信息,分配相应大小的数据块下载任务至各个P2P服务器。 The task assignment module is configured to allocate a data block download task of a corresponding size to each P2P server according to the communication speed information between the P2P client and the plurality of P2P servers.
本发明实施例所述流媒体文件的播放装置,与实施例四至五所述流媒体文件的播放方法相对应,在此不作重复赘述。 The device for playing a streaming media file according to the embodiment of the present invention corresponds to the method for playing the streaming media file according to the fourth to fifth embodiments, and details are not described herein.
通过将流媒体分割得到多个分片和索引文件后,对分片和索引文件进行合并生成的合并文件进行切割得到数据块,每个数据块中包括对应的序号,这样使得P2P客户端可以从任意的P2P服务器中下载数据块进行组合,得到分片,从而可以实现基于HTTP协议的HLS的P2P播放,能够提高播放速度,方便数据管理的同时,可以实现不同码率的快速切换。 After the streaming media is divided into multiple fragments and index files, the merged files generated by combining the fragments and the index files are cut to obtain data blocks, and each data block includes a corresponding serial number, so that the P2P client can The P2P server downloads the data blocks and combines them to obtain the fragmentation, so that the P2P playback of the HLS based on the HTTP protocol can be realized, the playback speed can be improved, the data management can be facilitated, and the fast switching of different code rates can be realized.
在本发明所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。 In the several 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 device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or 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 an 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.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分。而前述的存储介质包括: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 present invention, which is essential or contributes 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 medium. A number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the methods described in various embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, a read only memory (ROM, Read-Only) Memory, random access memory (RAM), disk or optical disk, and other media that can store program code.
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。 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 (13)

  1. 一种流媒体文件的存储方法,其特征在于,所述方法包括: A method for storing a streaming media file, the method comprising:
    获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割,得到所述流媒体文件对应的多个分片,以及包含所述分片的偏移量和指向所述分片的指针的索引文件;Obtaining a streaming media file to be stored, dividing the streaming media file according to a preset duration, obtaining a plurality of fragments corresponding to the streaming media file, and including an offset of the fragment and pointing to the segment The index file of the slice pointer;
    将所述索引文件与所述流媒体文件分割后的分片进行合并,生成合并后的文件;Combining the index file with the segmentation of the stream media file to generate a merged file;
    将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,将所述数据块发送至多个P2P服务器进行存储。The merged file is sequentially cut according to a preset size to obtain a plurality of data blocks, wherein the data block includes a serial number corresponding to the data block, and the data block is sent to a plurality of P2P servers for storage.
  2. 根据权利要求1所述方法,其特征在于,所述将所述数据块发送至多个P2P服务器进行存储步骤包括:The method according to claim 1, wherein the step of transmitting the data block to a plurality of P2P servers for storing comprises:
    在所述多个P2P服务器中的每个终端中存储切割后的所有数据块,或者切割后的部分数据块。All of the cut data blocks, or the cut partial data blocks, are stored in each of the plurality of P2P servers.
  3. 根据权利要求1所述方法,其特征在于,所述将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,将所述数据块发送至多个P2P服务器进行存储步骤还包括:The method according to claim 1, wherein the splicing the merged file in order according to a preset size to obtain a plurality of data blocks, wherein the data block includes a serial number corresponding to the data block, and The step of sending the data block to multiple P2P servers for storage further includes:
    对每个数据块进行校验,生成每个数据块对应的校验信息,并将所述校验信息添加到数据块中。Each data block is verified, verification information corresponding to each data block is generated, and the verification information is added to the data block.
  4. 根据权利要求1所述方法,其特征在于,在所述获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割步骤之前,所述方法还包括:The method according to claim 1, wherein before the step of performing the segmentation of the streaming media file according to a preset duration, the method further comprises:
    对视频进行编码,由编码器将采集的视频数据编码为H.264格式的视频,将采集音频数据编码为ACC格式的音频;Encoding the video, the encoder encodes the collected video data into a video of H.264 format, and encodes the collected audio data into audio of ACC format;
    将编码后的视频和音频封装为MPEG格式的流媒体文件。The encoded video and audio are packaged into a streaming media file in MPEG format.
  5. 一种流媒体文件下载播放方法,其特征在于,所述方法包括:A streaming media file download and play method, the method comprising:
    根据数据块序号,从一个或者多个P2P服务器中下载数据块;Downloading data blocks from one or more P2P servers according to the data block number;
    解析下载的索引文件,根据索引文件中偏移量计算每个分片的大小以及分片播放顺序;Parsing the downloaded index file, calculating the size of each shard and the shard play order according to the offset in the index file;
    根据需要播放的分片的大小,获取所述分片对应的数据块,将数据块构成的分片发送至播放器播放。The data block corresponding to the slice is obtained according to the size of the slice to be played, and the slice formed by the data block is sent to the player for playing.
  6. 根据权利要求5所述方法,其特征在于,在所述将数据块构成的分片发送至播放器播放步骤之前,所述方法还包括:The method according to claim 5, wherein before the step of transmitting the slice formed by the data block to the player playing step, the method further comprises:
    根据数据块中包括的校验信息,对下载的数据块进行校验;The downloaded data block is verified according to the verification information included in the data block;
    当所述数据块不能通过校验时,则重新向P2P服务器下载所述数据块。When the data block fails the verification, the data block is re-downloaded to the P2P server.
  7. 根据权利要求5所述方法,其特征在于,所述根据数据块序号,从一个或者多个P2P服务器中下载数据块步骤之前,所述方法还包括:The method according to claim 5, wherein the method further comprises: before the step of downloading a data block from the one or more P2P servers according to the data block number, the method further comprising:
    获取P2P客户端与多个P2P服务器之间的通信速度信息;Obtaining communication speed information between the P2P client and multiple P2P servers;
    根据所述P2P客户端与多个P2P服务器之间的通信速度信息,分配相应大小的数据块下载任务至各个P2P服务器。And according to the communication speed information between the P2P client and the plurality of P2P servers, the data block download task of the corresponding size is allocated to each P2P server.
  8. 一种流媒体文件的播放系统,其特征在于,所述播放系统包括:A playback system for streaming media files, characterized in that the playback system comprises:
    P2P 服务器,所述P2P服务器用于存放切割后的数据块,所述数据块中包括数据块对应的序号,其中待切割的文件为流媒体文件进行分割后的分片以及所述分片对应的索引文件合并后的文件,所述索引文件中包含所述分片的偏移量以及指向所述分片的指针;P2P a server, the P2P server is configured to store the cut data block, where the data block includes a sequence number corresponding to the data block, where the file to be cut is a segment after the segmentation of the streaming media file and an index corresponding to the segment a file after the file is merged, the index file includes an offset of the slice and a pointer to the slice;
    P2P 客户端,所述P2P客户端用于从一个或者多个P2P服务器中获取数据块,根据数据块的序号得到索引文件,解析所述索引文件,得到需要播放的流媒体文件的分片的大小以及需要读取的数据块,并将读取的数据块构成分片发送至播放器进行播放。P2P a client, the P2P client is configured to obtain a data block from one or more P2P servers, obtain an index file according to the sequence number of the data block, parse the index file, and obtain a size of a fragment of the streaming media file to be played, and The data block to be read is sent, and the read data block is fragmented and sent to the player for playback.
  9. 一种流媒体文件的存储装置,其特征在于,所述装置包括:A storage device for streaming media files, characterized in that the device comprises:
    流媒体文件分割单元,用于获取待存储的流媒体文件,根据预设的时长对所述流媒体文件进行分割,得到所述流媒体文件对应的多个分片,以及包含所述分片的偏移量和指向所述分片的指针的索引文件;a streaming media file dividing unit, configured to obtain a streaming media file to be stored, and divide the streaming media file according to a preset duration, to obtain a plurality of fragments corresponding to the streaming media file, and a fragment that includes the fragment An index file of the offset and the pointer to the slice;
    文件合并单元,用于将所述索引文件与所述流媒体文件分割后的分片进行合并,生成合并后的文件;a file merging unit, configured to merge the index file with the shards of the stream media file to generate a merged file;
    切割存储单元,用于将所述合并后的文件按照预设的大小进行按序切割,得到多个数据块,所述数据块中包括数据块对应的序号,将所述数据块发送至多个P2P服务器进行存储。Cutting a storage unit, configured to sequentially cut the merged file according to a preset size, to obtain a plurality of data blocks, where the data block includes a serial number corresponding to the data block, and send the data block to multiple P2Ps The server is storing.
  10. 根据权利要求9所述装置,其特征在于,所述切割存储单元还用于:The apparatus according to claim 9, wherein said cutting storage unit is further configured to:
    对每个数据块进行校验,生成每个数据块对应的校验信息,并将所述校验信息添加到数据块中。Each data block is verified, verification information corresponding to each data block is generated, and the verification information is added to the data block.
  11. 根据权利要求9所述装置,其特征在于,所述装置还包括:The device according to claim 9, wherein the device further comprises:
    编码单元,用于对视频进行编码,由编码器将采集的视频数据编码为H.264格式的视频,将采集音频数据编码为ACC格式的音频;a coding unit, configured to encode the video, and encode the collected video data into a video of H.264 format, and encode the collected audio data into audio of ACC format;
    封装单元,用于将编码后的视频和音频封装为MPEG格式的流媒体文件。A packaging unit for encapsulating the encoded video and audio into a streaming media file in an MPEG format.
  12. 一种流媒体文件下载播放装置,其特征在于,所述装置包括:A streaming media file download and playback device, characterized in that the device comprises:
    数据块下载模块,用于根据数据块序号,从一个或者多个P2P服务器中下载数据块;a data block downloading module, configured to download a data block from one or more P2P servers according to the data block number;
    索引文件解析模块,用于解析下载的索引文件,根据索引文件中偏移量计算每个分片的大小以及分片播放顺序;An index file parsing module is configured to parse the downloaded index file, and calculate the size of each shard and the shard play order according to the offset in the index file;
    数据块获取发送模块,用于根据需要播放的分片的大小,获取所述分片对应的数据块,将数据块构成的分片发送至播放器播放。The data block acquisition sending module is configured to acquire a data block corresponding to the fragment according to the size of the fragment to be played, and send the fragment formed by the data block to the player for playing.
  13. 根据权利要求12所述装置,其特征在于,所述装置还包括:The device of claim 12, wherein the device further comprises:
    校验模块,根据数据块中包括的校验信息,对下载的数据块进行校验,当所述数据块不能通过校验时,则重新向P2P服务器下载所述数据块。The verification module checks the downloaded data block according to the verification information included in the data block, and when the data block fails to pass the verification, the data block is re-downloaded to the P2P server.
PCT/CN2015/088766 2015-09-01 2015-09-01 Method, device, and system for storing streaming media file WO2017035787A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/088766 WO2017035787A1 (en) 2015-09-01 2015-09-01 Method, device, and system for storing streaming media file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/088766 WO2017035787A1 (en) 2015-09-01 2015-09-01 Method, device, and system for storing streaming media file

Publications (1)

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

Family

ID=58186527

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/088766 WO2017035787A1 (en) 2015-09-01 2015-09-01 Method, device, and system for storing streaming media file

Country Status (1)

Country Link
WO (1) WO2017035787A1 (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111405313A (en) * 2019-06-28 2020-07-10 杭州海康威视系统技术有限公司 Method and system for storing streaming media data
CN112287127A (en) * 2019-07-23 2021-01-29 上海哔哩哔哩科技有限公司 Multimedia file storage and reading method
CN112584155A (en) * 2020-12-11 2021-03-30 南京中兴力维软件有限公司 Video data processing method and device
CN113365084A (en) * 2021-05-12 2021-09-07 烽火通信科技股份有限公司 Method and device for controlling sending speed by using time wheel
CN113992660A (en) * 2021-10-29 2022-01-28 维沃移动通信有限公司 File transmission method and device, electronic equipment and storage medium
CN114679438A (en) * 2022-03-03 2022-06-28 上海艾策通讯科技股份有限公司 Streaming media data transmission method and device, computer equipment and storage medium
CN117336311A (en) * 2023-11-30 2024-01-02 深圳市小溪流科技有限公司 Method and device for keeping consistency of multiple HLS server slices

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101141627A (en) * 2007-10-23 2008-03-12 深圳市迅雷网络技术有限公司 Storage system and method of stream media file
CN101917388A (en) * 2009-12-17 2010-12-15 新奥特(北京)视频技术有限公司 Streaming media data storage method and device
US20100332621A1 (en) * 2008-02-22 2010-12-30 Telefonaktiebolaget Lm Ericsson (Publ) Method and Apparatus for Obtaining Media Over a Communications Network
CN101997890A (en) * 2009-08-28 2011-03-30 中国移动通信集团公司 P2P stream media downloading method, system and device
CN102255695A (en) * 2011-07-22 2011-11-23 乐视网信息技术(北京)股份有限公司 Data check method and system applied to peer-to-peer (p2p) network delivery system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101141627A (en) * 2007-10-23 2008-03-12 深圳市迅雷网络技术有限公司 Storage system and method of stream media file
US20100332621A1 (en) * 2008-02-22 2010-12-30 Telefonaktiebolaget Lm Ericsson (Publ) Method and Apparatus for Obtaining Media Over a Communications Network
CN101997890A (en) * 2009-08-28 2011-03-30 中国移动通信集团公司 P2P stream media downloading method, system and device
CN101917388A (en) * 2009-12-17 2010-12-15 新奥特(北京)视频技术有限公司 Streaming media data storage method and device
CN102255695A (en) * 2011-07-22 2011-11-23 乐视网信息技术(北京)股份有限公司 Data check method and system applied to peer-to-peer (p2p) network delivery system

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111405313A (en) * 2019-06-28 2020-07-10 杭州海康威视系统技术有限公司 Method and system for storing streaming media data
CN111405313B (en) * 2019-06-28 2023-11-14 杭州海康威视系统技术有限公司 Method and system for storing streaming media data
CN112287127A (en) * 2019-07-23 2021-01-29 上海哔哩哔哩科技有限公司 Multimedia file storage and reading method
CN112287127B (en) * 2019-07-23 2022-10-14 上海哔哩哔哩科技有限公司 Multimedia file storage and reading method
CN112584155A (en) * 2020-12-11 2021-03-30 南京中兴力维软件有限公司 Video data processing method and device
CN112584155B (en) * 2020-12-11 2022-11-04 南京中兴力维软件有限公司 Video data processing method and device
CN113365084A (en) * 2021-05-12 2021-09-07 烽火通信科技股份有限公司 Method and device for controlling sending speed by using time wheel
CN113992660A (en) * 2021-10-29 2022-01-28 维沃移动通信有限公司 File transmission method and device, electronic equipment and storage medium
CN114679438A (en) * 2022-03-03 2022-06-28 上海艾策通讯科技股份有限公司 Streaming media data transmission method and device, computer equipment and storage medium
CN114679438B (en) * 2022-03-03 2024-04-30 上海艾策通讯科技股份有限公司 Streaming media data transmission method, device, computer equipment and storage medium
CN117336311A (en) * 2023-11-30 2024-01-02 深圳市小溪流科技有限公司 Method and device for keeping consistency of multiple HLS server slices
CN117336311B (en) * 2023-11-30 2024-03-12 深圳市小溪流科技有限公司 Method and device for keeping consistency of multiple HLS server slices

Similar Documents

Publication Publication Date Title
WO2017035787A1 (en) Method, device, and system for storing streaming media file
WO2012177041A2 (en) Media content transceiving method and transceiving apparatus using same
WO2013162312A1 (en) Method and apparatus for transceiving data for multimedia transmission system
WO2017035786A1 (en) Method, device, and system for playing and checking streaming media file
WO2012060581A2 (en) Method for transreceiving media content and device for transreceiving using same
WO2012011724A2 (en) Method for transceiving media files and device for transmitting/receiving using same
WO2011059272A2 (en) Method and apparatus for providing trick play service
WO2011108893A2 (en) Method and apparatus for generating and reproducing adaptive stream based on file format, and recording medium thereof
WO2011059273A2 (en) Method and apparatus for adaptive streaming using segmentation
WO2013077698A1 (en) Method for linking mmt media and dash media
WO2013077697A1 (en) Method for hybrid delivery of mmt pakcage and content and method for receiving content
WO2013141666A1 (en) Hybrid delivery method and reception method for mmt packaged svc video contents
WO2011152675A2 (en) Method and apparatus for adaptive streaming based on plurality of elements for determining quality of content
WO2015034245A1 (en) Transmitting apparatus, receiving apparatus, and signal processing method thereof
WO2011059274A2 (en) Adaptive streaming method and apparatus
WO2015002406A1 (en) Method and apparatus of data authentication
WO2012077982A2 (en) Transmitter and receiver for transmitting and receiving multimedia content, and reproduction method therefor
WO2012099359A2 (en) Reception device for receiving a plurality of real-time transfer streams, transmission device for transmitting same, and method for playing multimedia content
WO2013112027A1 (en) Method for estimating network jitter in apparatus for transmitting coded media data
WO2017035783A1 (en) Streaming media transmission and play method, and transmission and play device
WO2015012605A1 (en) Method and apparatus for encoding three-dimensional content
WO2020076058A1 (en) Method and apparatus for generating media file comprising 3-dimensional video content, and method and apparatus for replaying 3-dimensional video content
EP3017571A1 (en) Transmitting apparatus, receiving apparatus and signal processing method thereof
WO2016195354A1 (en) Transmitting apparatus, receiving apparatus, and method for controlling the same
WO2012011722A2 (en) Method for transmitting/receiving media and device for transmitting/receiving using same

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

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

Country of ref document: EP

Kind code of ref document: A1