How to Use ffprobe to Find Codec Names and Profiles
This article explains how to use ffprobe, a powerful
command-line utility bundled with FFmpeg, to identify the exact codec
names and profiles of any video or audio file. You will learn the
specific command-line flags needed to target stream metadata, how to
output the results in a clean format, and how to structure the output in
JSON for scripting and automation.
The Basic Command for Video Codec and Profile
To find the codec name and profile of the primary video stream, use
the following ffprobe command in your terminal:
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,profile -of default=noprint_wrappers=1 input.mp4How this command works: * -v error:
Suppresses the default FFmpeg banner and configuration details, showing
only errors and your requested data. * -select_streams v:0:
Isolates the first video stream (use a:0 for the first
audio stream). * -show_entries stream=codec_name,profile:
Specifies that you only want to retrieve the codec_name and
profile fields. *
-of default=noprint_wrappers=1: Simplifies the output by
removing the outer format wrappers.
Example Output:
codec_name=h264
profile=High
Formatting the Output as JSON
If you are parsing the data in a script or prefer a more readable
format, you can instruct ffprobe to output the results in
JSON format:
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,profile -of json input.mp4Example Output:
{
"programs": [],
"streams": [
{
"codec_name": "h264",
"profile": "High"
}
]
}Finding Codecs and Profiles for All Streams
If your media file contains multiple streams (such as video, multiple audio tracks, and subtitles), you can retrieve the codec and profile information for all of them simultaneously.
Run the following command:
ffprobe -v error -show_entries stream=codec_type,codec_name,profile -of default=noprint_wrappers=1 input.mp4Example Output:
codec_name=h264
profile=High
codec_type=video
codec_name=aac
profile=LC
codec_type=audio
Including codec_type in the entries allows you to
quickly distinguish which codec and profile belong to the video stream
versus the audio stream.