How to Configure XML Output in FFprobe

FFprobe allows you to export media analysis data into structured XML format using its built-in writer system. This guide covers how to set the XML output format, configure specific formatting parameters like schema qualification and XSD strictness, and structure commands for automated workflows.

Setting the Output Writer to XML

To generate XML output, use the -print_format flag or its alias -of followed by xml. A basic command to extract stream and container information looks like this:

ffprobe -v error -show_format -show_streams -of xml input.mp4

XML Formatting Parameters

FFprobe provides two specific parameters to customize the structure and validation compliance of its XML output:

  1. fully_qualified (short flag: q)
    • Values: 1 (enabled) or 0 (disabled). Default is 0.
    • Description: When enabled, the generated XML root element includes standard XML namespace declarations (xmlns:xsi and xsi:schemaLocation) pointing to the official FFprobe schema definition.
  2. xsd_strict (short flag: x)
    • Values: 1 (enabled) or 0 (disabled). Default is 0.
    • Description: Forces the XML output to strictly adhere to the FFprobe XSD schema, removing any non-compliant elements or formatting discrepancies. Setting this option automatically enables fully_qualified.

Syntax for Configuring Options

Options are appended directly to the xml writer name using an equals sign (=). If you are passing multiple parameters, separate them with a colon (:).

You can use the full parameter names:

ffprobe -v error -show_format -of xml=fully_qualified=1:xsd_strict=1 input.mp4

Or use the shortened parameter aliases for brevity:

ffprobe -v error -show_format -of xml=q=1:x=1 input.mp4

Saving the Output to an XML File

To redirect the generated XML to a file instead of displaying it in the terminal, use standard shell redirection or FFprobe's -o flag:

ffprobe -v error -show_format -show_streams -of xml=q=1:x=1 input.mp4 > output.xml

Alternatively:

ffprobe -v error -show_format -show_streams -of xml=q=1:x=1 -o output.xml input.mp4