Summary of the invention
In view of this, the invention provides a kind of flow media playing method and device, can effectively alleviate network delay, reduce as much as possible to play time-delay, promote user experience to a greater degree.
In order to solve the problems of the technologies described above, the present invention has adopted following technical scheme:
A kind of flow media playing method comprises the steps:
Client detection of dynamic stream media transmission quality;
Client is adjusted current streaming media playing speed and buffering area duration according to current stream media transmission quality by default principle.
Above-mentioned flow media playing method, client is determined current stream media transmission quality by detecting current buffering area filling rate.
Above-mentioned flow media playing method, client are adjusted current streaming media playing speed by default principle and are carried out as follows:
The buffering area duration is set, and serves as to adjust the execution cycle, adjust execution cycle at each and carry out following adjustment with the buffering area duration of Set For Current:
Current buffering area filling rate slows to multiplying power at a slow speed less than 1/4 with current streaming media playing speed, keeps current buffering area duration constant;
Current buffering area filling rate slows to multiplying power at a slow speed in 1/4 to 1/2 interval with current streaming media playing speed, the buffering area duration is increased be big multiplying power duration;
Current buffering area filling rate is in 1/2 to 3/4 interval, and uncomfortable rectification media play speed keeps the buffering area duration of Set For Current constant;
Current buffering area filling rate speeds up streaming media playing to quick multiplying power greater than 3/4, and the buffering area duration is reduced to little multiplying power duration.
Above-mentioned flow media playing method, described multiplying power at a slow speed are 0.8 times of normal multiplying power, and described quick multiplying power is 1.2 times of positive multiplying constant, and described big multiplying power duration is 5/4 of a current buffering area duration, and described little multiplying power duration is 3/4 of a current buffering area duration; Perhaps, described multiplying power at a slow speed be current playback rate (the buffering area filling rate that 1-is current) doubly.
Above-mentioned flow media playing method, described buffering area filling rate are the mean value that the repeatedly sampling of adjusting in the execution cycle is calculated.
Above-mentioned flow media playing method, when filling buffering area first, the initial duration of buffering area at first is set, add up each framing interval in the buffering area simultaneously at the filling buffering area, if largest frames surpasses the current initial duration of buffering area at interval, then with this largest frames at interval as the initial duration of new buffering area, fill until first and to finish, the buffering area duration when finishing with filling is the original duration of buffering area.
Above-mentioned flow media playing method in filling the buffering area process first, adopts multiplying power playing stream media at a slow speed.
The invention also discloses a kind of streaming medium playing device, comprise stream media transmission quality detection module and streaming media playing module, wherein:
The stream media transmission quality detection module is used for the detection of dynamic stream media transmission quality;
The streaming media playing module is used for according to current stream media transmission quality, adjusts current streaming media playing speed by default principle.
Compared with prior art, beneficial effect of the present invention is: by detecting stream media transmission quality, and the broadcasting speed and the buffering area duration of Streaming Media are adjusted according to stream media transmission quality, like this, if network condition is better, quickening broadcasting speed that can be suitable, reduce the buffering area duration, play time-delay thereby reduce, if network condition is relatively poor, the broadcasting speed that slows down that then can be suitable, increase the buffering area duration, thereby the depletion rate of the buffered data in the reduction buffering area is alleviated the influence of network delay, thereby can bring the user better streaming media playing experience.
Embodiment
Below in conjunction with accompanying drawing the specific embodiment of the present invention is elaborated.
In streaming media playing, the network digital video playback is relatively large for the dependence of network quality, thereby, below, will be example with the network digital video playback, the present invention is carried out exemplary description.It will be appreciated, of course, that the present invention can be useful in the various streaming media playing.
Main inventive concept of the present invention is: use the dynamic QQS buffering area that the network digital video is play, by in player, adding a dynamic QQS module, according to current network conditions video playback speed is adjusted, the size of dynamic adjustments screen buffer, to reach under the condition that reduces the video playback time-delay as far as possible network delay is optimized, thereby when effectively alleviating network delay, can reduce as much as possible to play time-delay, promote user experience to a greater degree.
As shown in Figure 1, the exemplary description of Fig. 1 theory structure of the present invention.Can see, come the video flowing of automatic network to be transferred to client player, in client player, dynamic QQS module mentioned above mainly comprises two parts, promptly cushions output and regulates control section.Wherein:
The buffering output, the frame of the supervision player that continues deposits that (the next link of buffering area is considered as the buffer memory of decoder, and is not shown, the buffer memory of decoder is a part of decoder, can be understood as the inlet of decoder, its buffer memory one frame data are not independent parts) in, whether current have data can deliver to decoder, and keep frame and deposit not for empty, when not having data in frame is deposited, the buffering output should be exported frame data arrival frame from buffering area at once and deposit.
Regulate control section, in real time playback rate is adjusted according to current network condition, to reach the purpose of dynamic adjustment buffer size.To the adjustment of playback rate specifically is to deposit the time interval that each frame data is delivered to decoder and finish by changing frame.
In the present invention, owing to playback rate is adjusted according to network condition, thereby will be referred to different playback rates, therefore, be understandable that the buffered data playing duration that calculates with the local current playback rate of client player may be inconsistent with the buffered data playing duration that calculates with normal play speed (this speed may be different with current playback rate).In this article, the time that title is calculated with the normal play speedometer is absolute time, hereinafter, represent buffer size with the buffering area duration, this buffering area duration calculates based on absolute time, that is, if the buffering area duration is 100 milliseconds, promptly it can cushion the data with 100 milliseconds of normal play speed broadcasts.
As shown in Figure 2, the exemplary description of Fig. 2 broadcast of the present invention adjust flow process.It is by client player detection of dynamic stream media transmission quality that flow process is adjusted in this broadcast, and according to current stream media transmission quality, adjusts current streaming media playing speed by default principle and realize.
Stream media transmission quality, i.e. network quality situation is to determine by the filling rate that detects buffering area, the filling rate of buffering area is the ratio of the available buffer data duration of actual buffered data duration in the buffering area and buffering area.For example, buffering area can cushion 400 milliseconds data, and the duration of current actual buffered data of filling is 200 milliseconds, and the filling rate of then current buffering area is 1/2.
In the filling process first of buffering area, when promptly preparing to play, for the first time buffering area is filled.At first need to be provided with the initial value of buffering area duration, claim that this initial value is the initial duration of buffering area, each framing interval (frame period refers to that previous frame is accomplished to the absolute time difference that present frame is finished) in the statistics buffering area when filling buffering area, if largest frames at interval (each framing before beginning to play maximum at interval) surpasses the initial duration of buffering area, then the initial duration of buffering area is made as this largest frames at interval, continue buffering, finish until the filling first of buffering area.Especially, claim that the initial duration of buffering area of filling when finishing is the original duration of buffering area.
In example of the present invention, the playback rate adjustment is an implementation of repeatedly carrying out.We are implemented as an adjustment execution cycle with adjustment each time.This adjusts the execution cycle based on current buffering area duration, for example, setting current buffering area duration (current buffering area available buffer data duration) is t1, then adjusting the execution cycle is t1, it should be noted that, after buffering area duration is each time adjusted, adjust also dynamic change thereupon of execution cycle.
As mentioned above, the playback rate adjustment is carried out based on the filling rate of buffering area, it is more accurate for the buffering area filling rate is calculated, adopted repeatedly sampling in this example, ask for average mode, promptly adjust in the execution cycle the repeatedly current filling duration of sampling buffer (the actual buffered data duration of current buffering area) at one, the setting sampling period is t (t<t1), to repeatedly (general, sampling number is more than or equal to t1/t time, if t equals frame period just, then sampling number equals t1/t) sampling obtain each fill duration and be averaged, setting and should on average filling duration is t2, and then t2/t1 is a buffering area filling rate of adjusting in the execution cycle.For example, in certain adjusts the execution cycle, t1=400ms, t=10ms (frame period is about about 40ms), the average filling duration t2=100ms of 40 samplings, then the buffering area filling rate of this adjustment execution cycle is t2/t1=1/4.
Behind the buffering area filling rate that calculates an adjustment execution cycle,, playback rate is adjusted according to following default principle as Fig. 2:
Current buffering area filling rate shows that less than 1/4 big time-delay appears in network condition, and current streaming media playing speed is slowed to multiplying power at a slow speed, keeps current buffering area duration constant;
Current buffering area filling rate shows that in 1/4 to 1/2 interval network condition is relatively poor, and current streaming media playing speed is slowed to multiplying power at a slow speed, the buffering area duration is increased be big multiplying power duration;
Current buffering area filling rate shows that in 1/2 to 3/4 interval the size of current buffering area comparatively adapts to current network condition, and uncomfortable rectification media play speed keeps the buffering area duration of Set For Current constant;
Current buffering area filling rate shows that greater than 3/4 network condition is better, and streaming media playing is speeded up to quick multiplying power, and the buffering area duration is reduced to little multiplying power duration.
In this example, described multiplying power at a slow speed is 0.8 times of normal multiplying power, and described quick multiplying power is 1.2 times of positive multiplying constant, and described big multiplying power duration is 5/4 of a current buffering area duration, and described little multiplying power duration is 3/4 of a current buffering area duration.
Generally, video playback speed is when 0.8 times of normal speed is finely tuned between 1.2 times, and human eye comparatively is not easy to discover, so main these two numerical value that adopt of this example carry out the adjustment of playback rate.Certainly, the adjustment coefficient of playback rate also more flexible way calculate, when for example slowing down broadcasting speed, can be with described multiplying power at a slow speed current playback rate (the buffering area filling rate that 1-is current) doubly.Certainly, also can select more satisfactory broadcasting speed to adjust strategy according to practical situations.
For further improving practicality and accuracy, in the process of filling buffering area first, the mode that also can adopt slower broadcasting speed (as 0.8 times of speed) to play is filled buffering area, until reaching the original duration of buffering area.Promptly adopt 0.8 times of speed to get started broadcast, unnecessary 20% buffered data is filled to buffering area, can show picture at once like this, and needn't be in order to fill up the time-delay that represents that buffering area increases the first frame picture.
Streaming medium playing device of the present invention comprises stream media transmission quality detection module and streaming media playing module, and stream media transmission quality detection module and streaming media playing module are arranged in the client player, wherein:
The stream media transmission quality detection module is used for the detection of dynamic stream media transmission quality; It can determine current stream media transmission quality by detecting current buffering area filling rate.
The streaming media playing module is used for according to current stream media transmission quality, adjusts current streaming media playing speed by default principle.Adjusting current streaming media playing speed carries out as follows:
The buffering area duration is set, and serves as to adjust the execution cycle, adjust execution cycle at each and carry out following adjustment with the buffering area duration of Set For Current:
Current buffering area filling rate slows to multiplying power at a slow speed less than 1/4 with current streaming media playing speed, keeps current buffering area duration constant;
Current buffering area filling rate slows to multiplying power at a slow speed in 1/4 to 1/2 interval with current streaming media playing speed, the buffering area duration is increased be big multiplying power duration;
Current buffering area filling rate is in 1/2 to 3/4 interval, and uncomfortable rectification media play speed keeps the buffering area duration of Set For Current constant;
Current buffering area filling rate speeds up streaming media playing to quick multiplying power greater than 3/4, and the buffering area duration is reduced to little multiplying power duration.
The working method of streaming medium playing device is similar to aforesaid flow media playing method, repeats no more.
The present invention can be according to the network quality situation, dynamically adjust the size of video playback buffering area, effectively alleviate network delay, and reduce as far as possible and play time-delay, reach the balance of network delay disturbance and video playback time-delay, experience thereby bring the better streaming media playing of user.
The present invention adopts the mode of the filling rate of statistics buffering area in a period of time when judging the network quality situation, owing to carry out in client, so stability is better, misoperation is also less, and viewing effect is better.
When the network quality situation is better, transmission rate causes buffer overflow greater than decode rate situation easily takes place, the present invention accelerates broadcasting speed when buffering area does not also have overflow, reduce the buffering area set point.This client that is adjusted at is finished, and assists without streaming media server.
The present invention adjusts execution cycle at each and resets according to the filling rate of this time period internal buffer size to buffering area, make it to adapt to current network condition, the dynamic adjustment of QOS runs through the whole video playing process all the time, thereby has good adjustment effect.
Above content be in conjunction with concrete preferred implementation to further describing that the present invention did, but this example of just lifting for ease of understanding should not think that concrete enforcement of the present invention is confined to these explanations.For the general technical staff of the technical field of the invention, without departing from the inventive concept of the premise, can make various possible being equal to and change or replacement, these changes or replacement all should belong to protection scope of the present invention.