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.
- 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.
- Open the app and adjust the video resolution and frame rate settings to fit your bandwidth.
- Scroll to the bottom and tap Start server (or the equivalent “Start Broadcast” button).
- 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.
- For MJPEG (HTTP) Streams: The stream URL is
typically
http://<YOUR_IP>:8080/videoorhttp://<YOUR_IP>:8080/videofeed. - For H.264 (RTSP) Streams: If your app supports
RTSP, the stream URL is typically
rtsp://<YOUR_IP>:554/h264_pcm.sdporrtsp://<YOUR_IP>:8554/live.
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-i: Specifies the input URL of your mobile IP camera.-c:v libx264: Transcodes the video to the H.264 codec.-preset fast: Balances encoding speed and compression efficiency.-crf 23: Controls video quality (lower values mean better quality; 18-28 is standard).-c:a aac: Transcodes the audio to AAC.output.mp4: The output file name.
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.mp4Stream 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_KEYUsing 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.