Embodiment
In order to make object of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, be not intended to limit the present invention.
embodiment one
Fig. 1 is the realization flow figure of the Vehicular video transmission method that the embodiment of the present invention provides, and details are as follows:
In step S101, when unstable networks, the video image that buffer memory is current;
Wherein, described when unstable networks, the video image that buffer memory is current, is specially:
When unstable networks, set up buffer area, by the video image that described buffer area buffer memory is current.
Wherein, by buffer area, can the video image that do not send in time due to network congestion of buffer memory.
In step s 102, according to the data volume of the real-time buffer memory of described video image, the encoder bit rate of the described video image of adjustment in real time;
Wherein, the data volume of real-time buffer memory represents levels of accumulation data cached in buffer area, directly utilizes levels of accumulation data cached in buffer area, real-time coding code check, adapt to the change of the network bandwidth with this, network added flow need not be increased, the object increasing reliability can be reached.
In step s 103, according to described encoder bit rate, described video image is encoded, generating video packet;
Can adopt any one video format existing, encode to described video image, generating video packet, does not limit at this.
In step S104, transmit described video packets of data.
Adopt the predetermined network transmission protocol, transmit described video packets of data, the described network transmission protocol includes but not limited to transmission control protocol (Transmission Control Protocol, TCP).
In embodiments of the present invention, according to the data volume of the real-time buffer memory of video image, the encoder bit rate of the described video image of adjustment in real time; According to encoder bit rate, video image is encoded, generating video packet; Transmitting video data bag.Avoid when unstable networks, appearance can not ensure the reliability of Vehicular video real-time data transmission, reduce the problem of the quality of Vehicular video, packet loss when reducing real-time video transmission can be maximized, obtain stable live video stream, thus both ensure that the reliability of Vehicular video real-time data transmission, also improve the quality of Vehicular video.
embodiment two
Fig. 2 is the implementation process figure of the Vehicular video transmission method step S102 that the embodiment of the present invention provides, and details are as follows:
In step s 201, when increasing according to the data volume of the real-time buffer memory of described video image, the encoder bit rate of described video image is reduced in real time, until described data volume is close to preset data amount;
Wherein, when increasing according to the data volume of the real-time buffer memory of described video image, reduce the encoder bit rate of described video image in real time, and according to the corresponding relation of self-defining described encoder bit rate and frame per second, corresponding reduction frame per second, to ensure the video quality of real-time Transmission.
In step S202, when the described data volume according to the real-time buffer memory of described video image reduces, heighten the encoder bit rate of described video image in real time, until described data volume is close to preset data amount.
Wherein, when the described data volume according to the real-time buffer memory of described video image reduces, heighten the encoder bit rate of described video image in real time, and according to the corresponding relation of self-defining described encoder bit rate and frame per second, correspondingly heighten frame per second, to ensure the video quality of real-time Transmission.
In embodiments of the present invention, according to the data volume of the real-time buffer memory of video image, the encoder bit rate of the described video image of adjustment in real time; According to encoder bit rate, video image is encoded, generating video packet; Transmitting video data bag.Packet loss when reducing real-time video transmission can be maximized, obtain stable live video stream, thus both ensure that the reliability of Vehicular video real-time data transmission, also improve the quality of Vehicular video.
embodiment three
Fig. 3 is the implementation process figure of the step S201 that the embodiment of the present invention provides, and details are as follows:
In step S301, obtain the difference between the real-time writing speed of described video image and reading speed;
In step s 302, judge whether described difference is greater than preset difference value in Preset Time;
In step S303, when whether difference described in Preset Time is greater than preset difference value, represents that the data volume of the real-time buffer memory of described video image increases, reduce the encoder bit rate of described video image in real time, until described data volume is close to preset data amount.
Wherein, within the sampling time of reducing encoder bit rate, the difference of read-write pin and read pointer is sampled and added up, by sampling statistics, when whether difference described in Preset Time is greater than preset difference value, represent that the data volume of the real-time buffer memory of described video image increases, reduce the encoder bit rate of described video image in real time.
For ease of illustrating, for practical application, details are as follows:
Wherein, buffer area is made up of multiple buffer unit, and the video data that H264 encoder time per unit produces writes one or more buffer units of buffer area, and data writing position write pointer represents, the size of each buffer unit is a fixed value, as 1024byte;
A unit buffer unit is once sent to TCP transmit queue as a packet by read pointer, if the difference of write pointer and read pointer is less than a unit, then read pointer is set to wait state;
The translational speed of write pointer affects by encoder bit rate, and the speed of read pointer sends the impact of code check by TCP, and network state is poorer, represents that speed of giving out a contract for a project is slower, and the probability of packet loss is tending towards increasing, then turn encoder bit rate down, namely reduce encoder bit rate.
In embodiments of the present invention, stable as much as possible and level and smooth in order to real-time video, reducing encoder bit rate is response fast, the sampling time of therefore reducing encoder bit rate is shorter than the sampling time raising encoder bit rate, by reducing encoder bit rate, packet loss when reducing real-time video transmission can be maximized, obtain stable live video stream, thus both ensure that the reliability of Vehicular video real-time data transmission, also improve the quality of Vehicular video.
embodiment four
Fig. 4 is the implementation process figure of the step S202 that the embodiment of the present invention provides, and details are as follows:
In step S401, obtain the difference between the real-time writing speed of described video image and reading speed;
Writing speed is the value of write pointer, and reading speed is the value of read pointer.
In step S402, judge whether described difference is not more than preset difference value in Preset Time;
In step S403, when whether difference described in Preset Time is not more than preset difference value, represents that the data volume of the real-time buffer memory of described video image reduces, heighten the encoder bit rate of described video image in real time, until described data volume is close to preset data amount.
Wherein, within the sampling time raising encoder bit rate, the difference of read-write pin and read pointer is sampled and added up, by sampling statistics, when whether difference described in Preset Time is not more than preset difference value, represent that the data volume of the real-time buffer memory of described video image reduces, heighten the encoder bit rate of described video image in real time.
Wherein, the sampling time raising encoder bit rate is longer than the sampling time of reducing encoder bit rate.
For ease of illustrating, for practical application, details are as follows:
Wherein, buffer area is made up of multiple buffer unit, and the video data that H264 encoder time per unit produces writes one or more buffer units of buffer area, and data writing position write pointer represents, the size of each buffer unit is a fixed value, as 1024byte;
A unit buffer unit is once sent to TCP transmit queue as a packet by read pointer, if the difference of write pointer and read pointer is less than a unit, then read pointer is set to wait state;
The translational speed of write pointer affects by encoder bit rate, and the speed of read pointer sends the impact of code check by TCP, if network state is better, then the speed of TCP transmission video data is faster, the speed reading video data is faster, just allow the more video data of encoder encodes, namely encoder bit rate can be adjusted to larger, and frame per second can also tune up;
If the difference of write pointer and read pointer is greater than 0 and be similar to the size of whole buffer area, then the video data volume that in the representation unit time, TCP sends is less than the video data that coding produces, and should reduce encoder bit rate; If the difference of write pointer and read pointer is 0, and keep difference to be 0 in a period of time, then raise encoder bit rate;
In embodiments of the present invention, stable as much as possible and level and smooth in order to real-time video, raising encoder bit rate is slow response, therefore the sampling time raising encoder bit rate is longer than the sampling time of reducing encoder bit rate, by raising encoder bit rate, can packet loss when reduction real-time video transmission, improve transmission speed, obtain stable live video stream, thus both ensure that the reliability of Vehicular video real-time data transmission, also improve the quality of Vehicular video.
embodiment five
The present embodiment essentially describes the realization flow of Vehicular video transmission in actual applications, and details are as follows:
1, install onboard by vehicle-mounted DVR, connect camera and 3G antenna, plug wireless 3G card, normally power on to equipment, vehicle-mounted DVR normally starts;
2, after the normal electrifying startup of equipment, carry out 3G dialup networking, and registration is networked to video server;
3, open real-time video client, by client application equipment end real-time video, carry out real-time video monitoring;
4, device coding produces real time video data, and be sent to server by wireless 3G, server is forwarded to client, and client carries out decoding playback;
5, when device coding code check starts, first can give tacit consent to an initial bit rate value, then can carry out self-adaption code rate adjustment according to the real time status of 3G network, make full use of wireless network resource to reach, ensure the transmission quality of real-time video;
6, after device coding produces and looks real-time audio data, server is mail to by Transmission Control Protocol, at application layer application buffer area, and the read-write pointer of difference set buffer area, send the difference of buffer area read-write pointer according to real time video data application layer, namely utilize and send the data cached levels of accumulation of buffer area, in real time the encoder bit rate of adjustment transmitting terminal, adapt to the change of the network bandwidth with this, network added flow need not be increased;
7, send buffer area to be made up of multiple buffer unit, the video data that H264 encoder time per unit produces writes one or more buffer units in Circular buffer district, data writing position write pointer represents, the size of each buffer unit is a fixed value, as 1024byte, often write a certain amount of coding video frequency data, write pointer carries out corresponding shifting function;
8, a unit buffer unit is once sent to TCP transmit queue as a packet by read pointer, if the difference of write pointer and read pointer is less than a unit, then read pointer is set to wait state;
9, the translational speed of write pointer affects by encoder bit rate, and the speed of read pointer sends the impact of code check by TCP, if network state is better, then the speed of TCP transmission video data is faster, the speed reading video data is faster, just allow the more video data of encoder encodes, namely code check can be adjusted to larger, and frame per second can also tune up; On the contrary, network state is poorer, represents that speed of giving out a contract for a project is slower, and the probability of packet loss is tending towards increasing, then turn code check down, reduces frame per second;
If the difference of 10 write pointers and read pointer is greater than 0 and be similar to the size of whole buffer area, then the video data volume that in the representation unit time, TCP sends is less than the video data that coding produces, and should reduce encoder bit rate; If the difference of write pointer and read pointer is 0, and keep difference to be 0 in a period of time, then should raise encoder bit rate;
11, reduce encoder bit rate and raise two kinds of adjustable strategies that encoder bit rate is this self-adaption code rate adjustment algorithm, when the encoder bit rate of real-time video is greater than the transmission code rate of network, carry out the adjustment of reduction encoder bit rate, when Video Coding is less than Internet Transmission code check, carry out the encoder bit rate adjustment raised.In reality, in order to real-time video is stable as much as possible and level and smooth, reducing encoder bit rate is response fast, but rising encoder bit rate is slow response, needs to wait for that steadily certain period adjusts network just namely raise encoder bit rate;
Although 12 reduction encoder bit rates are quick responses, and to raise encoder bit rate be slow response, but two kinds of code adjustment strategies all need to carry out sampling statistics, namely added up by the sampling of the read-write pointer position difference of certain period, judge whether to carry out encoder bit rate adjustment response, and the sampling time raising encoder bit rate is longer than the sampling time of reducing encoder bit rate;
13, while taking encoder bit rate to adjust, in order to ensure real-time video quality, tackling frame per second mutually and also adjusting, reducing frame per second when code check reduces, when code check raises, increase frame per second;
embodiment six
Fig. 5 is the structured flowchart of the Vehicular video transmitting device that the embodiment of the present invention provides, and this device can run in vehicle-mounted video monitoring device.For convenience of explanation, illustrate only part related to the present embodiment.
With reference to Fig. 5, this Vehicular video transmitting device, comprising:
Video image cache module 51, for when unstable networks, the video image that buffer memory is current;
Encoder bit rate adjusting module 52, for the data volume according to the real-time buffer memory of described video image, the encoder bit rate of the described video image of adjustment in real time;
Video packets of data generation module 53, for according to described encoder bit rate, encodes to described video image, generating video packet;
Video packets of data transport module 54, for transmitting described video packets of data.
In a kind of implementation of the present embodiment, in this Vehicular video transmitting device, described video image cache module 51, specifically for when unstable networks, sets up buffer area, by the video image that described buffer area buffer memory is current.
In a kind of implementation of the present embodiment, be the structured flowchart of encoder bit rate adjusting module 52 in the Vehicular video transmitting device that provides of the embodiment of the present invention with reference to figure 6, Fig. 6, in this Vehicular video transmitting device, described encoder bit rate adjusting module 52 comprises:
Encoder bit rate reduces unit 521, for when increasing according to the data volume of the real-time buffer memory of described video image, reduces the encoder bit rate of described video image in real time, until described data volume is close to preset data amount;
Encoder bit rate heightens unit 522, for when the described data volume according to the real-time buffer memory of described video image reduces, heightens the encoder bit rate of described video image in real time, until described data volume is close to preset data amount.
In a kind of implementation of the present embodiment, be the structured flowchart that in the Vehicular video transmitting device that provides of the embodiment of the present invention, encoder bit rate reduces unit 521 with reference to figure 7, Fig. 7, in this Vehicular video transmitting device, described encoder bit rate reduces unit 521 and comprises:
First obtains subelement 5211, for obtaining the difference between the real-time writing speed of described video image and reading speed;
First judgment sub-unit 5212, for judging whether described difference is greater than preset difference value in Preset Time;
Encoder bit rate reduces subelement 5213, for when whether difference described in Preset Time is greater than preset difference value, represent that the data volume of the real-time buffer memory of described video image increases, reduce the encoder bit rate of described video image in real time, until described data volume is close to preset data amount.
In a kind of implementation of the present embodiment, be the structured flowchart that in the Vehicular video transmitting device that provides of the embodiment of the present invention, encoder bit rate heightens unit 522 with reference to figure 8, Fig. 8, in this Vehicular video transmitting device, described encoder bit rate is heightened unit 522 and is comprised:
Second obtains subelement 5221, for obtaining the difference between the real-time writing speed of described video image and reading speed;
Second judgment sub-unit 5222, for judging whether described difference is not more than preset difference value in Preset Time;
Encoder bit rate heightens subelement 5223, for when whether difference described in Preset Time is not more than preset difference value, represent that the data volume of the real-time buffer memory of described video image reduces, heighten the encoder bit rate of described video image in real time, until described data volume is close to preset data amount.
The device that the embodiment of the present invention provides can be applied in the embodiment of the method for aforementioned correspondence, and details, see the description of above-described embodiment, do not repeat them here.
Through the above description of the embodiments, those skilled in the art can be well understood to the mode that the present invention can add required common hardware by software and realizes.Described program can be stored in read/write memory medium, described storage medium, as random asccess memory, flash memory, read-only memory, programmable read only memory, electrically erasable programmable memory, register etc.This storage medium is positioned at memory, and processor reads the information in memory, performs the method described in each embodiment of the present invention in conjunction with its hardware.
The above; be only the specific embodiment of the present invention, but protection scope of the present invention is not limited thereto, is anyly familiar with those skilled in the art in the technical scope that the present invention discloses; the change that can expect easily or replacement, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection range of claim.