Android video recording, another mobile phone real-time viewing scheme

Source: Internet
Author: User
Tags nginx server

Recent research on the Android video recording, another mobile phone real-time viewing, there are a few ideas.

1. The Android phone acts as a server, uses NANOHTTPD to act as a server, and another phone or PC is viewed by entering http://Phone's ip:8080 URL.

This scheme can refer to Ipcamera-for-android Open source project, URL Http://code.google.com/p/ipcamera-for-android/source/checkout

The source code that can be run can be downloaded here http://download.csdn.net/detail/xiaoliouc/4933558

Disadvantage: Android phone must support MP4+ARM_NB format, some phones are not compatible, delay a bit fierce, the previous research in Googlecode see the code, it seems that the program is not advisable

2. Android phone using Juv-rtmp-client.jar package, online has a charge package, but can search cracked package, through RTMP protocol to publish service to Red5 server. The server is of course Red5, you can use the Red5 own OFLA demo to do the test. Client code can refer to Ivideochat, http://download.csdn.net/detail/xiaoliouc/4933594

Play using a player that supports rtmp protocol, such as Ffplay.  

Cons: Demo delay is great, for reference only. RTMP protocol Semi-open, more difficult

3.android phones shoot video through camera class. A frame-by-frame image compression is sent to the server via a socket and the server can be viewed directly. If you want another phone to be able to watch, you can let the server forward to achieve. Example Online there are many, http://download.csdn.net/detail/xiaoliouc/4933610

Disadvantage: The transmission process consumes a lot of traffic through a frame-by-frame sending of data. Play yes, but not in the actual project.

4.android mobile phone through the camera class to take video, the shooting video through H264 encoding, can be used soft coding (using the x264 library or Opencore Software library), Java class through the JNI call compiled so file to achieve. It is then transmitted to the server via the UDP-based RTP protocol. Why not use the TCP protocol, because TCP retransmission mechanism will generate delay and jitter, and the use of the UDP transport protocol itself is non-connected, can not provide quality assurance, need to use RTP or RTCP UDP protocol only to provide traffic control and congestion control services. The server decodes and plays the received h264 through FFmpeg. Playback can use VLC media player. If you're familiar with C + +, take a look at live555, an open source project.

Disadvantage: Need to use more knowledge points, jni,h264 codec, RTP protocol and so on. The use of soft code, mobile phone CPU operation is relatively large, easy to heat.

5.android phones take video through the Mediarecorder class, which of course includes audio. The captured video is encoded by H264 and can be hard-coded (direct manipulation of the hardware for the phone) and only for 3gp,mp4 video formats. Method Reference http://blog.csdn.net/zblue78/article/details/6078040

This blog, inside is very detailed, extract H264 Sps,pps, can refer to http://blog.csdn.net/peijiangping1989/article/details/6934317

The Winhex is a handy 16 binary viewing tool that http://download.csdn.net/detail/xiaoliouc/4928773

There is a lot of code online, personal understanding is: Mediarecorder recorded video (3gp,mp4), can be Mmediarecorder.setpreviewdisplay (Msurfaceholder.getsurface ()) Preview video, sent to the local localserversocket H264 live video stream via Localsocket. This process involves hard coding, hard-coded personal understanding is that in the preview process or in advance to determine the video Sps,pps,head (generally 0x00000001), different phone hardware is not the same. Write these parameters to H264, get the correct h264 video stream, and then push the stream to the streaming media server, using a player that supports the RTSP protocol, such as VLC.

6, using HLS protocol, the server uses Nginx,ffmpeg decoding. Nginx Server building process, ffmpeg installation process see my previous articles.

The decoded MP4 file is then TS-sliced with ffmpeg to generate an indexed m3u8 file, which can then be accessed by the client via the browser http://ip:port/*.m3u8.

7. Relatively easy and effective way to build an RTSP server on Android phone, another phone using VLC player input rtsp://ip:port/play video. The specific principle is, through the Android phone to mediarecorder recording video, transfer Localsocket to the local through the hard code, add RTP head, separate NALU packet, according to the RTSP protocol interactive process to send data to each other.

The code can refer to the spydroid, the source code can be svncheckout, can run normally, and the effect is good.

Http://code.google.com/p/spydroid-ipcamera/source/checkout.

Online has not analyzed the spydroid source of the article, and so on their own empty have the opportunity to analyze the source code.

8. The front is a one-way video, if it is two-way video, in fact, video conferencing, you can refer to the sipdroid Open source code, website: http://code.google.com/p/sipdroid/source/ Checkout

Android video recording, another mobile phone live view scenario

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.