Embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, it is right below in conjunction with drawings and Examples
The present invention is further elaborated.It should be appreciated that specific embodiment described herein is only to explain the present invention, not
For limiting the present invention.
As shown in figure 1, in one embodiment provide it is a kind of play video stream media method, the present embodiment mainly with
The terminal that this method is applied to can play video stream media is illustrated.The terminal includes but is not limited to smart mobile phone, flat board electricity
Brain, MP4(Moving Picture Experts Group Audio Layer IV, dynamic image expert's compression standard audio layer
Face 3)Player, pocket computer on knee and desktop computer etc..This method includes:
Step 102, the video frame number downloaded in the first controlling cycle and the video frame number played are obtained, and the
The video frame number buffered after one controlling cycle terminates in video frame buffers.
First, second controlling cycle refers to two adjacent controlling cycles, and controlling cycle is preferably 1 second.
In the first controlling cycle, terminal is after flow media data packet is received, according to the file header of flow media data packet
Information determines the encapsulation format of flow media data packet, so as to obtain video according to corresponding encapsulation format parsing flow media data packet
Frame, and be stored in video frame buffers, the quantity for parsing the frame of video obtained is the video frame number of download.
The frame of video in video frame buffers is taken out successively, and calling corresponding Video decoding module to carry out decoding acquisition can be straight
Connect the data cell of broadcasting(The video data unit of such as yuv format), decoding buffer zone is stored in, decoding is taken out during broadcasting successively
Data cell in buffering area is played out.Each frame of video one data cell of correspondence, is played in the first controlling cycle
The quantity of data cell be the video frame number played in the first controlling cycle.
, can be by detecting that video frame buffers obtain the video frame number of buffering after first controlling cycle terminates.Can be with
Set up and index for video frame buffers, the frame of video buffered to identify in video frame buffers, so as to quick acquisition
The video frame number buffered in video frame buffers.
For convenience of description, in following statements unless otherwise indicated, the video frame number of download refers to the download of the first controlling cycle
Video frame number, the video frame number played refers to the video frame number played in the first controlling cycle, and the video frame number of buffering refers to
The video frame number buffered after first controlling cycle terminates in video frame buffers.
Step 104, network condition is judged according to the video frame number of download and the video frame number played, according to regarding for buffering
Frequency frame number and the video frame number played judge whether the frame of video of buffering is sufficient, and according to network condition and the frame of video of buffering
Whether sufficient judged result calculates the video frame number to be played of the second controlling cycle.
The video frame number of download can accurately reflect network condition, and the video frame number of download is less than the frame of video played
Number, illustrates that network condition is not good, if continuing to broadcast according to the frame per second for having played video frame number/controlling cycle in the first controlling cycle
Put, consuming excessively for frame of video can be caused, follow-up play may be caused to interrupt, it is therefore desirable to adjust the second controlling cycle wait broadcast
Put video frame number.According to the judged result whether frame of video of buffering is sufficient, video frame number to be played can be specifically determined.Specifically
Ground, if the video frame number of buffering is more than the video frame number played, is illustrated that video frame buffer is sufficient, can be reduced with less amplitude
The value for the video frame number played as the second controlling cycle video frame number to be played;If on the contrary, the video frame number of buffering is small
In the video frame number played, illustrate that the frame of video of buffering is not enough, the video frame number played can be reduced with larger amplitude
It is worth the video frame number to be played as the second controlling cycle, so as to reach the smooth purpose for playing video stream media,
Step 106, video flowing is played according to the frame per second of video frame number to be played divided by controlling cycle in the second controlling cycle
Media.
In the second controlling cycle, according to the frame per second of video frame number to be played divided by controlling cycle successively from decoding buffer zone
Data cell is taken out uniformly to play.
The method of above-mentioned broadcasting video stream media, the first controlling cycle, the second controlling cycle are two adjacent control weeks
Phase, i.e., calculate the video frame number to be played of next controlling cycle after a upper controlling cycle terminates, go round and begin again, to play into
Control line period.If for example, controlling cycle is 1 second, when video stream media plays the 50th second, calculating the 50th second
The video frame number of interior download and the video frame number played, so that the video frame number to be played of the 51st second is calculated, so that the 51st
Second plays video stream media according to the frame per second of video frame number/1 to be played;Play after the 51st second, then calculate 52 seconds to be played
Video frame number, by that analogy, goes round and begins again, until playing the video stream media.
Network condition is accurately weighed according to the video frame number downloaded in the first controlling cycle and the video frame number played,
It can reflect whether network fluctuates in the first controlling cycle exactly, so as to the video according to network condition and buffering
Whether frame is sufficient to calculate the video frame number to be played to be played of the second controlling cycle.When network is fluctuated, with reference to buffering
Frame of video whether sufficient judged result adjust the second controlling cycle video frame number to be played, smoothly broadcast so as to reach
Put the purpose of video stream media, it is to avoid due to occur network fluctuation cause prematurely to run out of after playable frame of video can only in
Disconnected situation about playing.
As shown in Fig. 2 in one embodiment, step 104 includes:
Step 202, judge the video frame number downloaded whether be less than the video frame number played with it is default be less than 1 positive system
Several product, if then performing step 204, if otherwise performing step 210.
The video frame number of download can weigh the network condition in the first controlling cycle, so as to determine the second controlling cycle
Video frame number to be played provide reference.The value of the default positive coefficient for being less than 1 is preferably 0.5.If the video frame number downloaded
Less than the video frame number played and the product of the coefficient, illustrate that network condition is excessively poor, treating for the second controlling cycle should be set
Broadcasting video frame number is a less value.
Step 204, judge whether the video frame number of buffering is more than the video frame number played, if then performing step 206,
If otherwise performing step 208.
By judging whether the video frame number of buffering is more than the video frame number played, it can be determined that in video frame buffers
Whether the frame of video of buffering is sufficient, if the video frame number of buffering is more than the video frame number played, and illustrates that the frame of video of buffering is filled
Foot;If the video frame number of buffering is less than the video frame number played, illustrate that the frame of video of buffering is not enough.
Step 206, video frame number to be played is calculated according to the video frame number of download and the video frame number played.
Now, network condition is excessively poor, but the frame of video of buffering is sufficient, video frame number and played that main consideration is downloaded
Video frame number influence.Specifically, video frame number to be played can be the video frame number downloaded and the video frame number played
Weighted average, the average value of the video frame number especially downloaded and the video frame number played.Weighted average is taken both may be used
To prevent consuming excessively for frame of video during broadcasting to buffering, the smoothness of picture can be maintained as far as possible again.
Step 208, video frame number to be played is calculated according to the video frame number of buffering and the video frame number downloaded.
Now, network condition is excessively poor, and the frame of video of buffering is also not enough, and frame of video to be played should be reduced as far as possible
Number, can calculate video frame number to be played according to the video frame number of buffering and the video frame number of download.Specifically, video to be played
Frame number is less value in the video frame number of buffering and the video frame number of download.
Step 210, judge whether the video frame number downloaded is less than the video frame number played, if then performing step 212,
If otherwise performing step 218.
Now, the video frame number of download is not less than the product for the video frame number and default positive coefficient for being less than 1 played,
It is not excessively poor to illustrate network, and it is poor or normal that can determine whether current network.If the video frame number downloaded is small
In the video frame number played, illustrate that network is poor;If the video frame number downloaded is not less than the video frame number played, explanation
Network is normal, meets the demand of normal play video Streaming Media.
Step 212, judge whether the video frame number of buffering is more than the video frame number played, if then performing step 214,
If otherwise performing step 216.
Now, network is poor, can determine whether whether the frame of video of buffering is sufficient.If the video frame number of buffering is more than
The video frame number played, illustrates that the frame of video of buffering is sufficient;If the video frame number that the video frame number of buffering has no more than been played,
Illustrate that the frame of video of buffering is not enough.
Step 214, calculate to be played according to the video frame number of download, the video frame number of buffering and the video frame number played
Video frame number.
Now, although network is poor, but in video frame buffers abundance is buffered, the frame of video of download can be considered
Number, the video frame number of buffering and the video frame number played to playing the influence of video stream media glibly.Specifically, it is to be played
Video frame number is the weighted average of the video frame number, the video frame number of buffering and the video frame number played downloaded, especially
The average value of the video frame number of download, the video frame number buffered and the video frame number played.
Step 216, video frame number to be played is calculated according to the video frame number of buffering and the video frame number downloaded.
Now, network is poor, and the frame of video of buffering is not enough, and video frame number to be played should be reduced as far as possible, can be with
Video frame number to be played is calculated according to the video frame number of buffering and the video frame number downloaded.Specifically, video frame number to be played is
Less value in the video frame number of buffering and the video frame number downloaded.
Step 218, judge whether the video frame number of buffering is more than the video frame number played, if then performing step 220,
If otherwise performing step 222.
Now, the video frame number of download is not less than the video frame number played, and illustrates that network is normal, further basis can regard
Whether abundance determines video frame number to be played for frequency frame buffer zone.
Step 220, video frame number to be played is that default video plays frame number.
Now, network is normal, and video frame buffers are sufficient, and video frame number to be played is that default video plays frame number.Can
Frame number is played with the default video that video stream media is obtained by reading the file header of flow media data packet.Generally, depending on
Frequency play frame rate is 25 frames/second, therefore it can be 25* controlling cycles that default video, which plays frame number,.
Step 222, video frame number to be played is the video frame number of buffering.
Now, although network is normal, but video frame buffer is not enough, in order to ensure the smooth of video playback, set to be played
Video frame number for buffering video frame number, then in the subsequent control cycle, when network condition is normal, and buffering frame of video it is sufficient when
Video frame number to be played is set to default video again and plays frame number.
In the present embodiment, network condition is judged by the video frame number of download and the magnitude relationship for the video frame number played,
In conjunction with the whether sufficient video frame number to be played to calculate the second controlling cycle in video frame buffers, reach that smoothly broadcasting is regarded
The purpose of frequency Streaming Media so that terminal remains to smooth broadcasting in the case where fluctuation occurs in network, compatibility is strong.
As shown in figure 3, in one embodiment, step 104 is specifically included:
Step 302, judge whether the video frame number of buffering is more than the video frame number played, if otherwise performing step 304,
If then performing step 306.
By judging whether the video frame number of buffering is more than the video frame number played, it can be determined that the frame of video of buffering is
No abundance.If the video frame number of buffering is more than the video frame number played, illustrate that the frame of video of buffering is not enough, should be according to download
Video frame number and the video frame number played judge network condition, and calculate video frame number to be played according to network condition, specifically
, network condition is judged according to the video frame number of download and the video frame number played, and calculate to be played according to network condition
Video frame number comprises the following steps 306-314.If on the contrary, the video frame number that the video frame number of buffering has no more than been played, explanation
The frame of video of buffering is sufficient, performs step 304.
Step 304, video frame number to be played is calculated according to the video frame number of buffering and the video frame number downloaded.
Now, the frame of video of buffering is not enough, and video frame number to be played should be reduced as far as possible, can be according to the video of buffering
Frame number and the video frame number downloaded calculate video frame number to be played.Specifically, video frame number to be played is the video frame number of buffering
With less value in the video frame number of download.
Step 306, judge the video frame number downloaded whether be less than the video frame number played with it is default be less than 1 positive system
Several product, if then performing step 308, if otherwise performing step 310.
Compare the video frame number of download and the video frame number played and the product of the default positive coefficient for being less than 1 it is big
It is small, it can be determined that whether network is excessively poor.The value of the coefficient is preferably 0.5.
Step 308, video frame number to be played is calculated according to the video frame number of download and the video frame number played.
Now, network condition is excessively poor, but the frame of video of buffering is sufficient, video frame number and played that main consideration is downloaded
Video frame number influence.Specifically, video frame number to be played can be the video frame number downloaded and the video frame number played
Weighted average, the average value of the video frame number especially downloaded and the video frame number played.Weighted average is taken both may be used
To prevent consuming excessively for frame of video during broadcasting to buffering, the smoothness of picture can be maintained as far as possible again.
Step 310, judge whether the video frame number downloaded is less than the video frame number played.
By the size for the video frame number for comparing the video frame number of download and having played, it can be determined that whether network condition compares
It is poor.
Step 312, calculate to be played according to the video frame number of download, the video frame number of buffering and the video frame number played
Video frame number.
Now, although network is poor, but in video frame buffers abundance is buffered, the frame of video of download can be considered
Number, the video frame number of buffering and the video frame number played to playing the influence of video stream media glibly.Specifically, it is to be played
Video frame number is the weighted average of the video frame number, the video frame number of buffering and the video frame number played downloaded, especially
The average value of the video frame number of download, the video frame number buffered and the video frame number played.
Step 314, video frame number to be played is that default video plays frame number.
Now, network is normal, and video frame buffers are sufficient, and video frame number to be played is that default video plays frame number.Can
Frame number is played with the default video that video stream media is obtained by reading the file header of flow media data packet.Generally, depending on
Frequency play frame rate is 25 frames/second, therefore it can be 25* controlling cycles that default video, which plays frame number,.
As shown in figure 4, a kind of device for playing video stream media is provided in one embodiment, including:
Frame number acquisition module 402, for obtaining the video frame number downloaded in the first controlling cycle and the video played
Frame number, and the video frame number buffered in video frame buffers after the first controlling cycle terminates.
Video frame number computing module 404 to be played, sentences for the video frame number according to download and the video frame number played
Circuit network situation, judges whether the frame of video of buffering is sufficient according to the video frame number of buffering and the video frame number played, and root
According to the video frame number to be played of whether sufficient judged result the second controlling cycle of calculating of the frame of video of network condition and buffering.
Playing module 406, for being broadcast in the second controlling cycle according to the frame per second of video frame number to be played divided by controlling cycle
Put video stream media.
As shown in figure 5, in one embodiment, video frame number computing module 404 to be played includes:
Whether the first judge module 404a, the video frame number for judging to download is less than the video frame number played with presetting
The positive coefficient for being less than 1 product, if then judging whether the video frame number of buffering is more than the video frame number played.
First computing module 404b, if being more than the video frame number played for the video frame number buffered, according to download
Video frame number and the video frame number played calculate video frame number to be played;What if the video frame number of buffering had no more than been played
Video frame number, then calculate video frame number to be played according to the video frame number of buffering and the video frame number downloaded.
In one embodiment, if the first judge module 404a is additionally operable to the video frame number downloaded not less than regarding for having played
The product of frequency frame number and coefficient, then judge whether the video frame number downloaded is less than the video frame number played, if the video downloaded
Frame number is less than the video frame number played, then judges whether the video frame number of buffering is more than the video frame number played.
If the video frame number that the first computing module 404b is additionally operable to buffering is more than the video frame number played, according to download
Video frame number, the video frame number of buffering and the video frame number played calculate video frame number to be played;If the frame of video of buffering
The video frame number that number has no more than been played, then calculate frame of video to be played according to the video frame number of buffering and the video frame number downloaded
Number.
In one embodiment, if the first judge module 404a is additionally operable to the video frame number downloaded not less than regarding for having played
Frequency frame number, then judge whether the video frame number of buffering is more than the video frame number played.
If the video frame number that the first computing module 404b is additionally operable to buffering is more than the video frame number played, to be played to regard
Frequency frame number is that default video plays frame number;If the video frame number that the video frame number of buffering has no more than been played, video to be played
Frame number is the video frame number of buffering.
As shown in fig. 6, in one embodiment, video frame number computing module 404 to be played includes:
Second judge module 404c, for judging whether the video frame number of buffering is more than the video frame number played, if
Network condition is then judged according to the video frame number of download and the video frame number played.
Second computing module 404d, if the video frame number that the video frame number for buffering no more than has been played, according to slow
The video frame number of punching and the video frame number downloaded calculate video frame number to be played;If the video frame number of buffering is more than regarding for having played
Frequency frame number, then calculate video frame number to be played according to network condition.
Embodiment described above only expresses the several embodiments of the present invention, and it describes more specific and detailed, but simultaneously
Therefore the limitation to the scope of the claims of the present invention can not be interpreted as.It should be pointed out that for one of ordinary skill in the art
For, without departing from the inventive concept of the premise, various modifications and improvements can be made, these belong to the guarantor of the present invention
Protect scope.Therefore, the protection domain of patent of the present invention should be determined by the appended claims.