Recently, I have studied the real-time video network transmission problem of Android. I have spent a lot of effort on video processing. I have summarized the following five solutions and compared them.
Take video transmission of 320x240 as an Example
Solution |
Compression rate |
Compression/Transmission Mode |
Real-time |
Average Traffic consumption |
Transmission Distance |
Use the callback function of camera to send the original yuv420 data. |
0 |
No compression, frame-Based Transmission |
High (20 ~ 30 FPS) |
Very high (6.5 Mbps), too horrible o_o |
Wired or wireless at close distance |
Use mediarecorder to hard encode yuv420 with h264 before sending |
High (95%) |
Inter-frame compression and Video Stream Transmission |
High (20 FPS) |
Low (30 ~ 70 Kbps) |
Long distance |
Call the local h264 encoding library (JNI) to encode a frame of yuv420 and then send |
High (97%) |
Inter-frame compression, transmitted by Frame |
Low (2 FPS) |
Low (20 Kbps) |
Long distance |
Use a gzip library to compress a frame of data and then send it (a wonderful Practice) |
Relatively high (70% ~ 80%) |
Intra-frame compression and transmission by Frame |
Low (5 FPS) |
Relatively high (300 Kbps) |
Long distance |
Compressing and transmitting one frame of data in JPEG Mode |
Average (about 60%) |
Intra-frame compression and transmission by Frame |
High (25 FPS) |
(170 Kbps) |
Long distance (bandwidth allowed) |
Note: mediarecorder has strong hardware dependence. Therefore, different mobile phones have different performance. Some mobile phone data transmission may be congested, reducing the real-time performance.
To sum up, solution 2 (mediarecorder) and solution 5 (JPEG) can still be considered. Because my project only needs to transmit data in close-range wireless mode, and the hardware level is not high, therefore, solution 5 is selected.
The above scheme is summarized after I have studied the real-time video encoding and transmission scheme in a more specific and in-depth manner recently. I hope that friends who need to study video transmission can refer to it!