FFmpeg Serialize Filter Guide
This guide explains how serialization works within the FFmpeg
filtergraph ecosystem, addressing the common search for a native
serialize filter. While FFmpeg does not include a
standalone filter explicitly named serialize, developers
frequently use serialization workflows to export frame-level metadata,
sequence filters in a serial pipeline, dynamically feed serial command
instructions, or output serialized raw data streams for external
processing. Below are the primary methods to implement serialization
tasks using FFmpeg's built-in tools.
Serializing Frame Metadata
To serialize frame-level metadata into a structured text stream or
file, use the metadata and showinfo filters.
This approach extracts internal frame attributes into key-value
pairs.
To print serialized metadata directly to the console or redirect it to a log file:
ffmpeg -i input.mp4 -vf "showinfo" -f null -To serialize and print specific metadata tags using the
metadata filter:
ffmpeg -i input.mp4 -vf "metadata=mode=print:key=lavfi.signalstats.YAVG:file=metadata_output.txt" -f null -Serializing Filter
Commands with sendcmd
When users refer to a "serialize filter" for executing a sequence of
commands over time, FFmpeg provides the sendcmd (video) and
asendcmd (audio) filters. These filters read serialized
command lists from a file or text string to alter downstream filter
properties dynamically at specific timestamps.
1. Create a
serialized command file (commands.txt)
0.0-5.0 drawtext reinit 'text=Part 1';
5.0-10.0 drawtext reinit 'text=Part 2';
2. Execute the serialized pipeline
ffmpeg -i input.mp4 -vf "sendcmd=f=commands.txt,drawtext=fontfile=font.ttf:text='':fontsize=24:x=10:y=10" output.mp4Serializing Multiple
Inputs with concat
If serialization refers to chaining video segments together
sequentially rather than processing them in parallel, use the
concat filter:
ffmpeg -i part1.mp4 -i part2.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" output.mp4This ensures that the two distinct streams are serialized into a single continuous stream.
Serializing Video Frames to an External Pipe
To serialize raw video frame data into an external process (such as a Python script, machine learning model, or Node.js pipeline):
ffmpeg -i input.mp4 -f rawvideo -pix_fmt rgb24 - | python3 process_stream.pyThis serializes uncompressed pixel arrays sequentially across
stdout, allowing external code to deserialize and read
fixed-size frame buffers in real time.