Push Live DASH Stream via HTTP POST in FFmpeg

This article explains how to stream live DASH (Dynamic Adaptive Streaming over HTTP) content directly to a remote web server using FFmpeg's HTTP POST method. You will learn the specific command-line arguments and parameters required to package a live video source into DASH segments and upload them to an ingestion server in real time.

The FFmpeg Command

To push a live DASH stream via HTTP POST, you must configure FFmpeg to use the dash muxer and set the HTTP transfer method to POST.

Here is the standard command-to-use template:

ffmpeg -re -i input.mp4 \
  -c:v libx264 -preset veryfast -b:v 3000k \
  -c:a aac -b:a 128k \
  -f dash \
  -method POST \
  -http_persistent 1 \
  -seg_duration 4 \
  -streaming 1 \
  -use_template 1 \
  -use_timeline 1 \
  http://yourserver.com/live/manifest.mpd

Parameter Breakdown

  • -re: Reads the input at the native frame rate. This is required for simulating a live stream from a pre-recorded file. If you are using a physical capture card or live camera feed, omit this option.
  • -f dash: Directs FFmpeg to format the output as a DASH stream.
  • -method POST: Explicitly instructs the underlying HTTP protocol to upload the manifest (.mpd) and segment files (.m4s) using HTTP POST requests. By default, FFmpeg may try to use HTTP PUT.
  • -http_persistent 1: Enables persistent HTTP connections (Keep-Alive). This keeps the TCP connection open across multiple segment uploads, significantly reducing latency and connection overhead.
  • -seg_duration 4: Sets the target segment length to 4 seconds. You can adjust this value to balance latency and playback stability.
  • -streaming 1: Enables chunked transfer encoding, allowing FFmpeg to post segments to the server as they are being encoded rather than waiting for the entire segment to finish.
  • -use_template 1 and -use_timeline 1: Optimizes the MPD manifest structure by using templates and timelines to reference media segments, reducing manifest file size overhead.

Server-Side Requirements

To successfully receive the stream, your target web server must be configured to handle incoming HTTP POST requests. The server must accept the incoming .mpd and .m4s payloads and write them to the designated directory in the web root so that players (such as Dash.js or Shaka Player) can fetch them via standard HTTP GET requests. Common setups include using an Nginx server with an upload module or a custom Node.js/Python receiver script.