How to Find Codec Profile and Level with ffprobe

This guide explains how to extract the exact codec profile and level from any video or audio file using ffprobe, the media analysis tool included with FFmpeg. By targeting specific metadata fields within media streams, you can quickly retrieve crucial encoding parameters—such as H.264 High Profile Level 4.1 or HEVC Main 10—without parsing through extensive, irrelevant technical data.

Basic Command for Stream Metadata

To inspect the primary video stream and retrieve the codec name, profile, and level, run the following command in your terminal:

ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,profile,level -of default=noprint_wrappers=1 input.mp4

Command Breakdown

  • -v error: Suppresses default startup logs and warnings, displaying only the requested output or critical errors.
  • -select_streams v:0: Limits the query to the first video stream (v:0). Replace with a:0 if you are inspecting an audio stream (e.g., AAC profile).
  • -show_entries stream=codec_name,profile,level: Tells ffprobe to output only the codec, profile, and level properties instead of all stream metadata.
  • -of default=noprint_wrappers=1: Removes the standard [STREAM] and [/STREAM] header tags from the terminal output.

Understanding the Output

Running the command will produce output structured like this:

codec_name=h264
profile=High
level=41
  • codec_name: The compression standard used (e.g., h264, hevc, vp9).
  • profile: The feature set used during encoding (e.g., Baseline, Main, High, Main 10).
  • level: A numerical value defining the performance capabilities and limits (such as resolution, bitrate, and frame rate). Note that for H.264 and H.265/HEVC, levels are often represented as integers. For example, level=41 represents Level 4.1, while level=50 represents Level 5.0.

Extracting Values for Scripts (CSV or Flat Format)

If you are automating checks via shell scripts and need just the raw values without variable names, change the output format using the -of csv flag:

ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,profile,level -of csv=p=0 input.mp4

Output:

h264,High,41

Exporting as JSON

To integrate the results into modern applications or automated pipelines, format the output as JSON:

ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,profile,level -of json input.mp4

Output:

{
    "programs": [

    ],
    "streams": [
        {
            "codec_name": "h264",
            "profile": "High",
            "level": 41
        }
    ]
}