Stream Phone Camera to FFmpeg via IP Webcam

Turning your mobile phone into an IP camera and processing its video feed with FFmpeg is a powerful way to set up low-cost surveillance, live streaming, or video testing environments. This article provides a straight-to-the-point guide on how to install an IP camera app on your smartphone, locate your device’s network stream URL, and execute the correct FFmpeg commands to capture and transcode the video in real-time.

Step 1: Install and Configure an IP Camera App

To turn your mobile phone into an IP camera, you need an app that broadcasts your camera feed over your local Wi-Fi network.

  1. On Android, download and install IP Webcam (by Pavel Khlebovich) from the Google Play Store. On iOS, download Live-Reporter or a similar RTSP/MJPEG streaming app from the App Store.
  2. Open the app and adjust the video resolution and frame rate settings to fit your bandwidth.
  3. Scroll to the bottom and tap Start server (or the equivalent “Start Broadcast” button).
  4. The app will display an IP address and port number on your phone screen (for example, http://192.168.1.50:8080). Note this address down, as you will need your phone and computer to be connected to the same Wi-Fi network.

Step 2: Identify the Stream URL

FFmpeg requires the direct path to the video stream, not just the landing page of the web interface.

Replace <YOUR_IP> with the actual IP address displayed on your mobile device.

Step 3: Transcode the Video with FFmpeg

With FFmpeg installed on your computer, open your terminal or command prompt. Use one of the following commands depending on your use case.

Convert Stream and Save to MP4 File

To capture the live stream, transcode the video into the widely compatible H.264 codec, compress the audio to AAC, and save it as an MP4 file, run:

ffmpeg -i http://192.168.1.50:8080/video -c:v libx264 -preset fast -crf 23 -c:a aac -b:a 128k output.mp4

Low-Latency Hardware Accelerated Transcoding (NVIDIA GPU)

If you have an NVIDIA graphics card and want to reduce CPU usage during real-time transcoding, use the hardware-accelerated NVENC encoder:

ffmpeg -hwaccel cuda -i http://192.168.1.50:8080/video -c:v h264_nvenc -preset fast output.mp4

Stream to an External RTMP Server (e.g., YouTube or Twitch)

To transcode the phone’s camera feed and push it to a live streaming platform, redirect the output to an RTMP URL:

ffmpeg -rtsp_transport tcp -i rtsp://192.168.1.50:8554/live -c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k -bufsize 6000k -g 60 -c:a aac -f flv rtmp://a.rtmp.youtube.com/live2/YOUR_STREAM_KEY

Using the -rtsp_transport tcp flag forces FFmpeg to use TCP for the input RTSP stream, which prevents packet loss and visual artifacts. Press q in your terminal window at any time to stop capturing and safely close the video file.