How to Stream Video via FFmpeg HTTP Progressive Download
This guide explains how to stream video files over a local area network (LAN) using FFmpeg’s built-in HTTP server capabilities. You will learn how to configure FFmpeg to serve a compatible MP4 video stream using progressive download settings and how to access the stream from another device on your network using a media player like VLC.
Step 1: Prepare the FFmpeg Command
FFmpeg can act as a basic HTTP server using the
-listen 1 flag. To stream an MP4 file over HTTP progressive
download, the video must be fragmented so the receiving client can start
playback without waiting for the entire file to download.
Run the following command in your terminal or command prompt:
ffmpeg -re -i input.mp4 -c:v libx264 -preset veryfast -c:a aac -f mp4 -movflags frag_keyframe+empty_moov -listen 1 http://0.0.0.0:8080Command Breakdown:
-re: Tells FFmpeg to read the input file in real-time (at its native frame rate). This is crucial for streaming.-i input.mp4: Specifies your source video file.-c:v libx264 -preset veryfast: Re-encodes the video to H.264 using a fast preset to reduce latency and CPU usage.-c:a aac: Re-encodes the audio to AAC format for maximum device compatibility.-f mp4: Forces the output format to be MP4.-movflags frag_keyframe+empty_moov: This is the key setting for HTTP progressive streaming. It fragments the MP4 file and writes the metadata at the beginning, allowing the client to play the stream instantly.-listen 1: Tells FFmpeg to act as an HTTP server and listen for an incoming connection.http://0.0.0.0:8080: Binds the server to all available network interfaces on your computer on port 8080.
Step 2: Find Your Local IP Address
To connect from another device, you need the local IP address of the host computer running FFmpeg.
- Windows: Open Command Prompt and type
ipconfig. Look for the “IPv4 Address” under your active network adapter (e.g.,192.168.1.5). - macOS/Linux: Open Terminal and type
ifconfigorip route. Look for your local IP address.
Step 3: Receive and Play the Stream
Once the FFmpeg command is running, it will wait for a client to connect. You can open the stream on any device connected to the same local network.
Open a media player that supports network streams, such as VLC Media Player.
Go to Media > Open Network Stream (or press
Ctrl+N).Enter the URL using your host computer’s local IP address and the port specified in the FFmpeg command:
http://[YOUR_IP_ADDRESS]:8080(e.g.,http://192.168.1.5:8080)Click Play. FFmpeg will immediately begin processing and streaming the video to your player.