Configure FFmpeg RTMP AMF Metadata
This article explains how to configure Action Message Format (AMF) metadata when streaming via RTMP using FFmpeg. You will learn how to add custom metadata fields, modify default stream information, and disable the metadata payload entirely to resolve compatibility issues with specific media servers and players.
Understanding RTMP AMF Metadata
When FFmpeg initiates an RTMP stream, it packages audio and video
data inside an FLV (Flash Video) container format. Before sending the
actual media packets, FFmpeg transmits an onMetaData packet
encoded in AMF. This packet contains essential stream properties such as
video width, height, frame rate, and audio sample rate, which help the
receiving player decode the stream properly.
Adding and Modifying AMF Metadata
FFmpeg allows you to inject custom string values into the AMF
onMetaData packet using the global -metadata
option. The FLV muxer automatically translates these key-value pairs
into AMF metadata properties.
To add custom metadata such as a stream title or creator name, use the following syntax:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f flv -metadata title="My Live Stream" -metadata creator="FFmpeg Encoder" rtmp://your-server-url/live/stream_keyCommon standard metadata keys supported by the FLV muxer include: *
title * author / creator *
copyright * description
Disabling the AMF Metadata Packet
Some players, legacy decoders, or specific CDN ingestion endpoints
fail to process or crash when they receive the onMetaData
AMF packet. If you experience connection drops immediately after the
handshake, you can instruct FFmpeg to omit this packet entirely.
To disable the metadata packet, apply the no_metadata
flag to the -flvflags private option:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f flv -flvflags no_metadata rtmp://your-server-url/live/stream_keyUsing this flag prevents the generation of the
@setDataFrame and onMetaData AMF objects,
sending only the raw audio and video streams.
Injecting Custom AMF Objects (Advanced)
By default, FFmpeg maps all command-line metadata to AMF string
types. If your destination server requires specific boolean or numeric
AMF types that cannot be set via the standard -metadata
flag, you must use an external script or a dedicated RTMP broker to
modify the raw RTMP handshaking packets, as FFmpeg’s command-line
interface does not natively support strict AMF type casting for custom
fields.