A kind of playing method and device for regarding video flowing in networking
Technical field
This application involves network technique field, more particularly to it is a kind of regard in networking the playback method of video flowing and, one
Kind regards the playing device of video flowing in networking.
Background technology
It is a real-time exchange platform depending on networking, is the more advanced form of internet, it is potentially huge on network to regard
Frequency flow uses two advantages of asynchronous and packet switch of Ethernet depending on networking, and eliminating Ethernet under the premise of full compatibility lacks
It falls into, has the end-to-end seamless connection of the whole network, direct user terminal directly carries IP data packets, also, user data is in the whole network model
Any format conversion is not required in enclosing, can realize the whole network HD video real-time Transmission that current internet can not be realized.
Therefore, push numerous the Internet, applications to HD video depending on networking, unitize, high definition is face-to-face.It is most real at last
This life circle, the distance for realizing person to person in global range was the distance of a screen without distance;On the other hand, have depending on networking
Flexible, the simple and low price of packet switch, is provided simultaneously with quality and the safety assurance of circuit switching, on communication history for the first time
Realize the seamless connection of the whole network switched virtual circuit and data format.
In practical applications, ES is carried out using regarding networking(Elementary stream, primary flow/elementary stream)Net
During network video steaming transfer, due to there is no timestamp information, that is to say, that can not determine the time that video decoding plays.Each is regarded
The size of frequency frame is all different, especially I frames(Key frame)With P frames(Difference frame)Between, often mutually far short of what is expected times.And
And network transmission is there is also many uncertain factors, therefore the phenomenon that play when often has interim card.
Invention content
This application provides a kind of playback methods for regarding video flowing in networking, and video flowing is received simultaneously to avoid by regarding networking
The video cardton problem occurred when playing out.
Correspondingly, present invention also provides a kind of playing device for regarding video flowing in networking, to ensure the above method
It realizes.
This application provides a kind of playback methods for regarding video flowing in networking, which is characterized in that including:
The coding parameter for video flowing is pre-set in video sending end, and the video flowing includes key frame and multiple
Difference frame;
The video sending end encodes each frame video flowing according to the coding parameter, after coding, the key frame
It is less than the first preset value with the magnitude difference of the difference frame, the magnitude difference of each difference frame is less than the second preset value;
The video sending end sends the video flowing by regarding networking to video receiver, when sending control at interval of
The period of third preset value sends a frame video flowing, and goes out a frame video stream within the period of the 4th preset value
It goes;
Video receiver receives the video flowing, and timestamp information is added for each frame video flowing;
Current frame per second information is calculated according to the timestamp information, and according to the frame per second information constant duration pair
Each frame video flowing received is decoded, and decoded video flowing is played out.
Preferably, the video sending end depending on the step of sending the video flowing to video receiver of networking by including:
The video sending end is connected into regarding networking, and is passed through to establish with video receiver regarding networking and be connected;
The video sending end generation includes socket information, and pass through according to the socket information and regarded depending on networking to described
Frequency receiving terminal sends the video flowing, and the socket information identifies the video flowing and passed in the data link layer depending on networking
Defeated transmission path.
Preferably, the socket information includes the protocol number, interface index number, header class of the physical layer of data link layer
It is one or more in type, packet type, physical layer address and physical layer address length.
Preferably, it is described current frame per second information to be calculated according to timestamp information, and according to frame per second information constant duration
The step of ground is decoded each frame video flowing received includes:
The timestamp information carried according to the frame video flowing that is currently received and the first frame video flowing received
Timestamp information calculates the frame per second information;
Average time interval between two frame video flowings, and one time interval of suspend mode are determined according to the frame per second information
Afterwards next frame video flowing is sent to decoder;
The decoder is decoded the frame video flowing received.
Preferably, before next frame video flowing is sent to decoder, each frame video stream buffer received is regarded described
Frequency receiving terminal, the video flowing are primary flow.
Present invention also provides it is a kind of regard networking in video flowing playing device, including:
Parameter setting module, for pre-setting the coding parameter for video flowing, the video flowing in video sending end
Include key frame and multiple difference frames;
Coding module encodes each frame video flowing according to the coding parameter for the video sending end, coding
Afterwards, the magnitude difference of the key frame and the difference frame is less than the first preset value, and the magnitude difference of each difference frame is less than the
Two preset values;
Sending module sends the video flowing to video receiver by regarding networking for the video sending end, is sending out
Control sends a frame video flowing, and by one within the period of the 4th preset value at interval of the period of third preset value when sending
Frame video stream is gone out;
Receiving module, the video flowing is received for video receiver, and timestamp information is added for each frame video flowing;
Frame per second computing module, for calculating current frame per second information according to the timestamp information;
Decoder module, for according to the frame per second information constant duration being solved to each frame video flowing received
Code;
Playing module, for being played out to decoded video flowing.
Preferably, the sending module includes:
Submodule is connected, is connected into for the video sending end regarding networking, and passes through and is established regarding networking and video receiver
Connection;
Information generates submodule, and socket information is included for video sending end generation;
Video stream submodule regards networking to video receiver transmission institute for being passed through according to the socket information
Video flowing is stated, the socket information identifies the transmission path that the video flowing is transmitted in the data link layer depending on networking.
Preferably, the socket information includes the protocol number, interface index number, header class of the physical layer of data link layer
It is one or more in type, packet type, physical layer address and physical layer address length.
Preferably, the frame per second computing module, specifically for the time carried according to the frame video flowing being currently received
The timestamp information of stamp information and the first frame video flowing received calculates the frame per second information;
The decoder module includes:
Interval calculation submodule, for being determined according to the frame per second information between the average time between two frame video flowings
Every, and after one time interval of suspend mode next frame video flowing is sent to decoder;
Decoding video stream submodule is decoded the frame video flowing received for the decoder.
Preferably, described device further includes:
Buffer module, for being buffered before next frame video flowing is sent to decoder in the video receiver from reception
Each frame video flowing arrived, the video flowing are primary flow.
Compared with background technology, the application includes advantages below:
Through the embodiment of the present invention, the coding parameter of video sending end is adjusted, is reduced between each difference frame and crucial
Difference in size between frame and difference frame so that the size of each frame is uniform as possible, when being sent by regarding networking, sends at equal intervals
Per frame video flowing, and a frame video flowing is controlled to be sent within the preset unit interval, and in video receiver according to each
The timestamp information statistics frame per second information that a video flowing carries, according to frame per second information at equal intervals toward decoder transmission data, thus
Ensure that video receiver can equally spaced decode every frame video flowing, realize and uniformly play video flowing, avoid the interim card of video flowing
Problem.
Description of the drawings
Fig. 1 is a kind of flow chart for regarding the playback method of network video stream in networking described in the embodiment of the present application;
Fig. 2 is the flow chart that ES streams are handled in an example of the embodiment of the present application;
Fig. 3 is a kind of structure diagram for regarding the playing device of network video stream in networking described in the embodiment of the present application.
Specific embodiment
Above-mentioned purpose, feature and advantage to enable the application are more obvious understandable, below in conjunction with the accompanying drawings and specific real
Mode is applied to be described in further detail the application.
With reference to Fig. 1, it illustrates the playback method flows for regarding network video stream in networking a kind of described in the embodiment of the present application
Figure.
Step 101 pre-sets the coding parameter for video flowing in video sending end, and the video flowing includes key
Frame and multiple difference frames.
The embodiment of the present invention can solve the problems, such as that ES streams, can also by depending on networking transport and interim card that while playing occurs
For other due to the problem of interim card is played caused by cause not of uniform size between frame.
It is flowed for ES, I frames represent key frame, it can be understood as the complete reservation of this frame picture, since it includes complete
Picture, when decoding, only need this frame data that can complete, P frames i.e. difference frame, and expression is this frame with one before
A key frame(Or P frames)Difference, need during decoding to be superimposed with the difference of this frame definition withs the picture cached before, generation is finally
Picture, P frames do not have complete picture data, the only data with the picture difference of former frame.
The full-size after a frame compression of images can be set by coding parameter, the size of such I frames image would not
It is excessive.It only needs to set in encoder initialization primary.
Step 102, the video sending end encode each frame video flowing according to the coding parameter, after coding, institute
The magnitude difference for stating key frame and the difference frame is less than the first preset value, and the magnitude difference of each difference frame is less than second and presets
Value.
Video sending end encodes video flowing according to coding parameter, it is therefore intended that so that each frame sign is equal as possible
Even, i.e., between each P frames and the size of I frames and P frames can be consistent as possible.
When this is coding parameter, according to specific application and can need set, due in concrete implementation simultaneously
Size is identical between can not causing each frame, can cause each frame sign relatively as possible, difference is acceptable
Within the scope of, in the embodiment of the present invention, the magnitude difference of the key frame and the difference frame can be set to be less than first default
Value, the magnitude difference of each difference frame are less than the second preset value.
Step 103, the video sending end send the video flowing by regarding networking to video receiver, are sending time control
The period made at interval of third preset value sends a frame video flowing, and by a frame video within the period of the 4th preset value
Stream is sent.
In the embodiment of the present invention, video sending end sends each frame video flowing by the way of the even packet of even frame.
If transmitting terminal can uniformly send every frame data, for example original video frame per second is 30fps, then every 33ms just
Send a frame data, then receiving terminal will uniformly receive image data, then can directly decode display.Thus protect
It is synchronous with receiving terminal transmitting terminal is demonstrate,proved, video playing is just very smooth, and here it is so-called even frames.Even packet is that a frame data are uniform
Within the unit interval, i.e. sent in a frame time.Network flow can be more stable in this way, is not in that network load is instantaneous
The phenomenon that peak value is excessive.
Specifically, by when sending each frame video flowing, the time interval for controlling transmission is third preset value, that is, is controlled
A frame video flowing is sent at interval of the period of third preset value, to realize even frame, by controlling each frame video flowing identical
Time in be sent, i.e., a frame video stream is gone out within the period of the 4th preset value, to realize even packet.
In reality, since network transmission bandwidth is limited, and I frames are usually more many times greater than P frame, can not be in a frame
Time in be sent.Therefore, can under conditions of bandwidth permission as fast as possible one frame data of transmission, if an I
Frame is excessive, takes several time quantums, then just needs to send P frame data as early as possible in the next time, until extensive
Again to the normal condition that can be at equal intervals sent by frame.
It is used in the embodiment of the present invention, between video sending end and video receiver and is attached depending on networking and transmits video
Flow data, specifically, video sending end is connected into regarding networking, and is passed through to establish with video receiver regarding networking and be connected, video connects
Receiving end can be connected into before or after video sending end is connected into regarding networking.
In concrete implementation, video receiver and video sending end all can be set-top box, as video receiver
Set-top box is set-top box client(Client ends), the set-top box as video sending end is server end(Server ends), depending on
Frequency receiving terminal and video sending end may be that other can be connected into the equipment regarding networking.
In the embodiment of the present invention, it is preferable that the video sending end passes through depending on being regarded described in networking to video receiver transmission
The step of frequency flows includes:
Sub-step S11, the video sending end are connected into regarding networking, and are passed through to establish with video receiver regarding networking and be connected;
Sub-step S12, video sending end generation include socket information, and are passed through according to the socket information and regard connection
Net sends the video flowing to the video receiver, and the socket information identifies the video flowing in the data-link regarding networking
The transmission path that road floor is transmitted.
After video receiver and video sending end establish connection by regarding networking, video receiver is sent to video sending end
Video flowing.The relevant environment of the set-top box of one of application scenarios is Linux environment, will be from link layer in linux environment(MAC)
Direct transceiving data frame, in the embodiment of the present invention, video is flowed through regarding networking transport, different from the transmission mode of traditional Ethernet
Part is:During through Ethernet transmitting video-frequency flow, video steaming transfer is in third layer, that is, application layer of ISO(Network layer), pass through IP
Video receiver and video sending end is identified in address, and video receiver and video sending end are carried during video steaming transfer
IP address;During through regarding networking transport data, video steaming transfer ISO the second layer, that is, link layer, by link layer information to regarding
The video receiver and video sending end of frequency stream are identified, and when video steaming transfer carries link layer information.
Receipts and the work of hair can be respectively completed in linux environment by libpcap and two dynamic bases of libnet.
Although it is widely used, using still there is many drawbacks in the software for requiring to carry out cross-platform transplanting;Again because regarding
The video of networking is all by two layers(Link layer)To carry out transceiving data, while for the use space for reducing flash.This
Inventive embodiments used it is a kind of more directly, need not install other libraries slave link layer transceiving data frame mode, i.e., it is logical
It crosses and defines the socket of link layer to complete, is i.e. packet sockets, packet sockets are used to receive and dispatch original number on the mac layer
It according to frame, allows for completing realization at all levels on link layer in user's space in this way, either carry out developing or tests work
All bringing great convenience property.
Information of the socket information as link layer is used in the embodiment of the present invention.Video receiver is when generating video flowing
Socket information is added in video stream packets, when sending video flowing to video sending end, according to what is identified in socket information
It is transmitted depending on networking data link layer transfer path, socket information can include the agreement of the physical layer of data link layer
Number, it is one or more in interface index number, header type, packet type, physical layer address and physical layer address length.
Step 104, video receiver receive the video flowing, and timestamp information is added for each frame video flowing.
In background technology, when video steaming transfer, does not carry timestamp information, in the embodiment of the present invention, is regarded for each frame
Frequency stream addition timestamp information.For calculating frame per second information.
Step 105 calculates current frame per second information according to the timestamp information, and according to times such as the frame per second information
Compartment of terrain is decoded, and decoded video flowing is played out each frame video flowing received.
Receiving terminal needs to record timestamp information at that time, and according to timestamp information statistics frame when receiving the first frame data
Rate information, in the embodiment of the present invention, the step 105 can include:
Sub-step S21, the timestamp information carried according to the frame video flowing being currently received and the first frame received
The timestamp information of video flowing calculates the frame per second information;
Sub-step S22, the average time interval between two frame video flowings, and suspend mode one are determined according to the frame per second information
After a time interval next frame video flowing is sent to decoder;
Sub-step S23, the decoder are decoded the frame video flowing received.
Can frame per second information be calculated according to the time difference of current time and first frame after a certain number of frames are received,
The timestamp information carried according to the frame video flowing being currently received and the timestamp of first frame video flowing received
Information calculates frame per second information.Over time, the frame per second information being calculated is just more accurate.Get frame per second information
Afterwards, the average time interval between two frame video flowings is determined according to the frame per second information, it is possible to one time interval of suspend mode
Time, that is to say a frame time, then data are sent toward decoder.Decoder can further flow into the frame video received
Row decoding.
In the embodiment of the present invention, before next frame video flowing is sent to decoder, each frame video flowing for receiving can be with
It is buffered in the video receiver.
In summary, it is seen that set about in terms of the embodiment of the present invention is from Video coding, network is sent, network receives three, base
The smooth playing of video is realized in sheet, has mainly done the improvement of following three aspects:
1st, transmitting terminal coding parameter is adjusted so that each frame sign is uniform as possible, i.e. the size of I frames and P frames is kept as possible
Unanimously.
2nd, the even packet of the even frame of transmitting terminal, has sent a frame data in a frame time as possible.
3rd, increase rx-side buffering, count frame per second information, equally spaced past decoder send data.
Through the embodiment of the present invention, the coding parameter of video sending end is adjusted, is reduced between each difference frame and crucial
Difference in size between frame and difference frame so that the size of each frame is uniform as possible, and when being sent by regarding networking, control is at equal intervals
It sends per frame video flowing, and a frame video flowing is controlled to be sent within the preset unit interval, and delay in video receiver
The Video stream information received is rushed, frame per second information is counted according to the timestamp information that each video flowing carries, according to frame per second information
At equal intervals toward decoder transmission data, so as to ensure that video receiver can equally spaced decode every frame video flowing, realize uniform
Video flowing is played, avoids the interim card problem of video flowing.
In order to which those skilled in the art is made to more fully understand the present invention, specifically illustrated below by way of one
Bright, Fig. 2 is the flow chart that ES streams are handled in an example of the embodiment of the present application, and it is video sending end to start, receiving end, that is, video
Receiving terminal, as figure may include steps of:
Originator:
1st, video flowing is acquired.
2nd, coding parameter is adjusted, data are encoded according to coding parameter.
3rd, after encoding, transmitting terminal transmission data controls the sending times of data.
Receiving end:
1st, receiving terminal receives simultaneously buffered data, is sent to decoder at equal intervals.
2nd, decoder is decoded video flowing.
4th, display of video streams is played.
In this example, the form of input video stream is 720P60, and coding parameter is as follows:MaxPicSizeRatio is 200,
Target bit rate is 2mbps, and bite rate control mode is dynamic code stream control vbr, and only I frames and P frames, I frame periods are 60 frames.Interception
60 frame data after coding are as follows, and wherein first frame is I frames, are all subsequently P frames, and size is 42290,4050,2632 successively,
3480,2355,2356,2217,2206,2235…(Unit is byte).Understand that current network bandwidth is 4mbps according to configuration,
Then sending first frame needs the time of 86ms or so, i.e. 5 frame multiple spots, then sends 2-7 frames below at full speed, restores to the 8th frame
Normally, i.e., a frame data are only sent in every frame time.
Through the embodiment of the present invention, the coding parameter of video sending end is adjusted, is reduced between each difference frame and crucial
Difference in size between frame and difference frame so that the size of each frame is uniform as possible, and when being sent by regarding networking, control is at equal intervals
It sends per frame video flowing, and a frame video flowing is controlled to be sent within the preset unit interval, and delay in video receiver
The Video stream information received is rushed, frame per second information is counted according to the timestamp information that each video flowing carries, according to frame per second information
At equal intervals toward decoder transmission data, so as to ensure that video receiver can equally spaced decode every frame video flowing, realize uniform
Video flowing is played, avoids the interim card problem of video flowing.
It should be noted that for aforementioned embodiment of the method, in order to be briefly described, therefore it is all expressed as a series of
Combination of actions, but those skilled in the art should know, the application is not limited by described sequence of movement, because according to
According to the application, certain steps may be used other sequences or be carried out at the same time.Secondly, those skilled in the art should also know,
Embodiment described in this description belongs to preferred embodiment, necessary to involved action not necessarily the application.
Based on the explanation of above method embodiment, present invention also provides the corresponding broadcastings for regarding network video stream in networking
Device embodiment, to realize the content described in above method embodiment.
With reference to Fig. 3, it illustrates the playing device structures for regarding network video stream in networking a kind of described in the embodiment of the present application
Block diagram.
Parameter setting module 201, for pre-setting the coding parameter for video flowing, the video in video sending end
Stream includes key frame and multiple difference frames;
Coding module 202 encodes each frame video flowing according to the coding parameter for the video sending end, compiles
After code, the magnitude difference of the key frame and the difference frame is less than the first preset value, and the magnitude difference of each difference frame is less than
Second preset value;
Sending module 203 sends the video flowing by regarding networking for the video sending end to video receiver,
Control sends a frame video flowing at interval of the period of third preset value during transmission, and will within the period of the 4th preset value
One frame video stream is gone out;
Receiving module 204 receives the video flowing for video receiver, for each frame video flowing addition timestamp letter
Breath;
Frame per second computing module 205, for calculating current frame per second information according to the timestamp information;
Decoder module 206, for according to the frame per second information constant duration being carried out to each frame video flowing received
Decoding;
Playing module 207, for being played out to decoded video flowing.
In the embodiment of the present invention, it is preferable that the sending module includes:
Submodule is connected, is connected into for the video sending end regarding networking, and passes through and is established regarding networking and video receiver
Connection;
Information generates submodule, and socket information is included for video sending end generation;
Video stream submodule regards networking to video receiver transmission institute for being passed through according to the socket information
Video flowing is stated, the socket information identifies the transmission path that the video flowing is transmitted in the data link layer depending on networking.
In the embodiment of the present invention, it is preferable that the socket information includes the protocol number of the physical layer of data link layer, connects
It is one or more in stomochord quotation marks, header type, packet type, physical layer address and physical layer address length.
In the embodiment of the present invention, it is preferable that the frame per second computing module, specifically for being regarded according to the frame being currently received
The timestamp information of the frequency stream timestamp information carried and the first frame video flowing received calculates the frame per second information;
The decoder module includes:
Interval calculation submodule, for being determined according to the frame per second information between the average time between two frame video flowings
Every, and after one time interval of suspend mode next frame video flowing is sent to decoder;
Decoding video stream submodule is decoded the frame video flowing received for the decoder.
In the embodiment of the present invention, it is preferable that described device further includes:
Buffer module, for being buffered before next frame video flowing is sent to decoder in the video receiver from reception
Each frame video flowing arrived, the video flowing are primary flow.
Through the embodiment of the present invention, the coding parameter of video sending end is adjusted, is reduced between each difference frame and crucial
Difference in size between frame and difference frame so that the size of each frame is uniform as possible, and when being sent by regarding networking, control is at equal intervals
It sends per frame video flowing, and a frame video flowing is controlled to be sent within the preset unit interval, and delay in video receiver
The Video stream information received is rushed, frame per second information is counted according to the timestamp information that each video flowing carries, according to frame per second information
At equal intervals toward decoder transmission data, so as to ensure that video receiver can equally spaced decode every frame video flowing, realize uniform
Video flowing is played, avoids the interim card problem of video flowing.
It is regarded for above-mentioned in networking for the playing device embodiment of network video stream, since it is basic with embodiment of the method
It is similar, so description is fairly simple, the part explanation of related part embodiment of the method shown in Figure 1.
The application can be used in numerous general or special purpose computing device environment or configuration.Such as:Personal computer, service
Device computer, handheld device or portable device, laptop device, multi-processor device, the device based on microprocessor, top set
Box, programmable consumer-elcetronics devices, network PC, minicomputer, mainframe computer, including any of the above device or equipment
Distributed computing environment etc..
The application can be described in the general context of computer executable instructions, such as program
Module.Usually, program module includes routines performing specific tasks or implementing specific abstract data types, program, object, group
Part, data structure etc..The application can also be put into practice in a distributed computing environment, in these distributed computing environment, by
Task is performed and connected remote processing devices by communication network.In a distributed computing environment, program module can be with
In the local and remote computer storage media including storage device.
It should also be noted that, herein, term " comprising ", "comprising", not only including those elements, but also including
It other elements that are not explicitly listed or further includes as elements inherent to such a process, method, article, or device.
In the absence of more restrictions, the element limited by sentence " including ... ", it is not excluded that in the mistake for including the element
Also there are other identical elements in journey, method, article or equipment.
It should be understood by those skilled in the art that, embodiments herein can be provided as method, apparatus or computer program
Product.Therefore, the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware can be used in the application
Apply the form of example.Moreover, the computer for wherein including computer usable program code in one or more can be used in the application
Usable storage medium(Including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)The computer program production of upper implementation
The form of product.
Playback method to a kind of network video stream in networking provided herein and the network video in networking above
The playing device of frequency stream, is described in detail, specific case used herein to the principle and embodiment of the application into
It has gone elaboration, to have understood the present processes and its core concept the explanation of above example is only intended to helping;Meanwhile for this
The those skilled in the art in field, according to the thought of the application, there will be changes in specific embodiments and applications,
In conclusion the content of the present specification should not be construed as the limitation to the application.