Embodiment
Below with reference to accompanying drawing and combine embodiment, specify the present invention.
Hereinafter will and combine embodiment to specify the present invention with reference to accompanying drawing.Need to prove that under the situation of not conflicting, embodiment and the characteristic among the embodiment among the application can make up each other.
Embodiment one
Fig. 2 is the flow chart according to the TS handling file play of the embodiment of the invention, and is as shown in Figure 2, and this method mainly may further comprise the steps:
Step S202, client receives the order of trick-play TS file, and wherein, said trick-play comprises: fast-forward play or fast reverse play;
In embodiments of the present invention, the TS file is meant the audio-video frequency content file, and its form is the TS form.
For example, client can be obtained the index information of this TS file earlier when needs are play this TS file; Can also obtain the MPD information of this TS file, wherein, index information and MPD message file can be in same files; Also can be arranged in different files; And,, can TS description information of files (comprising key frame index information and/or MPD information) be deposited in another file in order not change the form of original TS file.In embodiments of the present invention, the file of the index information of record TS file is called the index file of TS file.Preferably, in order to accelerate toggle speed, client can be carried out the player initialization according to the initialization information in the index information after obtaining index information.When client inserted the TS file, the user possibly carry out F.F. or fast reverse play, sent F.F. or fast reverse play order to client.
Wherein, the index information of TS file can be kept in the server with the TS file, and this index information can include but not limited to one of following or its combination in any:
(1) access point at random of TS file (Random Access Point abbreviates RAP as) and/or key frame information; Comprise the initial sum deviation post of each frame at the TS file, and the information such as fragment sequence number of the segmental file under this frame.
(2) during this TS file of client terminal playing, the audio frequency and video initialization information that player is required;
(3) media play zero-time of this TS file etc.
And MPD information is used to describe the audio/video program information of TS file, comprises the URL of media file and the information such as Fragment Offset of each segmentation.
Wherein, RAP comprises IDR frame, ODR frame and GDR frame, and wherein, IDR frame and ODR frame belong to key frame.
Step S204, client is according to the parameter of current reproduction time and said order, and the index information of TS file location RAP or key frame to be play;
In practical application, when carrying out F.F. or fast reverse play, can be with the key frame broadcast of jumping, also can be with the broadcast of jumping of RAP frame, its implementation is similar.
Wherein, the parameter of said order includes but not limited to the multiple of F.F. or rewind down, and for example, the F.F. multiple can be 2, and indication is whenever play at a distance from a key frame, and when the fast forwarding and fast rewinding multiple was 4, indication was whenever play at a distance from three key frames.
For example; Can write down in the index information with segment information, each segmentation one to one of TS file in the timestamp of each frame; Client can be located the fragment sequence number at the frame place of current broadcast, according to the multiple of F.F. or rewind down according to current play time; Can confirm the fragment sequence number of the segmentation at RAP that the next one is to be play or key frame place; Client compares the timestamp and the current play time of each frame in this segmentation then, thus obtain and current play time between difference satisfy the RAP or the key frame of F.F. or rewind down multiple, this RAP or key frame next frame for playing.
For example, recording indexes information index file can be divided into head (head) and two parts of main body (body), and wherein, the Head part mainly comprises but is not limited to following field:
The size (taking byte number) of HSize:Head part
Tduration: total duration of the corresponding media file of index file (unit is a millisecond)
Codec: audio frequency and video initialization information and PAT, PMT information
And the Body part is made up of continuous one by one index segmentation equally, and is corresponding one by one in (on time and the space) on time sequencing and the positional alignment with the segmentation of media data file.The data structure of each index segmentation is identical, is example with the I frame, can include but not limited to: FSize, Fduration, Poffset and a plurality of I Frame Index.Wherein, each I Frame Index comprises ItimeStamp, IOffSet, ISize field.Each explanation of field is as shown in table 1.
Table 1.
Wherein, I Frame IndexEntry definition is as shown in table 2.
Table 2.
Wherein, the index file form of I frame can adopt form as shown in Figure 3.
Perhaps, also can directly write down the timestamp of each frame of TS file in the index file, client compares through the timestamp with current play time and each frame, the next RAP or the key frame of positioning playing.
In practical application, for reduce index file size, its store data is a binary mode, perhaps, also can adopt other forms such as XML.
Step S206, said RAP of user end to server request or key frame;
Client can be obtained the place segmentation of said RAP or key frame from index file a TS wraps in the deviation post in the TS file, said RAP or the key frame size at deviation post and the said RAP or the key frame of this segmentation; Then these information are formed URL, send a request message to server.
Step S208, said RAP or key frame are downloaded and play to client from said server.
The said method that provides through the embodiment of the invention; When carrying out F.F. or fast reverse play; Can only need the RAP or the key frame of broadcast, thereby avoid downloading unwanted information, save network traffics from the server download; Reduce the stand-by period in user's playing process, improved user experience.
And, in embodiments of the present invention, can also in a preferred implementation of the embodiment of the invention, can also may further comprise the steps from F.F. or fast reverse play mode switch to the ordinary playing pattern:
Step 1, client receive the order of the said TS file of normal play;
Whether the frame thatstep 2, client are judged current broadcast is access point at random, if not, then continue to carry out said trick-play, be access point at random until the frame of current broadcast;
Step 3, client are confirmed the segmentation of the said TS file on the corresponding said server of this key frame according to the information of the frame of current broadcast;
Step 4, client is sent download request according to the segment information of said segmentation to said server, downloads said segmentation from said server;
For example, the fragment sequence number of the segmentation that client can be confirmed through step 3 is found the side-play amount and the size of this segmentation in the MPD information, sends download request as condition to server with this then.
Step 5, client is confirmed the deviation post of this frame in said segmentation according to the information of the frame of current broadcast, and begins to play from this deviation post;
Step 6, the client progressive download is also play the segmental file of said TS file.
In this preferred implementation, only when the frame of current broadcast is RAP, just switch to normal play mode, thereby make switching level and smooth, improved user experience.
In addition, in embodiments of the present invention, can also in a preferred implementation of the embodiment of the invention, can also may further comprise the steps from F.F. or fast reverse play mode switch to the positioning playing pattern:
Step 1, client receive the positioning playing request, wherein, carry the start time point that needs positioning playing in the said positioning playing request;
Step 2, client are confirmed the fragment sequence number of the segmentation at and key frame that be RAP place nearest from said start time point, and this key frame is with respect to the side-play amount (being assumed to be P) of this segmentation;
Step 3, client is sent download request according to the segment information of said segmentation to said server, downloads segmental file from said server;
For example, the fragment sequence number of the segmentation that client can be confirmed throughstep 2 is found the side-play amount and the size of this segmentation in the MPD information, sends download request as condition to server with this then.
Step 4, client begins to play from the indicated position of side-play amount P of the said segmental file of download;
Step 5, the client progressive download is also play the segmental file of said TS file.
Through this preferred implementation, can be level and smooth switch to station-keeping mode, improved user's experience.
Embodiment two
In embodiments of the present invention, index file adopts the form shown in table 1 and table 2.
Fig. 4 is the flow chart according to the broadcast of the TS file of the embodiment of the invention two, and is as shown in Figure 4, mainly may further comprise the steps:
Step 401, client are obtained the index file and the MPD of TS file, and according to the content initialization player of the Head partial C odec field of key frame index file;
Step 402 judges whether to carry out fast or fast reverse play pattern, if, execution in step 403, otherwise, execution in step 407;
Step 403, client find down first-class source of media position and the side-play amount of I frame on server of playing according to current playing time and F.F. or rewind down multiple;
At first; Client can find corresponding fragment sequence number according to current playing time in MPD, because the segment information of index file is corresponding one by one with media file; Promptly with MPD in segmentation corresponding one by one; Therefore can navigate to the segmentation of corresponding key frame index immediately, in the present embodiment, the fragment number of supposing this segmentation is m.
Client is obtained the value of Fsize field in the segmentation of each index file successively as the byte number of skipping, up to finding m index segmentation.Again according to the current playing time point, compare with the ITimeStamp of each key frame in this key frame index segmentation, find qualified key frame to download.In the present embodiment, suppose that the key frame that needs to download is n in m segmentation of key frame index, then its deviation post is: (POffset of m segmentation)+(IOffSet of n key frame of this segmentation); The size of this key frame is ISize;
Step 404, client generates HTTP URL according to the deviation post and the side-play amount (being the size of key frame) of next one key frame to be play, and sends the download request of I frame information to server;
Step 405 is play the I frame of having downloaded;
Step 406 in F.F. or fast reverse play process, judges whether to receive the request of ending F.F. or backward mode; If; Then execution in step 407, if also do not receive the request of ending F.F. or backward mode until fast-forward play arrival end-of-file or fast reverse play to file header, then finish;
Step 407 according to the order that receives, gets into played in order or positioning playing isotype;
Step 408 in the playing process of played in order or positioning playing isotype, judges whether to switch to F.F. or backward mode, if, then return execution in step 403, otherwise, after being played to end-of-file, finish.
Embodiment three
Present embodiment describes the flow process from F.F. or fast reverse play mode switch to the played in order pattern in the foregoing description two, and promptly above-mentioned steps 407, and is as shown in Figure 5, mainly may further comprise the steps to the played in order pattern from F.F. or fast reverse play mode switch:
Step 501, client receive the order that gets into normal play mode;
Step 502 judges according to the IsRAP field information of index file whether the key frame of current broadcast is RAP, if be not RAP, continues to do trick mode play, up to the key frame that finds to RAP;
Step 503, the position of and partitioning data corresponding with this key frame according to the fragment sequence number at the key frame place of the RAP of current broadcast is searched the position and the side-play amount of corresponding media file segment data in the MPD;
Step 504 generates URL according to segment information, sends download request to server;
Step 505 is downloaded this segmentation, and according to the deviation post of current key frame at the partitioning of having downloaded, confirms the original position and the broadcast of normal play.
Embodiment four
Present embodiment describes the flow process from F.F. or fast reverse play mode switch to the timing play mode in the foregoing description two, and promptly above-mentioned steps 407, and is as shown in Figure 6, mainly may further comprise the steps to the positioning playing pattern from F.F. or fast reverse play mode switch:
Step 601, client receive the positioning playing request;
Step 602; Client finds the fragment number at and key frame place that be RAP nearest from this time, because the segment information of index file is corresponding one by one with media file according to the time of request positioning playing in the indexed file; Promptly with MPD in segmentation corresponding one by one; Therefore can locate corresponding fragment sequence number among the MPD immediately, write down the side-play amount of this key frame simultaneously, be assumed to be p with respect to this segmentation;
Step 603, client is sent download request according to segment information;
Step 604, client is determined segmental file from server download step 602;
Step 605, client begins to play this segmentation from the side-play amount p of the segmental file that downloads to;
Step 606, progressive download is also play other segmental file.
Embodiment five
Fig. 7 is that this device can be used as the client in the said method according to the playback process device of the TS file of the embodiment of the invention.As shown in Figure 7, this device mainly comprises:receiver module 10, locatingmodule 20,first download module 30 and playing module 40.Wherein,receiver module 10 is used to receive the order of trick-play TS file, and wherein, said trick-play comprises: fast-forward play or fast reverse play; Locatingmodule 20 is used for the parameter according to current reproduction time and said order, from the index information of said TS file, obtains said TS file the to be play position of access point or key frame at random;First download module 30 is used for the content frame to the said position of server requests, and downloads the content frame of said position from said server; Playingmodule 40 is used to play the said content frame thatfirst download module 30 is downloaded.
The said apparatus that provides through the embodiment of the invention; When carrying out F.F. or fast reverse play; Can only need the RAP or the key frame of broadcast, thereby avoid downloading unwanted information, save network traffics from the server download; Reduce the stand-by period in user's playing process, improved user experience.
In a preferred implementation of the embodiment of the invention, device also comprise can: acquisition module is used to obtain the said index information of said TS file.In addition, this acquisition module can also be used to obtain the MPD information of above-mentioned TS file.
In a preferred implementation of the embodiment of the invention, locatingmodule 20 comprises: first confirms submodule, is used for according to said current reproduction time, confirms first fragment sequence number that current broadcast frame is corresponding; Second confirms submodule, is used for the parameter according to said first fragment sequence number and said order, confirms second fragment sequence number at said RAP or key frame place; Obtain submodule; Be used for each frame time corresponding of the segmentation corresponding with said second fragment sequence number of said index information record is stabbed and said current reproduction time compares, obtain and said current reproduction time between difference satisfy the said RAP or the key frame of the parameter of said order.
In another execution mode of the embodiment of the invention,receiver module 10 also is used to receive the order of the said TS file of normal play; Said device can also comprise: detection module, determination module and second download module; Wherein, Said detection module, whether the frame that is used to detect current broadcast is random access point, if not; Then continue to trigger said locating module next RAP or the key frame of playing positioned, trigger said determination module during for RAP until the frame of current broadcast; Said determination module is used for confirming according to the information of the frame of current broadcast the segmentation of the said TS file on the corresponding said server of this frame; Download module is used for sending download request according to the segment information of the definite said segmentation of said determination module to said server, downloads said segmentation from said server; Then said playing module also is used for confirming the deviation post of this frame in said segmentation according to the information of the frame of current broadcast; And begin to play the said segmentation that said second download module is downloaded from this deviation post, trigger the subsequent segment file of the said TS file of the said second download module progressive download then.
In addition, in another execution mode of this embodiment,receiver module 10 also is used to receive the positioning playing request, wherein, carries the start time point that needs positioning playing in this positioning playing request; Then said device can also comprise: search module, be used for searching at said index information the fragment sequence number of the segmentation at and key frame place that be at random access point nearest from said start time point, and this key frame is with respect to the side-play amount of this segmentation; The 3rd download module is used for sending download request according to the fragment sequence number of said segmentation to said server, downloads the segmentation at and key frame that be at random access point place nearest from said start time point from said server; Playingmodule 40 also is used for beginning to play from the position of the said side-play amount indication of the segmentation of downloading; And triggering other segmental files of the said TS file of the 3rd download module progressive download, playingmodule 40 is play the follow-up segmental file of the said TS file that the 3rd download module downloads in order.
From above description, can find out, in embodiments of the present invention; Need not the whole segmentation of file in download for the fast forwarding and fast rewinding operation of the TS file under the Http Streaming scene; And key frame that need to play of download had only both been saved network traffics, reduced the stand-by period in user's playing process again; Simultaneously do not influence taking over seamlessly between the various special-effect modes yet, improved user's experience.
Obviously; It is apparent to those skilled in the art that above-mentioned each module of the present invention or each step can realize that they can concentrate on the single calculation element with the general calculation device; Perhaps be distributed on the network that a plurality of calculation element forms; Alternatively, they can be realized with the executable program code of calculation element, carried out by calculation element thereby can they be stored in the storage device; Perhaps they are made into each integrated circuit modules respectively, perhaps a plurality of modules in them or step are made into the single integrated circuit module and realize.Like this, the present invention is not restricted to any specific hardware and software combination.
The above is merely the preferred embodiments of the present invention, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.All within spirit of the present invention and principle, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.