Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein, only in order to explain the present invention, is not intended to limit the present invention.
As shown in Figure 1, provide in one embodiment a kind of method of displaying video Streaming Media, but the terminal that the present embodiment mainly is applied to the displaying video Streaming Media with the method illustrates.This terminal includes but not limited to smart mobile phone, panel computer, MP4(Moving Picture Experts Group Audio Layer IV, dynamic image expert compression standard audio frequency aspect 3) player, pocket computer on knee and desktop computer etc.The method comprises:
Step 102, obtain the video frame number of downloading in the first control cycle and the video frame number of having play, and the video frame number cushioned in video frame buffers after the first control cycle finishes.
First, second control cycle refers to two adjacent control cycles, and control cycle is preferably 1 second.
In the first control cycle, terminal is after receiving flow media data packet, determine the encapsulation format of flow media data packet according to the file header information of flow media data packet, thereby obtain frame of video according to corresponding encapsulation format resolution flow media data packet, and deposit in video frame buffers, the quantity of resolving the frame of video obtained is the video frame number of download.
Take out successively the frame of video in video frame buffers, calling corresponding video decode module decodes and obtains the data cell (such as the video data unit of yuv format) that can play-over, deposit decoding buffer zone in, the data cell of taking out successively in decoding buffer zone during broadcasting is play.The corresponding data unit of each frame of video, the quantity of the data cell of playing in the first control cycle is the video frame number of having play in the first control cycle.
After the first control cycle finishes, can obtain by detecting video frame buffers the video frame number of buffering.Can set up index for video frame buffers, in order to identify the frame of video cushioned in video frame buffers, thereby can obtain fast the video frame number cushioned in video frame buffers.
For convenience of explanation, in following statement except the special instruction, the video frame number of downloading refers to the video frame number that the first control cycle is downloaded, the video frame number of having play refers to the video frame number of having play in the first control cycle, and the video frame number of buffering refers to the video frame number that the first control cycle cushions in video frame buffers after finishing.
Step 104, according to the video frame number of download and the video frame number judgement network condition of having play, whether sufficient according to the frame of video of the video frame number of buffering and the video frame number play judgement buffering, and according to the frame of video of network condition and buffering whether the judged result of abundance calculate the video frame number to be played of the second control cycle.
The video frame number of downloading can accurately reflect network condition, the video frame number of downloading is less than the video frame number of having play, illustrate that network condition is not good, if continue, according to the frame per second of the frame number/control cycle of displaying video in the first control cycle, play, can cause consuming excessively of frame of video, may cause follow-up play to be interrupted, therefore need to adjust the video frame number to be played of the second control cycle.According to the frame of video of buffering sufficient judged result whether, can specifically determine video frame number to be played.Particularly, if the video frame number of buffering is greater than the video frame number of having play, the video frame buffer abundance is described, amplitude that can be less reduces the to be played video frame number of the value of the video frame number of having play as the second control cycle; On the contrary, if the video frame number of buffering is less than the video frame number of having play, the frame of video deficiency of buffering is described, amplitude that can be larger reduces the to be played video frame number of the value of the video frame number of having play as the second control cycle, thereby can reach the purpose of level and smooth displaying video Streaming Media
Step 106, at the second control cycle according to video frame number to be played the frame per second displaying video Streaming Media divided by control cycle.
At the second control cycle, take out successively data cell according to video frame number to be played divided by the frame per second of control cycle from decoding buffer zone and evenly play.
The method of above-mentioned displaying video Streaming Media, the first control cycle, the second control cycle are two adjacent control cycles, calculate the video frame number to be played of next control cycle after a upper control cycle finishes, go round and begin again, broadcasting is periodically controlled.Illustrate, if control cycle is 1 second, when video stream media plays the 50th second, calculate the video frame number of downloading in the 50th second and the video frame number of having play, thereby calculate the video frame number to be played of the 51st second, thereby at the 51st second Streaming Media of the frame per second displaying video according to video frame number to be played/1; After playing the 51st second, then calculate the video frame number to be played of 52 seconds, by that analogy, go round and begin again, until play this video stream media.
Accurately weigh network condition according to the video frame number of downloading in the first control cycle and the video frame number play, can reflect exactly in the first control cycle whether network fluctuates, thereby can be according to the frame of video of network condition and buffering whether sufficiently calculate the video frame number to be played that the second control cycle will be play.When fluctuation appears in network, whether sufficient judged result is adjusted the second control cycle video frame number to be played to the frame of video of binding buffer, thereby can reach the purpose of level and smooth displaying video Streaming Media, avoid owing to occurring can only interrupting situation about playing after network fluctuation causes ruing out of prematurely the frame of video that can play.
As shown in Figure 2, in one embodiment, step 104 comprises:
Step 202, whether the video frame number that judgement is downloaded is less than the video frame number play and the default product that is less than 1 positive coefficient, if perform step 204, performs step 210 if not.
The video frame number of downloading can be weighed the network condition in the first control cycle, thereby provides reference for the video frame number to be played of determining the second control cycle.The value that is less than 1 positive coefficient that should be default is preferably 0.5.If the video frame number of downloading, lower than the video frame number of having play and the product of this coefficient, illustrates the non-constant of network condition, the video frame number to be played that the second control cycle should be set is a less value.
Step 204, whether the video frame number of judgement buffering is greater than the video frame number of having play, if perform step 206, performs step 208 if not.
Whether the video frame number cushioned by judgement is greater than the video frame number of having play, and can judge that whether the frame of video cushioned in video frame buffers is sufficient, if the video frame number of buffering is greater than the video frame number of having play, the frame of video abundance of buffering is described; If the video frame number of buffering is less than the video frame number of having play, the frame of video deficiency of buffering is described.
Step 206, calculate video frame number to be played according to the video frame number of downloading and the video frame number of having play.
Now, the non-constant of network condition, but the frame of video abundance of buffering, the main impact of considering the video frame number of downloading and the video frame number of having play.Concrete, video frame number to be played can be the weighted average of the video frame number of downloading and the video frame number of having play, the mean value of the video frame number of especially downloading and the video frame number of having play.To the consuming excessively of the frame of video of buffering, can maintain again the smoothness of picture when getting weighted average and both can prevent from playing as far as possible.
Step 208, calculate video frame number to be played according to the video frame number of buffering and the video frame number of download.
Now, the non-constant of network condition, and the frame of video of buffering is also not enough, should reduce as much as possible video frame number to be played, can calculate video frame number to be played according to the video frame number of buffering and the video frame number of download.Particularly, less value in the video frame number that video frame number to be played is buffering and the video frame number of download.
Step 210, whether the video frame number that judgement is downloaded is less than the video frame number of having play, if perform step 212, performs step 218 if not.
Now, the video frame number of download is not less than the video frame number play and the default product that is less than 1 positive coefficient, illustrates that network is not non-constant, can further judge that current network is poor or normal.If the video frame number of downloading is less than the video frame number of having play, illustrate that network is poor; If the video frame number of downloading is not less than the video frame number of having play, illustrate that network is normal, meet the demand of normal play video Streaming Media.
Step 212, whether the video frame number of judgement buffering is greater than the video frame number of having play, if perform step 214, performs step 216 if not.
Now, network is poor, can further judge that whether the frame of video of buffering is sufficient.If the video frame number of buffering is greater than the video frame number of having play, the frame of video abundance of buffering is described; If the video frame number of buffering is not more than the video frame number of having play, the frame of video deficiency of buffering is described.
Step 214, calculate video frame number to be played according to video frame number, the video frame number of buffering and the video frame number of having play downloaded.
Now, although network is poor, in video frame buffers, buffering is sufficient, can consider the video frame number of download, the video frame number of buffering and the freely impact of displaying video Streaming Media of video frame number convection current of having play.Particularly, the weighted average of the video frame number that video frame number to be played is the video frame number downloaded, buffering and the video frame number of having play, the mean value of the video frame number of especially downloading, the video frame number of buffering and the video frame number play.
Step 216, calculate video frame number to be played according to the video frame number of buffering and the video frame number of download.
Now, network is poor, and the frame of video deficiency of buffering, should reduce as much as possible video frame number to be played, can calculate video frame number to be played according to the video frame number of buffering and the video frame number of download.Particularly, less value in the video frame number that video frame number to be played is buffering and the video frame number of download.
Step 218, whether the video frame number of judgement buffering is greater than the video frame number of having play, if perform step 220, performs step 222 if not.
Now, the video frame number of download is not less than the video frame number of having play, and illustrates that network is normal, can further according to video frame buffers, whether abundance is determined video frame number to be played.
Step 220, video frame number to be played is acquiescence video playback frame number.
Now, network is normal, and the video frame buffers abundance, and video frame number to be played is acquiescence video playback frame number.Can obtain by the file header of reading flow media data packet the acquiescence video playback frame number of video stream media.Generally, the video playback frame per second is 25 frames/second, and therefore giving tacit consent to the video playback frame number can be the 25* control cycle.
Step 222, video frame number to be played is the video frame number of buffering.
Now, although network is normal, but video frame buffer deficiency, in order to guarantee the level and smooth of video playback, the video frame number of video frame number to be played for buffering is set, subsequent control is in the cycle again, when network condition normal, and the frame of video of buffering when sufficient again video frame number to be played be set to give tacit consent to the video playback frame number.
In the present embodiment, the magnitude relationship judgement network condition of the video frame number by the video frame number downloaded and broadcasting, again in conjunction with the whether sufficient video frame number to be played that calculates the second control cycle of video frame buffers, reach the purpose of displaying video Streaming Media smoothly, make terminal in the situation that network appearance fluctuation still can smoothly be play, compatible strong.
As shown in Figure 3, in one embodiment, step 104 specifically comprises:
Step 302, whether the video frame number of judgement buffering is greater than the video frame number of having play, and performs step 304 if not, if perform step 306.
Whether the video frame number cushioned by judgement is greater than the video frame number of having play, and can judge that whether the frame of video of buffering is sufficient.If the video frame number of buffering is greater than the video frame number of having play, the frame of video deficiency of buffering is described, should be according to the video frame number of downloading and the video frame number of having play judgement network condition, and calculate video frame number to be played according to network condition, concrete, judge network condition according to the video frame number of downloading and the video frame number play, and calculate video frame number to be played according to network condition and comprise the following steps 306-314.On the contrary, if the video frame number of buffering is not more than the video frame number of having play, the frame of video abundance of buffering is described, performs step 304.
Step 304, calculate video frame number to be played according to the video frame number of buffering and the video frame number of download.
Now, the frame of video deficiency of buffering, should reduce video frame number to be played as much as possible, can calculate video frame number to be played according to the video frame number of buffering and the video frame number of download.Particularly, less value in the video frame number that video frame number to be played is buffering and the video frame number of download.
Step 306, whether the video frame number that judgement is downloaded is less than the video frame number play and the default product that is less than 1 positive coefficient, if perform step 308, performs step 310 if not.
The size of the video frame number of relatively downloading and the video frame number of having play and the product that is less than 1 positive coefficient of presetting, can judge the whether non-constant of network.The value of this coefficient is preferably 0.5.
Step 308, calculate video frame number to be played according to the video frame number of downloading and the video frame number of having play.
Now, the non-constant of network condition, but the frame of video abundance of buffering, the main impact of considering the video frame number of downloading and the video frame number of having play.Concrete, video frame number to be played can be the weighted average of the video frame number of downloading and the video frame number of having play, the mean value of the video frame number of especially downloading and the video frame number of having play.To the consuming excessively of the frame of video of buffering, can maintain again the smoothness of picture when getting weighted average and both can prevent from playing as far as possible.
Step 310, whether the video frame number that judgement is downloaded is less than the video frame number of having play.
Size by the video frame number of relatively downloading and the video frame number of having play, can judge that whether network condition is poor.
Step 312, calculate video frame number to be played according to video frame number, the video frame number of buffering and the video frame number of having play downloaded.
Now, although network is poor, in video frame buffers, buffering is sufficient, can consider the video frame number of download, the video frame number of buffering and the freely impact of displaying video Streaming Media of video frame number convection current of having play.Particularly, the weighted average of the video frame number that video frame number to be played is the video frame number downloaded, buffering and the video frame number of having play, the mean value of the video frame number of especially downloading, the video frame number of buffering and the video frame number play.
Step 314, video frame number to be played is acquiescence video playback frame number.
Now, network is normal, and the video frame buffers abundance, and video frame number to be played is acquiescence video playback frame number.Can obtain by the file header of reading flow media data packet the acquiescence video playback frame number of video stream media.Generally, the video playback frame per second is 25 frames/second, and therefore giving tacit consent to the video playback frame number can be the 25* control cycle.
As shown in Figure 4, provide in one embodiment a kind of device of displaying video Streaming Media, having comprised:
Frame number acquisition module 402, for obtain the video frame number of downloading and the video frame number of having play in the first control cycle, and the video frame number cushioned in video frame buffers after the first control cycle finishes.
Video frame number computing module 404 to be played, be used for according to the video frame number of download and the video frame number judgement network condition of having play, whether sufficient according to the frame of video of the video frame number of buffering and the video frame number play judgement buffering, and according to the frame of video of network condition and buffering whether the judged result of abundance calculate the video frame number to be played of the second control cycle.
Playing module 406, at the second control cycle according to video frame number to be played the frame per second displaying video Streaming Media divided by control cycle.
As shown in Figure 5, in one embodiment, video frame number computing module 404 to be played comprises:
Whether the first judge module 404a, be less than the video frame number play and the default product that is less than 1 positive coefficient for the video frame number that judges download, if whether the video frame number of judgement buffering is greater than the video frame number of having play.
The first computing module 404b, if be greater than for the video frame number of buffering the video frame number of having play, calculate video frame number to be played according to the video frame number of downloading and the video frame number of having play; If the video frame number of buffering is not more than the video frame number of having play, according to the video frame number of buffering and the video frame number of download, calculate video frame number to be played.
In one embodiment, if the first judge module 404a also is not less than the video frame number play and the product of coefficient for the video frame number of downloading, whether the video frame number that judgement is downloaded is less than the video frame number of having play, if the video frame number of downloading is less than the video frame number of having play, whether the video frame number of judgement buffering is greater than the video frame number of having play.
If the first computing module 404b also is greater than for the video frame number of buffering the video frame number of having play, according to video frame number, the video frame number of buffering and the video frame number of having play downloaded, calculate video frame number to be played; If the video frame number of buffering is not more than the video frame number of having play, according to the video frame number of buffering and the video frame number of download, calculate video frame number to be played.
In one embodiment, if the first judge module 404a also is not less than for the video frame number of downloading the video frame number of having play, whether the video frame number of judgement buffering is greater than the video frame number of having play.
If the first computing module 404b also is greater than for the video frame number of buffering the video frame number of having play, video frame number to be played is acquiescence video playback frame number; If the video frame number of buffering is not more than the video frame number of having play, video frame number to be played is the video frame number of buffering.
As shown in Figure 6, in one embodiment, video frame number computing module 404 to be played comprises:
Whether the second judge module 404c, be greater than the video frame number of having play for the video frame number that judges buffering, if according to the video frame number of download and the video frame number judgement network condition of having play.
The second computing module 404d, if be not more than for the video frame number of buffering the video frame number of having play, calculate video frame number to be played according to the video frame number of buffering and the video frame number of download; If the video frame number of buffering is greater than the video frame number of having play, according to network condition, calculate video frame number to be played.
The above embodiment has only expressed several execution mode of the present invention, and it describes comparatively concrete and detailed, but can not therefore be interpreted as the restriction to the scope of the claims of the present invention.It should be pointed out that for the person of ordinary skill of the art, without departing from the inventive concept of the premise, can also make some distortion and improvement, these all belong to protection scope of the present invention.Therefore, the protection range of patent of the present invention should be as the criterion with claims.