FFmpeg provides command-line tools for inspecting multimedia files and extracting useful information about their streams. A single media file can contain multiple streams, such as video, audio, subtitles, or other data. Identifying these streams is helpful when analyzing a file, troubleshooting playback issues, or preparing media for further processing. This tutorial explains how to get a list of streams in a media file using FFmpeg.
The ffprobe utility can list the streams contained in a media file along with selected properties.
Download a sample file for testing:
curl -sSo test.mp4 https://raw.githubusercontent.com/chromium/chromium/main/media/test/data/bear-1280x720-avt_subt_frag.mp4
The following command extracts the index, codec name, and type of every stream:
ffprobe -v error -show_entries stream=index,codec_name,codec_type -of csv=p=0 test.mp4
The command produces output:
0,h264,video
1,aac,audio
2,mov_text,subtitle
Command breakdown:
ffprobe- inspects the media file and extracts information about its streams.-v error- suppresses informational and diagnostic messages, displaying only errors.-show_entries stream=index,codec_name,codec_type- requests the stream index, codec name, and stream type for each detected stream.-of csv=p=0- formats the output as comma-separated values and omits the field names from the result.test.mp4- specifies the media file to inspect.
Leave a Comment
Cancel reply