WO2017035802A1 - 一种传输流编码、播放的方法和装置 - Google Patents

一种传输流编码、播放的方法和装置 Download PDF

Info

Publication number
WO2017035802A1
WO2017035802A1 PCT/CN2015/088816 CN2015088816W WO2017035802A1 WO 2017035802 A1 WO2017035802 A1 WO 2017035802A1 CN 2015088816 W CN2015088816 W CN 2015088816W WO 2017035802 A1 WO2017035802 A1 WO 2017035802A1
Authority
WO
WIPO (PCT)
Prior art keywords
transport stream
packet
file
information
fragmentation
Prior art date
Application number
PCT/CN2015/088816
Other languages
English (en)
French (fr)
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/088816 priority Critical patent/WO2017035802A1/zh
Publication of WO2017035802A1 publication Critical patent/WO2017035802A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/2343Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/83Generation or processing of protective or descriptive data associated with content; Content structuring
    • H04N21/845Structuring of content, e.g. decomposing content into time segments

Definitions

  • the invention belongs to the field of multimedia transmission, and in particular relates to a method and a device for encoding and playing a transport stream.
  • Transport stream referred to as TS (English full name Transport) Stream) is a digital encapsulation format used to package basic audio and video streams and other data. It may consist of one or more programs, each program being composed of one or more original streams and some other streams, including video streams, audio streams, program specific information streams (PSI), and other data packets.
  • PSI program specific information streams
  • the TS stream is designed to allow digital video and digital audio to be multiplexed and synchronized and to transmit one or more program coded data, non-linear editing and storage of television programs, etc., in the event of a serious error.
  • the process of forming the TS stream is: after the audio and video data is encoded by the source, the program is multiplexed with the auxiliary data to form an elementary stream (referred to as ES in English, the full name in English) Elementary Stream).
  • the basic code stream (ES) and the packet header (such as the data stream identification code including the ES for distinguishing different properties, PTS and PDS) are packaged to form a packetized basic code stream (referred to as PES in English, the full name in English) Packetized Elementary Stream).
  • PES packetized basic code stream
  • PES packetized basic code stream
  • the elementary stream is played by reading the information in the header.
  • the currently used streaming media protocols include HLS technology developed by Apple (English full name: HTTP Live) Streaming ).
  • HLS technology developed by Apple (English full name: HTTP Live) Streaming .
  • the segmentation process usually cuts by time, such as dividing into one slice for 10s duration, and if the code stream is high, the slice length can be divided into 5 second. And generate an index file (suffix m3u8) containing pointers to these small TS fragments.
  • the current transport stream is encoded differently from the HLS file, the current video file, such as an HLS file, or a transport stream file, is played in the transport stream player and the HLS player at the same time, which is not conducive to improving playback. flexibility.
  • the object of the present invention is to provide a method for encoding and playing a transport stream, so as to solve the problem that the video file of the prior art is played in the transport stream player and the HLS player at the same time, which is not conducive to improving the flexibility of playback. .
  • an embodiment of the present invention provides a method for encoding a transport stream, where the method includes:
  • transport stream to be encoded includes one or more transport stream packets, where the transport stream packet includes packet data and header information;
  • the step of adding the fragment information to the packet header information corresponding to the transport stream packet includes:
  • the slice information is written to the reserved storage space.
  • the packet data is cut according to a preset fragmentation duration
  • the step of obtaining the fragment file of the packet data and the fragmentation information step includes :
  • the packet data is cut according to a preset fragmentation duration to obtain a fragment file and each segment
  • the sequence number steps corresponding to the slice file include:
  • fragment files in different transport stream packets in the transport stream to be encoded are separately numbered to obtain a fragment file sequence number including the transport stream packet identifier information.
  • an embodiment of the present invention provides a method for playing a transport stream, where the method includes:
  • An HLS stream play file is generated according to the index file and the slice file.
  • the method before the step of acquiring the header information included in the transport stream packet and searching for the preset fragment information in the packet header information, the method also includes:
  • the current player is a transport stream player, controlling the packet data to play according to the header information in the transport stream packet;
  • the step of acquiring the header information included in the transport stream packet and searching for the preset fragment information in the header information is performed.
  • the fragmentation information includes a fragmentation duration and a fragment sequence number, where the acquiring the transport stream packet is included according to the fragmentation information.
  • the fragment file and the index file corresponding to the fragment file include:
  • the sequence number corresponding to each slice file is obtained according to the order in which the packet data is cut.
  • an embodiment of the present invention provides a transport stream encoding apparatus, where the apparatus includes:
  • a transport stream obtaining unit configured to acquire a transport stream to be encoded, where the transport stream to be encoded includes one or more transport stream packets, where the transport stream packet includes packet data and packet header information;
  • a cutting unit configured to cut the packet data according to a preset fragmentation duration, to obtain a fragment file of the packet data, and fragmentation information
  • an information adding unit configured to add the fragmentation information to the header information corresponding to the transport stream packet.
  • the information adding unit includes:
  • a storage space determining subunit configured to determine, according to a preset storage location relationship between the packet header information and the storage space of the packet header, a storage space reserved by the packet header information in the transport stream packet;
  • the information writing subunit is configured to write the fragmentation information into the reserved storage space.
  • an embodiment of the present invention provides a transport stream playing device, where the device includes:
  • a header information obtaining unit configured to acquire, in a transport stream packet in the transport stream, packet header information included in the transport stream packet
  • a fragmentation information searching unit configured to search for preset fragmentation information in the packet header information
  • a file obtaining unit configured to acquire, according to the fragmentation information, a fragment file included in the transport stream packet and an index file corresponding to the fragment file;
  • a playing unit configured to generate an HLS stream play file according to the index file and the slice file.
  • the fragment information includes a fragmentation duration and a fragment sequence number
  • the file obtaining unit includes:
  • a fragmentation file obtaining subunit configured to cut the packet data in the transport stream packet according to the fragmentation duration, to obtain the sliced fragment file
  • the slice number acquisition subunit is configured to obtain a sequence number corresponding to each slice file according to an order of cutting the package data.
  • the packet data in the transport stream packet is cut to obtain a slice file and a slice.
  • the information is added to the header information in the transport stream packet, and can be played by the transport stream player during playback, and the index file of the fragment file can be generated according to the header information, and played by the HLS player. Increased flexibility in playback.
  • FIG. 1 is a flowchart of an implementation of a method for encoding a transport stream according to a first embodiment of the present invention
  • FIG. 2 is a flowchart of an implementation of a method for playing a transport stream according to a second embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of an apparatus for encoding a transport stream according to a third embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a playback device for a transport stream according to a fourth embodiment of the present invention.
  • the main purpose of the embodiments of the present invention is to solve the problem that the transport stream files used in the prior art are widely used, and the use of more and more HLS files cannot be simultaneously played.
  • the video source in the server includes only one of the formats, or the format of the video source saved in different servers is different
  • the client plays in order to ensure that the video file can be played, two players need to be installed. This will undoubtedly occupy the client's storage resources and computing resources.
  • the video files of the same video content are converted into different formats for storage, which requires twice or more storage resources.
  • the invention is based on the solution that the video file cannot be adapted to various players in the prior art, and is specifically described below with reference to the accompanying drawings.
  • Embodiment 1 is a diagrammatic representation of Embodiment 1:
  • FIG. 1 is a flowchart showing an implementation process of a coding method of a transport stream according to a first embodiment of the present invention, which is described in detail as follows:
  • step S101 a transport stream to be encoded is obtained, where the transport stream to be encoded includes one or more transport stream packets, and the transport stream packets include packet data and header information.
  • a TS stream generally includes a plurality of transport stream packets, also called TS packets.
  • each TS packet it consists of a header, an adaptation area, and a packet data.
  • Each packet can be fixed at 188 bytes in length and 4 in header length.
  • the byte, adaptive area and packet data length are 184 bytes.
  • 184 bytes is a useful information space for transmitting encoded video and audio data streams.
  • the header also includes a variable-length adaptive region, and the length of the header is greater than 4 bytes.
  • the entire transmission packet should have a fixed length equivalent to 4 ATM packets.
  • the header of the TS packet includes the sync byte, the transmission error indicator, the payload unit start indicator, the transmission priority, and the packet identification (PID-Packet). Identification, transmission scrambling control, adaptive zone control and continuous counter are composed of 8 parts.
  • the synchronization byte bit can detect the packet restriction in the data stream and establish packet synchronization through its automatic correlation feature
  • a payload unit start indicator indicating whether the data packet has a determined start information
  • Transmission priority which can be used to assign priority to TS packets
  • the PID value is determined by the user, and the decoder distinguishes the TS packets from the different ESs on the TS according to the PID to reconstruct the original ES;
  • Transmission scrambling control which indicates whether the content of the data packet is scrambled, but the header and the adaptive area are never scrambled;
  • Adaptive zone control with 2 The bit indicates whether there is an adaptive region, that is, (01) indicates that there is no adaptive region with useful information, (10) indicates that there is no useful information with an adaptive region, (11) indicates that there is useful information with an adaptive region, and (00) has no definition. ;
  • the continuous counter can count the PID packet transmission sequence. According to the counter reading, the receiving end can judge whether there is packet loss and the packet transmission sequence is wrong. Obviously, the packet header has synchronization, identification, error detection and encryption functions for the TS packet.
  • the TS packet adaptation area is composed of an adaptive sector length, various flag indicators, information related to the insertion flag, and padding data.
  • the flag part consists of a discontinuity indicator, a random access indicator, and ES (Elementary Streams, original stream) optimization indicator, PCR flag, contact flag, transmission-specific data flag, original PCR flag, adaptive region extension flag are composed of 8 parts.
  • the transport stream to be encoded may be used for the TS stream in the server, or may be saved in other terminals, or generated TS stream.
  • the transport stream to be encoded has the same encoding rule as the existing transport stream, and can be played by an ordinary TS stream player.
  • step S102 the packet data is cut according to a preset fragmentation duration to obtain a fragment file of the packet data and fragmentation information.
  • the step of cutting the packet data according to a preset fragmentation duration, and obtaining the fragment file and the fragmentation information of the packet data includes:
  • the embodiment of the present invention further expands the cutting and the header information on the basis of the existing TS stream, and specifically includes:
  • Cutting packet data in a TS packet the packet data, that is, source data for playback included in the TS stream, including video source data (encoded), audio source data (encoded)
  • the video source data or the audio source is cut according to a preset time period according to a preset segmentation time, and the sliced slice is sequentially processed according to the cutting sequence.
  • the files are numbered to obtain the serial number corresponding to the fragment file.
  • the preset segmentation duration may be selected according to the code rate and different duration values. 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 the suffix ".ts" appended to each file.
  • the sequence number of the fragment file may consecutively number the sequence numbers of the plurality of transport stream packets, so that all the fragment files in the transport stream are consecutive. For example, if the sequence number of the slice file of the first transport stream packet is 0-n1, then the sequence number of the slice file of the second transport stream packet is n. 1- n 2, the sequence number of the slice file of the third transport stream packet is n 2- n 3, and the sequence number of the fragment file of the Nth transport stream packet is n(N-1)- n(N), that is, the sequence number corresponding to the fragment file generated by the entire transport stream is 0-n.
  • the fragment files in each transport stream packet can also be separately numbered, and the serial number of the transport stream packet is combined to number the sequence number of each fragment file, for example, two fields are set, One field is the transport stream packet number where the sequence number is located, and the second field is the number of the fragment file in the transport stream packet.
  • the first field may be any one of “0000” to “FFFF” indicating the number of the transport stream packet, and the second field may be “000000” to “FFFFFF” indicating the sequence number of the fragment file in each transport stream packet.
  • the transport stream packet in which the fragment file is located can be quickly located, which facilitates fast data search.
  • the fragmentation information may include a fragmentation duration and a sequence number of the fragmentation file.
  • the sequence number of the fragmentation file may correspond to the sequence start value of the fragmentation file of each transport stream packet.
  • the starting and ending interval of the fragment file number in the fragmentation information is (m1, m2), and the index corresponding to each fragment file can be quickly generated according to the fragmentation duration and the fragment sequence number. And generating, according to the index, an index file corresponding to the fragment file of the transport stream during playback.
  • step S103 the fragmentation information is added to the header information corresponding to the transport stream packet.
  • the present invention in order to implement effective transmission of the fragmentation information, subtly extends the header information of the existing transport stream packet, that is, adds the fragmentation information to the packet header information corresponding to the transport stream packet. in.
  • the existing header information may include, for example, a plurality of mapping tables, including, for example, a program association table PAT, a conditional access table CAT, a program mapping table PMT, and a network information table NIT, where:
  • the PAT (Program Association Table) program association table PID (Packet The identification value is fixed 0x0000, its main role is to indicate the transport stream ID, and the MAP of the corresponding program stream in the transport stream.
  • the PID of the table and network information table is a program Association Table.
  • PMT Program Map Table
  • the program map, the PID of the table is given by the PAT.
  • information included in one program can be obtained, for example, which streams of the program are composed and the types of the streams (video, audio, data), the PID corresponding to each stream in the specified program, and the PCR corresponding to the program. PID.
  • NIT Network Information Table
  • the network information table the PID of the table is given by the PAT.
  • the role of NIT is mainly to identify the multi-path transport stream.
  • NIT provides information about the multi-path transport stream, physical network and network transmission, such as frequency information for tuning and encoding. Information on parameters such as modulation method.
  • the storage location reserved by the storage space of the current packet header can be determined.
  • the PID fixed value of the CAT conditional access table is 0X0001
  • the PID fixed value of the program association table PAT is 0X0000
  • the PID value of the program mapping table PMT determined by the program association table is 0X0003
  • the PID of the determined network information table NIT is determined.
  • the value is 0X0004, then the reserved storage space can be 0X0005-0X000F.
  • the storage location of the reserved storage space of the packet header in the transport stream packet can be determined by the packet identifier PID value of the mapping table.
  • the fragmentation information generated in step S102 can be written and stored according to the determined storage location of the storage space reserved in the packet header.
  • Each TS packet further includes fragmentation information of the fragmentation file, which can be used to establish an index of the fragmentation file, and play control on the fragmentation file through the index file, so that the present invention can pass the TS stream extended by the packet header.
  • fragmentation information of the fragmentation file which can be used to establish an index of the fragmentation file, and play control on the fragmentation file through the index file, so that the present invention can pass the TS stream extended by the packet header.
  • Embodiment 2 is a diagrammatic representation of Embodiment 1:
  • FIG. 2 is a flowchart showing the implementation of the method for playing the transport stream according to the second embodiment of the present invention.
  • the transport stream generated by the transport stream encoding method in the first embodiment is played, and the playback method of the transport stream is discussed in detail below:
  • step S201 in the transport stream packet in the transport stream, the header information included in the transport stream packet is obtained.
  • the mapping table required for transporting the stream packet is stored in a specified location in the packet header, and the packet header information can be normally performed by the transport stream player. Play.
  • the method before the step of acquiring the header information included in the transport stream packet and searching for the preset fragment information in the header information, the method further includes:
  • the packet data is controlled to be played according to the header information in the transport stream packet;
  • the step of acquiring the header information included in the transport stream packet and searching for the preset fragment information in the header information is performed.
  • the decoding method according to the present invention can be used to play in the player of different decoding modes by recognizing the encoded transport stream.
  • step S202 the fragmentation information preset in the header information is searched for.
  • the preset fragmentation information is stored in a reserved storage space in a header of the transport stream packet, and the specific location may be searched by using a PID value of a mapping table in the header information.
  • mapping tables including, for example, a program association table PAT, a conditional access table CAT, a program mapping table PMT, and a network information table NIT, where:
  • the PAT Program Association Table
  • PID Packet The identification value is a fixed value of 0x0000, which indicates the MAP table of the program stream corresponding to the transport stream and the PID of the network information table.
  • PMT Program Map Table
  • NIT Network Information Table
  • CAT Conditional Access Table
  • conditional access table whose PID value is fixed 0x0001.
  • the PID fixed value of the CAT conditional access table is 0X0001
  • the PID fixed value of the program association table PAT is 0X0000
  • the PID value of the program map PMT determined by the program association table is 0X0003
  • the PID of the determined network information table NIT is determined.
  • the value is 0X0004, then the reserved storage space can be 0X0005-0X000F.
  • step S203 the fragment file included in the transport stream packet and the index file corresponding to the fragment file are obtained according to the fragmentation information.
  • the fragmentation information includes a fragmentation duration and a sequence number of the fragment file, where the sequence number of the fragment file may be a fragment file corresponding to a single transport stream packet.
  • the starting number and ending number of the serial number Since the fragment file in the transport stream is continuously played, the sequence number of the fragment file is also continuous, and the number included in the current transport stream packet can be indicated by the start sequence number and the end sequence number of the sequence number of the fragment file.
  • the number of slice files For example, if the sequence number of the fragment file in the fragmentation information is [a-b], then the number of fragment files is b-a+1.
  • the step of acquiring the fragment file included in the transport stream packet and the index file corresponding to the fragment file according to the fragmentation information includes:
  • the sequence number corresponding to each slice file is obtained according to the order in which the packet data is cut.
  • the cutting is performed according to the sequence of the transport stream packets, and for each data stream in the transport stream packet, The cutting is performed according to the order of playing, that is, the fragment files are sequentially obtained according to the playing time, so that the serial number of the fragment file corresponds to the sequence of the playing time.
  • the slice file can be extracted to obtain a slice file package.
  • the size of each transport stream (the size of the transport stream is generally fixed), the storage location corresponding to each fragment may be determined, and the storage location and the playback sequence are generated according to the storage location An index file for controlling the playback of the slice file.
  • the packet size in the transport stream is different
  • the information can be simultaneously added to the header information of the transport stream packet.
  • the specific position of the data packet is cut during cutting, and the position of the sliced slice file is adjusted accordingly.
  • step S204 an HLS stream play file is generated according to the index file and the slice file.
  • the data packet in the transport stream packet is cut to obtain a fragment file, and the serial number of the fragment file is obtained by the size of the fragment file, so that the storage location of each fragment file is determined. .
  • An index file for controlling the playback of the slice file which is usually an m3u8 index file, can be generated by the correspondence between the sequence number of the slice file and the storage location.
  • the HLS stream play file is obtained from the slice file and the index file, and can be used for decoding and playing by a general HLS stream play method.
  • the embodiment of the present invention specifically describes a transport stream that extends the transport stream header information to enable playback of the transport stream player, and can also be played by the HLS stream player, thereby making the transport stream file play more. flexible.
  • Embodiment 3 is a diagrammatic representation of Embodiment 3
  • FIG. 3 is a schematic structural diagram of an apparatus for encoding a transport stream according to a third embodiment of the present invention, which is described in detail as follows:
  • the transport stream obtaining unit 301 is configured to obtain a transport stream to be encoded, where the transport stream to be encoded includes one or more transport stream packets, where the transport stream packet includes packet data and header information.
  • the cutting unit 302 is configured to cut the packet data according to a preset fragmentation duration to obtain a fragment file of the packet data and fragmentation information;
  • the information adding unit 303 is configured to add the fragmentation information to the header information corresponding to the transport stream packet.
  • the information adding unit includes:
  • a storage space determining subunit configured to determine, according to a preset storage location relationship between the packet header information and the storage space of the packet header, a storage space reserved by the packet header information in the transport stream packet;
  • the information writing subunit is configured to write the fragmentation information into the reserved storage space.
  • the cutting unit comprises:
  • a sequence number obtaining sub-unit configured to cut the packet data according to a preset fragmentation duration, to obtain a fragment file and a serial number corresponding to each fragment file;
  • the fragmentation information generating subunit is configured to obtain the fragmentation information according to the preset fragmentation duration and the sequence number corresponding to the fragmentation file.
  • the sequence number obtaining subunit includes:
  • a first numbering module configured to consecutively number the fragment files in different transport stream packets in the transport stream to be encoded, to obtain serial numbers of consecutive numbers of the transport stream to be encoded
  • the second numbering module is configured to separately number the fragment files in different transport stream packets in the transport stream to be encoded, to obtain a fragment file sequence number including the transport stream packet identifier information.
  • the encoding device of the transport stream in the embodiment of the present invention corresponds to the encoding method of the transport stream in the first embodiment, and details are not described herein again.
  • Embodiment 4 is a diagrammatic representation of Embodiment 4:
  • FIG. 4 is a schematic structural diagram of a playback apparatus for a transport stream according to a fourth embodiment of the present invention, which is described in detail as follows:
  • the header information obtaining unit 401 is configured to acquire, in the transport stream packet in the transport stream, the header information included in the transport stream packet.
  • the fragmentation information searching unit 402 is configured to search for the fragmentation information preset in the packet header information
  • a file obtaining unit 403 configured to acquire, according to the fragmentation information, a fragment file included in the transport stream packet and an index file corresponding to the fragment file;
  • the playing unit 404 is configured to generate an HLS stream play file according to the index file and the slice file.
  • the fragmentation information includes a fragmentation duration and a slice serial number
  • the file obtaining unit includes:
  • a fragmentation file obtaining subunit configured to cut the packet data in the transport stream packet according to the fragmentation duration, to obtain the sliced fragment file
  • the slice number acquisition subunit is configured to obtain a sequence number corresponding to each slice file according to an order of cutting the package data.
  • the playback device of the transport stream in the embodiment of the present invention corresponds to the playback method of the transport stream in the second embodiment, and details are not described herein.
  • 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)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明提供了一种传输流的编码、播放方法和装置,该方法包括获取待编码的传输流,所述待编码的传输流包括一个或多个传输流包,所述所传输流包中,包括包数据和以及包头信息;对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息;将所述分片信息添加至所述传输流包所对应的包头信息中。本发明所述传输流文件,既能够使用传输流播放器进行播放,也能够根据包头信息生成分片文件的索引文件,通过HLS播放器进行播放,提高了播放的灵活性。

Description

一种传输流编码、播放的方法和装置 技术领域
本发明属于多媒体传输领域,尤其涉及一种传输流编码、播放的方法和装置。
背景技术
传送流简称TS(英文全称为Transport Stream)流,是一种数字封装格式,用来打包基本音视频流和其他数据。可由一个或多个节目组成,每个节目由一个或多个原始流和一些其他流复合在一起,包括视频流、音频流、节目特殊信息流(PSI)和其他数据包。其中PSI表有4种类型:节目关联表(PAT)、节目映射表(PMT)、网络信息表和条件访问表。TS流的设计目的是允许数字视频和数字音频复用并同步输出并且,在有可能发生严重错误的情况下进行一道或多道程序编码数据的传送、电视节目的非线性编辑和存储等。
其中,TS流的形成过程为:音视频数据经过信源编码后,将其与辅助数据一起进行节目复用,形成基本流(英文简称为ES,英文全称为 Elementary Stream)。基本码流(ES)与包头(比如包括用于区别不同性质的ES的数据流识别码,PTS和PDS)经打包处理后形成打包的基本码流(英文简称为PES,英文全称为 Packetized Elementary Stream)。当播放所述TS流时,通过读取包头中的信息对所述基本码流进行播放。
在流媒体文件点播传输时,目前常用的流媒体协议包括苹果公司开发的HLS技术(英文全称为: HTTP Live Streaming )。在使用HLS技术进行视频点播时,首先需要对点播的内容进行准备,包括首对采集的视频进行编码,然后对编码后的视频进行流分割,将传输流分割成很多个 ts 的文件的分片。分割过程通常是按时间进行切割,比如分割为一个分片为10s时长,而如果码流高可以分割分片的时长为 5 秒。并生成含有指向这些小TS分片指针的索引文件(后缀为m3u8)。
由于目前的传输流与HLS文件的编码方式不同,因此使得目前的视频文件,如HLS文件,或者传输流文件,不同同时在所述传输流播放器和HLS播放器中播放,不利于提高播放的灵活性。
技术问题
本发明的目的在于提供一种传输流的编码、播放方法,以解决现有技术的视频文件,不同同时在所述传输流播放器和HLS播放器中播放,不利于提高播放的灵活性的问题。
技术解决方案
第一方面,本发明实施例提供了一种传输流的编码方法,所述方法包括:
获取待编码的传输流,所述待编码的传输流包括一个或多个传输流包,所述所传输流包中,包括包数据和以及包头信息;
对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息;
将所述分片信息添加至所述传输流包所对应的包头信息中。
结合第一方面,在第一方面的第一种可能实现方式中,所述将所述分片信息添加至所述传输流包所对应的包头信息步骤包括:
根据预设的包头信息与包头存储空间的存储位置关系,确定所述传输流包中的包头信息所保留的存储空间;
将所述分片信息写入所述保留的存储空间。
结合第一方面,在第一方面的第二种可能实现方式中,所述对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息步骤包括:
将所述包数据按照预设的分片时长进行切割,得到分片文件以及每个分片文件对应的序号;
根据所述预设的分片时长以及所述分片文件对应的序号得到所述分片信息。
结合第一方面的第二种可能实现方式,在第一方面的第三种可能实现方式中,所述将所述包数据按照预设的分片时长进行切割,得到分片文件以及每个分片文件对应的序号步骤包括:
对待编码的传输流中不同的传输流包中的分片文件进行连续编号,得到待编码的传输流的连续编号的序号;
或者,对待编码的传输流中不同的传输流包中的分片文件进行分开编号,得到包括传输流包标识信息的分片文件序号。
第二方面,本发明实施例提供了一种传输流的播放方法,所述方法包括:
在所述传输流中的传输流包中,获取所述传输流包中包括的包头信息;
查找所述包头信息中预设的分片信息;
根据所述分片信息,获取所述传输流包所包括的分片文件以及所述分片文件对应的索引文件;
根据所述索引文件以及所述分片文件生成HLS流播放文件。
结合第二方面,在第二方面的第一种可能实现方式中,在所述获取所述传输流包中包括的包头信息,查找所述包头信息中预设的分片信息步骤之前,所述方法还包括:
如果当前播放器为传输流播放器,则根据所述传输流包中的包头信息,控制所述包数据播放;
如果当前播放器为HLS播放器,则进入获取所述传输流包中包括的包头信息,查找所述包头信息中预设的分片信息步骤。
结合第二方面,在第二方面的第二种可能实现方式中,所述分片信息包括分片时长以及分片序号,所述根据所述分片信息,获取所述传输流包所包括的分片文件以及所述分片文件对应的索引文件步骤包括:
根据所述分片时长,对传输流包中的包数据进行切割,得到切割后的分片文件;
根据对所述包数据进行切割的顺序,得到每个分片文件对应的序号。
第三方面,本发明实施例提供了一种传输流编码装置,所述装置包括:
传输流获取单元,用于获取待编码的传输流,所述待编码的传输流包括一个或多个传输流包,所述所传输流包中,包括包数据和以及包头信息;
切割单元,用于对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息;
信息添加单元,用于将所述分片信息添加至所述传输流包所对应的包头信息中。
结合第三方面,在第三方面的第一种可能实现方式中,所述信息添加单元包括:
存储空间确定子单元,用于根据预设的包头信息与包头存储空间的存储位置关系,确定所述传输流包中的包头信息所保留的存储空间;
信息写入子单元,用于将所述分片信息写入所述保留的存储空间。
第四方面,本发明实施例提供了一种传输流播放装置,所述装置包括:
包头信息获取单元,用于在所述传输流中的传输流包中,获取所述传输流包中包括的包头信息;
分片信息查找单元,用于查找所述包头信息中预设的分片信息;
文件获取单元,用于根据所述分片信息,获取所述传输流包所包括的分片文件以及所述分片文件对应的索引文件;
播放单元,用于根据所述索引文件以及所述分片文件生成HLS流播放文件。
结合第四方面,在第四方面的第一种可能实现方式中,所述分片信息包括分片时长以及分片序号,所述文件获取单元包括:
分片文件获取子单元,用于根据所述分片时长,对传输流包中的包数据进行切割,得到切割后的分片文件;
分片序号获取子单元,用于根据对所述包数据进行切割的顺序,得到每个分片文件对应的序号。
有益效果
在本发明中,通过在现有的传输流数据格式的基础上,将传输流中的每个传输流包进行进一步切割操作,将传输流包中的包数据进行切割得到分片文件以及分片信息,将分片信息添加到传输流包中的包头信息中,在播放时既能够使用传输流播放器进行播放,也能够根据包头信息生成分片文件的索引文件,通过HLS播放器进行播放,提高了播放的灵活性。
附图说明
图1是本发明第一实施例提供的传输流的编码方法的实现流程图;
图2是本发明第二实施例提供的传输流的播放方法的实现流程图;
图3是本发明第三实施例提供的传输流的编码装置的结构示意图;
图4为本发明第四实施例提供的传输流的播放装置的结构示意图。
本发明的实施方式
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
本发明实施例的主要目的在于解决现有技术中使用较为广泛的传输流文件,以及使用越来越多的HLS文件不能同时播放的问题。比如在服务器中的视频源只包括其中一种格式时,或者不同的服务器中保存的视频源格式不同,则在客户端进行播放时,为了保证可播放视频文件,则需要安装两个播放器,这无疑会占用客户端的存储资源以及计算资源。同样,在服务器中为使得视频文件能够适应不同播放器的播放需要,则会对同一视频内容的视频文件,转化为不同格式分别进行存储,需要占用两倍,或者更多的存储资源。本发明正是根据现有技术中视频文件不能与各种播放器适应而提出的解决方案,下面结合附图具体说明。
实施例一:
图1示出了本发明第一实施例提供的传输流的编码方法的实现流程,详述如下:
在步骤S101中,获取待编码的传输流,所述待编码的传输流包括一个或多个传输流包,所述所传输流包中,包括包数据和以及包头信息。
具体的,本发明实施例中所述的传输流(Transport Stream),又可称为TS流,一个TS流一般包括多个传输流包,又叫TS包。
在每个TS包中,包括包头、自适应区和包数据3部分组成。每个包长度可以为固定的188字节,包头长度占4 字节,自适应区和包数据长度占184字节。184字节为有用信息空间,用于传送已编码的视音频数据流。当节目时钟基准(PCR-Program Clock Reference)存在时,包头还包括可变长度的自适应区,包头的长度就会大于4字节。考虑到与通信的关系,整个传输包固定长度应相当于4个ATM包。考虑到加密是按照8字节顺序加扰的,代表有用信息的自适应区和包数据的长度应该是8字节的整数倍,即自适应区和包数据为23×8字节=184字节。
TS包的包头包括同步字节、传输误码指示符、有效载荷单元起始指示符、传输优先、包识别(PID-Packet Identification)、传输加扰控制、自适应区控制和连续计数器8个部分组成。
其中,同步字节位,可通过其自动相关特性,检测数据流中的包限制,建立包同步;
传输误码指示符,用于当有不能消除误码时,采用误码校正解码器可表示1bit 的误码,但无法校正所述误码;
有效载荷单元起始指示符,表示该数据包是否存在确定的起始信息;
传输优先,可用于给TS包分配优先权;
PID值是由用户确定的,解码器根据PID将TS上从不同ES来的TS包区别出来,以重建原来的ES;
传输加扰控制,可指示数据包内容是否加扰,但包头和自适应区永远不加扰;
自适应区控制,用2 bit表示有否自适应区,即(01)表示有有用信息无自适应区,(10)表示无有用信息有自适应区,(11)表示有有用信息有自适应区,(00)无定义;
连续计数器可对PID包传送顺序计数,据计数器读数,接收端可判断是否有包丢失及包传送顺序错误。显然,包头对TS包具有同步、识别、检错及加密功能。
TS包自适应区由自适应区长、各种标志指示符、与插入标志有关的信息和填充数据4部分组成。其中标志部分由间断指示符、随机存取指示符、ES(Elementary Streams,原始流)优化指示符、PCR标志、接点标志、传输专用数据标志、原始PCR标志、自适应区扩展标志8个部分组成。
其中,所述待编码的传输流,可以为服务器中用于TS流,也可以为其它终端中保存的,或者生成的TS流。所述待编码的传输流与现有的传输流具有相同的编码规则,可通过普通的TS流播放器对其进行播放。
在步骤S102中,对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息。
具体的,所述对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息步骤包括:
将所述包数据按照预设的分片时长进行切割,得到分片文件以及每个分片文件对应的序号;
根据所述预设的分片时长以及所述分片文件对应的序号得到所述分片信息。
本发明实施例在现有的TS流基础上,进一步对其切割以及包头信息进行扩展,具体包括:
对TS包中的包数据进行切割:所述包数据,即在TS流中所包括的用于播放的源数据,包括视频源数据(经过编码后的)、音频源数据(经过编码后的)等,所述切割的方法中,根据预设的分片时长对所述视频源数据,或者所述音频源,按播放时间的先后进行切割,并且根据切割的先后,依次对切割后的分片文件进行编号,得到分片文件对应的序号。
所述预设的分片时长,可以根据码率的高低而相应的选用不同的时长值。比如可以设定不同的码率范围与时长的对应关系,通过检测待分割的流媒体文件,当码率在第一范围时,则对应第一时长,当码率在第二范围时,对应第二时长。其中,第一时长和第二时长,随着码率的增加而减小。即对于每个分片的文件大小进行控制。比如对于正常码率的流媒体文件,可以选用10s的预设时长进行分割 。
当流媒体时长为1.5小时,预设时长为10s,则可以将流媒体分割为540个分片。每个分片的格式为ts,通常在每个文件的后面添加“.ts”的后缀。
具体的,在本发明实施例中,所述分片文件的序号,可以对多个传输流包的分片文件的序号进行连续编号,从而使得传输流中的所有分片文件是连续的。比如,对于第一个传输流包的分片文件的序号区间为0-n1,那么第二个传输流包的分片文件的序号区间为n 1- n 2,第三个传输流包的分片文件的序号区间为n 2- n 3,第N个传输流包的分片文件的序号区间为n(N-1)- n(N),即整个传输流生成的分片文件对应的序号区间为0- n。
可以理解的是,也可以对每个传输流包中的分片文件单独进行编号,并组合传输流包的包号对每个分片文件的序号进行编号,比如,设定两个字段,第一个字段为序号所在的传输流包编号,第二个字段为分片文件在传输流包中的编号。比如第一字段可以为“0000”至“FFFF”中的任意一个表示传输流包的编号,第二字段可以为“000000”至“FFFFFF”表示每个传输流包中分片文件的序号,通过这种序号设置的方式,当其中的一个分片文件出错时,可以快速的定位所述分片文件所在的传输流包,有利于快速的进行数据查找。
在本明实施例中,所述分片信息可以包括分片时长以及分片文件的序号,具体的,对于分片文件的序号,可以对应为每个传输流包的分片文件的序号起止值,比如对于传输流包M,其分片信息中的分片文件序号的起止区间为(m1,m2),根据分片时长以及分片序号,则可以快速的生成每个分片文件对应的索引,根据索引生成所述传输流的分片文件播放时对应的索引文件。
在步骤S103中,将所述分片信息添加至所述传输流包所对应的包头信息中。
在本发明实施例中,为实现对分片信息进行有效的传输,本发明巧妙的对现有的传输流包的包头信息进行扩展,即将分片信息添加至所述传输流包对应的包头信息中。
现有的包头信息中,比如可以包括多个映射表,包括如节目关联表PAT、条件接收表CAT、节目映射表PMT和网络信息表NIT,其中:
所述PAT(Program Association Table)节目关联表,其PID(Packet identification)值是固定的0x0000,它的主要作用是指出该传输流ID,以及该路传输流中所对应的节目流的 MAP 表和网络信息表的PID。
PMT(Program Map Table),节目映射表,该表的PID是由PAT提供给出的。通过该表可以得到一路节目中包含的信息,例如,该路节目由哪些流构成和这些流的类型(视频,音频,数据),指定节目中各流对应的PID,以及该节目的PCR所对应的PID。
NIT(Network Information Table),网络信息表,该表的PID是由PAT提供给出的。NIT的作用主要是对多路传输流的识别,NIT提供多路传输流,物理网络及网络传输的相关的一些信息,如用于调谐的频率信息以及编码方式。调制方式等参数方面的信息。
CAT(Conditional Access Table),条件访问表,其PID值为固定的 0x0001。
因此,对于包头位置的存储空间中,当通过固定的PID值的节目关联表PAT获取节目映射表PMT以及网络信息NIT的PID值后,就可以确定当前包头的存储空间所保留的存储位置。
比如,CAT条件访问表的PID固定值为0X0001,节目关联表PAT的PID固定值为0X0000,通过所述节目关联表确定的节目映射表PMT的PID值为0X0003,确定的网络信息表NIT的PID值为0X0004,那么保留的存储空间可以为0X0005-0X000F。
也即,通过映射表的包标识符PID值可以确定传输流包中的包头所保留存储空间的存储位置。
根据确定的所述包头中保留的存储空间的存储位置,可将步骤S102中生成的分片信息进行写入存储。
由于分片信息存储在包头中的保留位置,因此,可以不影响TS流播放器对TS流文件的解析播放。每个TS包中又包括分片文件的分片信息,可以用于建立分片文件的索引,通过索引文件对分片文件进行播放控制,从而使得本发明经过对包头扩展后的TS流既能够适应TS流播放器播放的要求,又能够适应HLS流播放器的播放要求,大大的提高的播放的灵活性。
实施例二:
与实施例一所述传输流的编码方法对应的,图2示出了本发明第二实施例提供的传输流的播放方法的实现流程,通过本实施例中所述传输流的播放方法,可以实现对实施例一中所述传输流编码方法生成的传输流进行播放,下面对传输流的播放方法进行详细论述:
在步骤S201中,在所述传输流中的传输流包中,获取所述传输流包中包括的包头信息。
具体的,本发明实施例中所述的传输流包,在其包头信息中,传输流包所需要的映射表存储在包头中的指定位置,通过所述包头信息可以由传输流播放器进行正常的播放。
优选的一种实施方式中,本发明在所述获取所述传输流包中包括的包头信息,查找所述包头信息中预设的分片信息步骤之前,所述方法还包括:
如果当前播放器为传输流播放器,则根据所述传输流包中的包头信息,控制所述包数据进行播放;
如果当前播放器为HLS播放器,则进入获取所述传输流包中包括的包头信息,查找所述包头信息中预设的分片信息步骤。
即对于现有的对于不同类型的文件专门设置的播放器方式,可以通过本发明所述的解码方法,使得通过辨例一编码后的传输流,在不同解码方式的播放器中进行播放。
在步骤S202中,查找所述包头信息中预设的分片信息。
所述预设的分片信息,其存储位置位于传输流包的包头中的保留存储空间,具体位置可以通过包头信息中的映射表的PID值进行查找。
具体的,比如对于现有的包头信息中,比如可以包括多个映射表,包括如节目关联表PAT、条件接收表CAT、节目映射表PMT和网络信息表NIT,其中:
所述PAT(Program Association Table)节目关联表,其PID(Packet identification)值是固定的0x0000,可指出该路传输流中所对应的节目流的 MAP 表和网络信息表的PID。PMT(Program Map Table),节目映射表,该表的PID是由PAT提供给出的。NIT(Network Information Table),网络信息表,该表的PID是由PAT提供给出的。CAT(Conditional Access Table),条件访问表,其PID值为固定的 0x0001。
因此,CAT条件访问表的PID固定值为0X0001,节目关联表PAT的PID固定值为0X0000,通过所述节目关联表确定的节目映射表PMT的PID值为0X0003,确定的网络信息表NIT的PID值为0X0004,那么保留的存储空间可以为0X0005-0X000F。通过预设的存储分片信息的方式,比如在第一个空闲的PID位置存储,或者在最后的一个空闲的PID位置存储,那么,根据查找得到的包头中的保留空间,以及预设的位置设定方式,则可以快速的查找所述分片信息对应的包识别标识PID,通过所述PID得到分片信息。
在步骤S203中,根据所述分片信息,获取所述传输流包所包括的分片文件以及所述分片文件对应的索引文件。
作为本发明其中一种可选的实施方式,所述分片信息包括分片时长以及分片文件的序号,其中,所述分片文件的序号可以为单个传输流包所对应的分片文件的序号的起始序号与结束序号。由于传输流中的分片文件是连续播放的,因此,所述分片文件的序号也是连续的,通过分片文件的序号的起始序号和结束序号即可表明当前传输流包中包括的分片文件的个数。比如,分片信息中的分片文件的序号范围为[a-b],那么分片文件的个数即为即为b-a+1个。
所述根据所述分片信息,获取所述传输流包所包括的分片文件以及所述分片文件对应的索引文件步骤包括:
根据所述分片时长,对传输流包中的包数据进行切割,得到切割后的分片文件;
根据对所述包数据进行切割的顺序,得到每个分片文件对应的序号。
具体的,根据分片信息中的分片时长,对所述传输流包中的包数据进行切割步骤中,根据传输流包的先后顺序进行切割,并且对于每个传输流包中的数据流,按照播放的先后顺序进行切割,即根据播放时间的先后,依次得到分片文件,从而使得分片文件的序号与所述播放时间的先后相对应。
根据切割得到的分片文件,可以对分片文件进行提取,得到分片文件包。
根据所述分片时长,每个传输流的大小(传输流的大小一般是固定的),即可确定每个分片所对应的存储位置,根据所述存储位置以及播放的先后,生成所述用于控制所述分片文件进行播放的索引文件。
当然,对于特殊情况下,比如,传输流中的数据包大小不同,可以将该信息同时添加在所述传输流包的包头信息中。从而使得切割时查找数据包的具体位置进行切割,并且对切割后的分片文件的位置进行相应的调整。
在步骤S204中,根据所述索引文件以及所述分片文件生成HLS流播放文件。
根据分片信息,对所述传输流包中的数据包进行切割后得到分片文件,并且通过分片文件的大小得到分片文件的序号,从而使得每个分片文件的存储位置是确定的。
通过所述分片文件的序号与存储位置的对应关系,即可生成用于控制所述分片文件进行播放的索引文件,通常为m3u8索引文件。
由所述分片文件以及索引文件得到HLS流播放文件,可用于一般HLS流播放方法进行解码播放。
本发明实施例与实施例一相对应,具体描述了一种扩展了传输流包头信息的传输流可实现传输流播放器播放,也可以通过HLS流播放器播放,从而使得传输流文件的播放更加灵活。
实施例三:
图3示出了本发明第三实施例提供的传输流的编码装置的结构示意图,详述如下:
本发明实施例所述传输流的编码装置,包括:
传输流获取单元301,用于获取待编码的传输流,所述待编码的传输流包括一个或多个传输流包,所述所传输流包中,包括包数据和以及包头信息;
切割单元302,用于对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息;
信息添加单元303,用于将所述分片信息添加至所述传输流包所对应的包头信息中。
作为本发明一种优选的实施方式,所述信息添加单元包括:
存储空间确定子单元,用于根据预设的包头信息与包头存储空间的存储位置关系,确定所述传输流包中的包头信息所保留的存储空间;
信息写入子单元,用于将所述分片信息写入所述保留的存储空间。
优选的,所述切割单元包括:
序号获取子单元,用于将所述包数据按照预设的分片时长进行切割,得到分片文件以及每个分片文件对应的序号;
分片信息生成子单元,用于根据所述预设的分片时长以及所述分片文件对应的序号得到所述分片信息。
优选的,所述序号获取子单元包括:
第一编号模块,用于对待编码的传输流中不同的传输流包中的分片文件进行连续编号,得到待编码的传输流的连续编号的序号;
或者,第二编号模块,用于对待编码的传输流中不同的传输流包中的分片文件进行分开编号,得到包括传输流包标识信息的分片文件序号。
本发明实施例所述传输流的编码装置,与实施例一中所述的传输流的编码方法相对应,在此不作重复赘述。
实施例四:
图4示出了本发明第四实施例提供的传输流的播放装置的结构示意图,详述如下:
本发明实施例中所述的传输流的播放装置,包括:
包头信息获取单元401,用于在所述传输流中的传输流包中,获取所述传输流包中包括的包头信息;
分片信息查找单元402,用于查找所述包头信息中预设的分片信息;
文件获取单元403,用于根据所述分片信息,获取所述传输流包所包括的分片文件以及所述分片文件对应的索引文件;
播放单元404,用于根据所述索引文件以及所述分片文件生成HLS流播放文件。
优选的,所述分片信息包括分片时长以及分片序号,所述文件获取单元包括:
分片文件获取子单元,用于根据所述分片时长,对传输流包中的包数据进行切割,得到切割后的分片文件;
分片序号获取子单元,用于根据对所述包数据进行切割的顺序,得到每个分片文件对应的序号。
本发明实施例中所述传输流的播放装置与实施例二中所述传输流的播放方法对应,在此不作重复赘述。
在本发明所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。

Claims (11)

  1. 获取待编码的传输流,所述待编码的传输流包括一个或多个传输流包,所述所传输流包中,包括包数据和以及包头信息;
    对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息;
    将所述分片信息添加至所述传输流包所对应的包头信息中。
  2. 根据权利要求1所述方法,其特征在于,所述将所述分片信息添加至所述传输流包所对应的包头信息步骤包括:
    根据预设的包头信息与包头存储空间的存储位置关系,确定所述传输流包中的包头信息所保留的存储空间;
    将所述分片信息写入所述保留的存储空间。
  3. 根据权利要求1所述方法,其特征在于,所述对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息步骤包括:
    将所述包数据按照预设的分片时长进行切割,得到分片文件以及每个分片文件对应的序号;
    根据所述预设的分片时长以及所述分片文件对应的序号得到所述分片信息。
  4. 根据权利要求3所述方法,其特征在于,所述将所述包数据按照预设的分片时长进行切割,得到分片文件以及每个分片文件对应的序号步骤包括:
    对待编码的传输流中不同的传输流包中的分片文件进行连续编号,得到待编码的传输流的连续编号的序号;
    或者,对待编码的传输流中不同的传输流包中的分片文件进行分开编号,得到包括传输流包标识信息的分片文件序号。
  5. 一种传输流的播放方法,其特征在于,所述方法包括:
    在所述传输流中的传输流包中,获取所述传输流包中包括的包头信息;
    查找所述包头信息中预设的分片信息;
    根据所述分片信息,获取所述传输流包所包括的分片文件以及所述分片文件对应的索引文件;
    根据所述索引文件以及所述分片文件生成HLS流播放文件。
  6. 根据权利要求5所述方法,其特征在于,在所述获取所述传输流包中包括的包头信息,查找所述包头信息中预设的分片信息步骤之前,所述方法还包括:
    如果当前播放器为传输流播放器,则根据所述传输流包中的包头信息,控制所述包数据进行播放;
    如果当前播放器为HLS播放器,则进入获取所述传输流包中包括的包头信息,查找所述包头信息中预设的分片信息步骤。
  7. 根据权利要求5所述方法,其特征在于,所述分片信息包括分片时长以及分片序号,所述根据所述分片信息,获取所述传输流包所包括的分片文件以及所述分片文件对应的索引文件步骤包括:
    根据所述分片时长,对传输流包中的包数据进行切割,得到切割后的分片文件;
    根据对所述包数据进行切割的顺序,得到每个分片文件对应的序号。
  8. 一种传输流的编码装置,其特征在于,所述装置包括:
    传输流获取单元,用于获取待编码的传输流,所述待编码的传输流包括一个或多个传输流包,所述所传输流包中,包括包数据和以及包头信息;
    切割单元,用于对所述包数据按照预设的分片时长进行切割,得到所述包数据的分片文件以及分片信息;
    信息添加单元,用于将所述分片信息添加至所述传输流包所对应的包头信息中。
  9. 根据权利要求8所述装置,其特征在于,所述信息添加单元包括:
    存储空间确定子单元,用于根据预设的包头信息与包头存储空间的存储位置关系,确定所述传输流包中的包头信息所保留的存储空间;
    信息写入子单元,用于将所述分片信息写入所述保留的存储空间。
  10. 一种传输流的播放装置,其特征在于,所述装置包括:
    包头信息获取单元,用于在所述传输流中的传输流包中,获取所述传输流包中包括的包头信息;
    分片信息查找单元,用于查找所述包头信息中预设的分片信息;
    文件获取单元,用于根据所述分片信息,获取所述传输流包所包括的分片文件以及所述分片文件对应的索引文件;
    播放单元,用于根据所述索引文件以及所述分片文件生成HLS流播放文件。
  11. 根据权利要求10所述装置,其特征在于,所述分片信息包括分片时长以及分片序号,所述文件获取单元包括:
    分片文件获取子单元,用于根据所述分片时长,对传输流包中的包数据进行切割,得到切割后的分片文件;
    分片序号获取子单元,用于根据对所述包数据进行切割的顺序,得到每个分片文件对应的序号。
PCT/CN2015/088816 2015-09-02 2015-09-02 一种传输流编码、播放的方法和装置 WO2017035802A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/088816 WO2017035802A1 (zh) 2015-09-02 2015-09-02 一种传输流编码、播放的方法和装置

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/088816 WO2017035802A1 (zh) 2015-09-02 2015-09-02 一种传输流编码、播放的方法和装置

Publications (1)

Publication Number Publication Date
WO2017035802A1 true WO2017035802A1 (zh) 2017-03-09

Family

ID=58186462

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/088816 WO2017035802A1 (zh) 2015-09-02 2015-09-02 一种传输流编码、播放的方法和装置

Country Status (1)

Country Link
WO (1) WO2017035802A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117336311A (zh) * 2023-11-30 2024-01-02 深圳市小溪流科技有限公司 一种使多台hls服务器切片保持一致性的方法及其装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050238316A1 (en) * 2002-09-19 2005-10-27 Thomson Licensing S,A, Hybrid video on demand using mpeg2 transport
US20090271832A1 (en) * 2008-04-24 2009-10-29 Sung-Kwon Park Video On Demand Transmission/Reception Method and System Using Divided Transport System
CN102333083A (zh) * 2011-08-24 2012-01-25 中兴通讯股份有限公司 一种传输数据的方法和系统
CN103442259A (zh) * 2013-08-21 2013-12-11 杭州浦禾通信技术有限公司 媒体数据的重组方法和装置
CN103733631A (zh) * 2011-06-20 2014-04-16 Lg电子株式会社 媒体内容收发方法和使用该方法的收发设备
CN104022852A (zh) * 2014-06-25 2014-09-03 北京奇艺世纪科技有限公司 一种文件传输方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050238316A1 (en) * 2002-09-19 2005-10-27 Thomson Licensing S,A, Hybrid video on demand using mpeg2 transport
US20090271832A1 (en) * 2008-04-24 2009-10-29 Sung-Kwon Park Video On Demand Transmission/Reception Method and System Using Divided Transport System
CN103733631A (zh) * 2011-06-20 2014-04-16 Lg电子株式会社 媒体内容收发方法和使用该方法的收发设备
CN102333083A (zh) * 2011-08-24 2012-01-25 中兴通讯股份有限公司 一种传输数据的方法和系统
CN103442259A (zh) * 2013-08-21 2013-12-11 杭州浦禾通信技术有限公司 媒体数据的重组方法和装置
CN104022852A (zh) * 2014-06-25 2014-09-03 北京奇艺世纪科技有限公司 一种文件传输方法及装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117336311A (zh) * 2023-11-30 2024-01-02 深圳市小溪流科技有限公司 一种使多台hls服务器切片保持一致性的方法及其装置
CN117336311B (zh) * 2023-11-30 2024-03-12 深圳市小溪流科技有限公司 一种使多台hls服务器切片保持一致性的方法及其装置

Similar Documents

Publication Publication Date Title
WO2015034245A1 (en) Transmitting apparatus, receiving apparatus, and signal processing method thereof
WO2012077982A2 (ko) 멀티미디어 컨텐츠를 송수신하는 송신 장치 및 수신 장치와, 그 재생 방법
US8285106B2 (en) Information processing apparatus
WO2017035787A1 (zh) 一种流媒体文件的存储方法、装置和系统
WO2012011724A2 (ko) 미디어 파일 송수신 방법 및 그를 이용한 송수신 장치
WO2012099359A2 (ko) 복수의 실시간 전송 스트림을 수신하는 수신 장치와 그 송신 장치 및 멀티미디어 컨텐츠 재생 방법
WO2011059274A2 (en) Adaptive streaming method and apparatus
WO2015012565A1 (en) Transmitting apparatus, receiving apparatus and signal processing method thereof
EP1052850A2 (en) Digital signal recording/reproducing apparatus
WO2017035783A1 (zh) 流媒体的传输、播放方法及传输、播放装置
JP2001069106A (ja) ストリーム多重分離装置
WO2013154402A1 (en) Receiving apparatus for receiving a plurality of signals through different paths and method for processing signals thereof
WO2011159128A2 (en) Method and apparatus for providing digital broadcasting service with 3-dimensional subtitle
WO2016111560A1 (en) Transmitting apparatus and receiving apparatus and signal processing method thereof
WO2016111607A1 (en) Transmitting apparatus and signal processing method thereof
WO2014208988A1 (en) Transmitter, receiver, and control method thereof
WO2011129602A2 (ko) 3차원 영상 데이터를 부호화하는 방법 및 장치와 복호화 방법 및 장치
WO2012023787A2 (ko) 디지털 수신기 및 디지털 수신기에서의 컨텐트 처리 방법
EP2847953A1 (en) Apparatus and method of transmitting and receiving packet in a broadcasting and communication system
US20180302674A1 (en) File generating method and file generating apparatus
JP4282722B2 (ja) ストリーム記録装置
WO2015012553A1 (en) Transmitting apparatus and receiving apparatus, and signal processing method thereof
WO2017035802A1 (zh) 一种传输流编码、播放的方法和装置
WO2017035804A1 (zh) 一种传送流切片方法及装置
KR100842602B1 (ko) 재생장치, 재생방법, 기록장치, 기록방법, 출력장치 및 입력장치

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

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

Country of ref document: EP

Kind code of ref document: A1