How to Use FFmpeg DASH Muxer with Custom HTTP Headers
This article explains how to configure the FFmpeg DASH (Dynamic Adaptive Streaming over HTTP) muxer to output streams to remote servers using customized HTTP requests. You will learn how to set custom HTTP headers, define the upload method, modify the User-Agent, and successfully stream or upload your DASH manifests and media segments to a secured or customized web server.
Understanding the FFmpeg DASH HTTP Output
When streaming using the DASH muxer (-f dash) to an HTTP
destination, FFmpeg utilizes its internal HTTP protocol handler to
upload the .mpd manifest file and the media segments
(.m4s or .tmp files).
By default, FFmpeg uses standard HTTP POST or PUT requests to upload these files. However, many modern streaming servers, Content Delivery Networks (CDNs), and cloud storage APIs require customized HTTP headers for authentication, content-type specification, or tracking.
Specifying Custom HTTP Headers
To inject custom HTTP headers into the requests sent by the DASH
muxer, you must use the -headers option.
Single Custom Header Example
If you only need to send a single header, such as an authorization token, you can pass it directly as a string:
ffmpeg -re -i input.mp4 \
-c:v libx264 -c:a aac \
-f dash \
-method PUT \
-headers "Authorization: Bearer YOUR_ACCESS_TOKEN" \
http://yourserver.com/live/manifest.mpdMultiple Custom Headers Example
When defining multiple headers, each header must be separated by a
Carriage Return and Line Feed (\r\n). In terminal
environments, you must escape or format this correctly:
ffmpeg -re -i input.mp4 \
-c:v libx264 -c:a aac \
-f dash \
-method PUT \
-headers "Authorization: Bearer YOUR_ACCESS_TOKEN"$'\r\n'"X-Custom-Header: CustomValue" \
http://yourserver.com/live/manifest.mpdNote: The $'\r\n' syntax is highly compatible with
Bash shells. If you are writing a script in another language or platform
(like Windows CMD), ensure the string contains literal CRLF
characters.
Customizing the User-Agent and Content Type
FFmpeg allows you to customize the User-Agent header
using either the -headers option or the dedicated
-user_agent parameter.
Using the dedicated parameter is cleaner if you only need to change the User-Agent:
ffmpeg -re -i input.mp4 \
-c:v libx264 -c:a aac \
-f dash \
-method PUT \
-user_agent "MyCustomStreamingClient/1.0" \
http://yourserver.com/live/manifest.mpdIf you need to change the Content-Type for the uploaded
segments, you can do so through the -headers argument:
ffmpeg -re -i input.mp4 \
-c:v libx264 -c:a aac \
-f dash \
-method PUT \
-headers "Content-Type: video/iso.segment" \
http://yourserver.com/live/manifest.mpdKey DASH Muxer Options for HTTP Uploads
When customizing your HTTP requests, ensure the following DASH-specific flags are configured to optimize the upload workflow:
-method PUTor-method POST: Explicitly defines the HTTP method used to upload segments. Most web servers receiving DASH streams requirePUT.-http_persistent 1: Keeps the HTTP connection open across multiple segment uploads. This drastically reduces TLS/TCP handshake overhead.-lhls 1: Enables Low-Latency HLS/DASH compatibility if your custom HTTP endpoint supports chunked transfer encoding.