System, terminal and the method for a kind of video location
Technical field
The present invention relates to technical field of video processing, the system that positions more particularly, to a kind of video, point
Broadcast terminal and system.
Background technology
Existing player, the main window of User Interface includes title bar, broadcast window and control group.
When for the continuous moving picture encoding of video image, continuous some width images are divided into I frame, P frame, B
Frame three types.
I frame: be also called key frame, can individually decode the picture that a width is complete;
P frame: decoding need to rely on frame above
B frame: decoding needs to refer to the frame of front and back.
Seeing accompanying drawing 1 is location schematic diagram.Owing to P frame or B frame can not individually decode, to obtain a frame complete
Picture, but it is necessarily dependent upon I frame.Therefore when positioning action, it is necessary to first navigate to I frame, then pressing
Order is decoded to P or the B frame of some correspondence positioning time.Assume to be spaced apart 1 second between two I frames, middle
B frame and P frame have 9.
When user drags the progress bar of control group, it is desirable to navigate to 10.9 seconds.Currently mainly there are two kinds of differences
Localization method:
1, precision frame alignment
First navigate to I frame nearest on the left of the time, be first I frame of accompanying drawing 1, solve the most in order
Code is to the Frame that timestamp (pts) is 10.9 correspondences.In order to complete positioning action, it is necessary to decoding 10.0
Could play to 10.9 data amounting to 10 frames and need the data of location.If decoding one frame needs 20 milliseconds, then
Time-consuming about 510 milliseconds of average decoding.
2, fast frame location
Speed-priority principle is to use to sacrifice precision to reach quickly to position.When there is positioning action, only need
Navigate to from the nearest I frame of this anchor point.The most only need to navigate to what pts value was 11.0s
I frame.
Both of which above has obvious shortcoming, and precision is preferentially when location, it may appear that longer
Stand-by period;Speed-priority then can navigate to from the nearest I frame of user specified point, and this I frame is with actual
Specified location in user have the regular hour poor, this period of time difference is loss of significance.Between I frame
When being spaced bigger, loss of accuracy also can increase therewith.
Summary of the invention
The embodiment of the present invention proposes the system of a kind of video location, it is possible to quickly location and guarantee positioning accurate
Degree.
The embodiment of the present invention also proposes the terminal of a kind of video location, it is possible to quickly location and guarantee are fixed
Position precision.
The embodiment of the present invention also proposes the method for a kind of video location, it is possible to quickly location and guarantee positioning accurate
Degree.
The technical scheme of the embodiment of the present invention is as follows:
The system of a kind of video location, described system includes terminal and server end;
Server end, for sending video file to terminal;
Terminal, for determining that the I frame number of described video file, less than or equal to the first threshold preset, is adopted
Use accurate frame alignment, play the video file behind location;Determine that the I frame number of described video file is more than described
First threshold, less than the Second Threshold preset, uses adaptive frame location, plays the video file behind location;
Determining that the I frame number of described video file, more than or equal to described Second Threshold, uses fast frame location, it is fixed to play
Video file after Wei.
Described terminal includes:
Memory module, for storing the video file that server end sends, and sends video file to controlling
Module;
Control module, for determining that the I frame number of described video file is less than or equal to described first threshold, by institute
State video file to send to accurate frame alignment module;Determine that the I frame number of described video file is more than described first
Threshold value is less than described Second Threshold, sends described video file to adaptive frame locating module;Determine described
The I frame number of video file is more than or equal to described Second Threshold, sends described video file to fast frame location
Module;
Fast frame locating module, for the described video file received being carried out fast frame location, and will location
After video file send to playing module;
Adaptive frame locating module, for the described video file received being carried out adaptive frame location, and will
Video file behind location sends to playing module;
Accurately frame alignment module, for the described video file received being carried out accurate frame alignment, and will location
After video file send to playing module;
Playing module, the video file after playing location.
Described server end and described terminal obtain video file by point-to-point mode.
The terminal of a kind of video location, it is characterised in that for determining the I frame number of described video file
Less than or equal to the first threshold preset, use accurate frame alignment, play the video file behind location;Determine institute
The I frame number stating video file is determined less than the Second Threshold preset, employing adaptive frame more than described first threshold
Position, plays the video file behind location;Determine that the I frame number of described video file is more than or equal to described second threshold
Value, uses fast frame location, plays the video file behind location.
Described terminal includes:
Memory module, for storing the video file that server end sends, and sends video file to controlling
Module;
Control module, for determining that the I frame number of described video file is less than or equal to described first threshold, by institute
State video file to send to accurate frame alignment module;Determine that the I frame number of described video file is more than described first
Threshold value is less than described Second Threshold, sends described video file to adaptive frame locating module;Determine described
The I frame number of video file is more than or equal to described Second Threshold, sends described video file to fast frame location
Module;
Fast frame locating module, for the described video file received being carried out fast frame location, and will location
After video file send to playing module;
Adaptive frame locating module, for the described video file received being carried out adaptive frame location, and will
Video file behind location sends to playing module;
Accurately frame alignment module, for the described video file received being carried out accurate frame alignment, and will location
After video file send to playing module;
Playing module, the video file after playing location.
A kind of method of video location, the method includes:
The I frame number of video file, less than or equal to the first threshold preset, uses accurate frame alignment;
The I frame number of video file less than the Second Threshold preset, uses adaptive frame more than described first threshold
Location;
The I frame number of video file is more than or equal to described Second Threshold, uses fast frame location.
By the time difference t1 between anchor point and a upper I frame, maximum decoding time loss D1, maximal accuracy
Computing capability C of loss D2, CPUcpuConsumption C with CPUcodecDetermine that described adaptive frame positions institute
Corresponding time t.
Described t is determined by below equation: t=t1*D1*Ccpu 2/(Ccodec 2*D2+Ccpu 2*D1)。
Described CcpuDominant frequency and interior check figure by CPU determine.
Described CcodecDetermined with video file frame per second by video file resolution ratio.
From technique scheme it can be seen that in embodiments of the present invention, server end is to terminal
Send video file;Terminal is according to the I frame number of video file and first threshold and the pass of Second Threshold
It is to determine to position with corresponding video locating method.Determine that the I frame number of described video file is less than
In default first threshold, use accurate frame alignment, play the video file behind location;Regard described in determining
The I frame number of frequency file less than the Second Threshold preset, uses adaptive frame location more than described first threshold,
Play the video file behind location;Determine that the I frame number of described video file is more than or equal to described Second Threshold,
Employing fast frame positions.So select video locating method for different size of video file, it is possible to fast
Speed location and guarantee positioning precision.
Accompanying drawing explanation
Fig. 1 is location schematic diagram;
Fig. 2 is the system architecture schematic diagram of embodiment of the present invention video location;
Fig. 3 is the terminal structural representation of embodiment of the present invention video location;
Fig. 4 is the method flow schematic diagram of embodiment of the present invention video location;
Fig. 5 is the location schematic diagram of the embodiment of the present invention.
Detailed description of the invention
For making the object, technical solutions and advantages of the present invention express clearer, below in conjunction with attached
The present invention is further described in more detail for figure and specific embodiment.
In embodiments of the present invention, for different size of video file, select different video locating methods,
It is thus possible to quickly position and ensure positioning precision.
Seeing the system architecture schematic diagram that accompanying drawing 2 is video location, the system of video location includes server end
201 and terminal 202.
Server end 201 sends video file to terminal 202.Wherein, server end 201 is with all
Terminal 202 obtain video file by point-to-point (P2P) mode, it is also possible to be server end 201
Directly send video file to terminal 202.
Terminal 202 determines that the I frame number of video file, less than or equal to the first threshold preset, uses accurately
Frame alignment, plays the video file behind location;Determine that the I frame number of video file is less than pre-more than first threshold
If Second Threshold, use adaptive frame location, play location after video file;Determine video file
I frame number is more than or equal to Second Threshold, uses fast frame location, plays the video file behind location.First threshold
Determine with the corresponding relation that Second Threshold is the I frame number by video file and progress bar scale.Specifically,
Obtain video I frame number, obtain progress bar scale.Determine that first threshold is maximum progress bar scale 1/10,
Second Threshold is maximum progress bar scale.Such as, maximum progress scale is 1000, then first threshold is 100,
Second Threshold is 1000, selects to position mode accordingly according to the I frame data of video documents.
See accompanying drawing 3 terminal 202 and include that memory module 2021, control module 2022, fast frame position
Module 2023, adaptive frame locating module 2024, accurate frame alignment module 2025 and playing module 2026.
Memory module 2021 stores the video file that server end 201 sends, and sends video file to control
Molding block 2022;Control module 2022 determines that the I frame number of video file is less than or equal to first threshold, by described
Video file sends to accurate frame alignment module 2025;If control module 2022 determines the I of described video file
Described video file less than Second Threshold, is sent to adaptive frame locating module by frame number more than first threshold
2024;If the I frame number that control module 2022 determines described video file is more than or equal to Second Threshold, by described
Video file sends to quick locating module 2023.Wherein, accurate frame alignment module 2025 uses existing skill
Accurate frame alignment in the middle of art, fast frame locating module 2023 uses the fast frame in the middle of prior art to position.
And adaptive frame locating module 2024 uses the adaptive frame location in the present invention, referring specifically to step
405。
Accurately frame alignment module 2025 carries out accurate frame alignment to the described video file received, and by behind location
Video file send to playing module 2026;The adaptive frame locating module 2024 described video to receiving
File carries out adaptive frame location, and sends the video file behind location to playing module 2026;Fast frame
Locating module 2023 carries out fast frame location to the described video file received, and by the video file behind location
Send to playing module 2026;Playing module 2026 plays the video file behind location.
See the method flow schematic diagram that accompanying drawing 4 is video location, specifically include following steps:
Step 401, startup player, playing video file.
Start player, commence play out video file.Wherein, the video file of broadcasting can be to have downloaded
To terminal video file, it is also possible to be the online video file play.
Step 402, whether click on or pull the progress bar of video file.
When user clicks on or pulls the progress bar of video file, then user needs to carry out video location, performs step
Rapid 403;Otherwise, perform step 401 and continue playing video file.
Step 403, determine frame alignment according to I frame number and the first threshold of video file and the relation of Second Threshold
Mode.
The I frame number of video file, less than or equal to the first threshold preset, uses accurate frame alignment, performs step
404;The I frame number of video file less than the Second Threshold preset, uses adaptive frame more than described first threshold
Location, performs step 405;The I frame number of video file is more than or equal to described Second Threshold, uses fast frame fixed
Position, performs step 406.
Step 404, accurate frame alignment.
First navigate to nearest I frame, be decoded to the Frame that anchor point is corresponding the most in order.Finally broadcast
The Frame that blow-down site is corresponding.
Step 405, adaptive frame position.
By the time difference t1 between anchor point and a upper I frame, maximum decoding time loss (D1), maximum essence
Degree loss (D2), computing capability C of CPUcpuConsumption C with CPUcodecDetermine that described adaptive frame is fixed
Time t corresponding to Wei, thus can be positioned by t.T1 can determine according to the structure of frame, D1
It is all that the concrete condition according to user pre-sets with D2.Wherein, CcpuBy the dominant frequency (f) of CPU and
Interior check figure n determines, concrete, Ccpu=f*n.CcodecFrame per second by video file resolution ratio Yu video file
Determine.Specifically, Ccodec=KX+C, wherein, X is the frame per second of video file resolution ratio and video file
Product, K Yu C is constant, be by decoding algorithm time complexity determine, for prior art.I.e.
Work as t=t1*D1*Ccpu 2/(Ccodec 2*D2+Ccpu 2* D1) time, it is possible to quickly location and guarantee positioning accurate
Degree.
Determination process the following detailed description of t.
Time difference between video anchor point and a upper I frame is the t1 second, and the time between next I frame
Difference is t2, and decoding when performing video positioning action consumes as T1, perform time essence during video positioning action
Exactness loss is Tlost.Wherein, T1=t*Ccodec/Ccpu, Tlost=| t1-t |.
The decoding time loss that user can tolerate when video positions is D1, can tolerate in accuracy
Accuracy loss is D2, and decoding elapsed time is proportional relation with patient time, accuracy loss and tolerance
Degree coefficient is proportional relation.
In order to make time loss minimize, then q1*T1+q2*TlostTake minimum of a value.Q1 is the decoding time
Consuming tolerance coefficient, q2 is that accuracy is lost tolerance coefficient, q1=t/D1;Q2=| t1-t|/D2。
When using adaptive location to carry out video location, video position location is 10.6pts, as shown in Figure 5.
So video location can any point between two 1-frames, but must be fulfilled for a requirement, it is simply that q1*
T1+q2*TlostTake minimum of a value.Owing to can only identify I frame when video positions, it is impossible to identify P frame and B
All non-I frames are here simply treated by frame as P frame.
Note H=Ccodec/Ccpu;
Video navigates to the time difference with a upper I frame when being t, and can obtain q1*T at t1+q2*Tlost
Minimum of a value, note F (t)=q1*T1+q2*Tlost, then have:
F (t)=q1*T1+q2*Tlost
=(t*H/D1) * t*H+ (| t1-t|/D2)*|t1-t|;
=(t*H)2/D1+(t1-t)2/D2;
=[(t*H)2*D2+(t1-t)2*D1]/(D1*D2);
=[(H2*D2+D1)*t2–2*t1*D1*t+t1 2*D1]/(D1*D2);
={ (H2*D2+D1)*(t-t1*D1/(H2*D2+D1))2
t1 2*D12/(H2*D2+D1)2+t1 2*D1}/(D1*D2);
I.e. work as t=t1*D1/(K2* D2+D1) time can obtain minimum of a value.
Step 406, fast frame position.
When there is positioning action, it is only necessary to navigate to from the nearest I frame of this anchor point.
First navigate to nearest I frame, be decoded to the Frame that anchor point is corresponding the most in order.
The above, only presently preferred embodiments of the present invention, it is not intended to limit the protection of the present invention
Scope.All within the spirit and principles in the present invention, any modification, equivalent substitution and improvement etc. made,
Should be included within the scope of the present invention.