| Version 3 (modified by , 12 years ago) ( diff ) |
|---|
ffprobe is a simple multimedia streams analyzer. You can use it to output all kinds of information about an input including duration, frame rate, frame size, etc. It is also useful for gathering specific information about an input to be used in a script.
Usage
ffprobe [OPTIONS] [INPUT_FILE]
Show help
ffprobe -h
Scroll to the top of the console output and refer to "Main options" for the most important options.
Examples
Basic example
$ ffprobe -v error -show_format input.mkv [FORMAT] filename=input.mkv nb_streams=2 nb_programs=0 format_name=matroska,webm format_long_name=Matroska / WebM start_time=0.000000 duration=108.501000 size=56164272 bit_rate=4141106 probe_score=100 TAG:encoder=libebml v0.7.7 + libmatroska v0.8.1 TAG:creation_time=2008-10-22 06:43:30 [/FORMAT]
If you only want size=56164272 you can add grep:
$ ffprobe -v error -show_format input.mkv | grep size size=56164272
There are several methods to get only the value such as by using awk:
$ ffprobe -v error -show_format input.mkv | awk -F= '/size/{print $NF}'
56164272
Or with eval and echo:
eval $(ffprobe -v error -show_format -show_entries format=size -of flat=s=_ input.mkv); echo $format_size 56164272
-vsets the loglevel.errorwill omit the build and "generic" file information, but will allow errors to be shown in addition to the desiredffprobeoutput.-print_formatis useful to change the output format. Available formats are: default, compact, csv, flat, ini, json, xml.
Duration
eval $(ffprobe -v error -show_format -of flat=s=_ input.mkv | grep format_duration); echo $format_duration
Alternatively you can omit grep by using the -show_entries option:
eval $(ffprobe -v error -show_format -of flat=s=_ -show_entries format=duration input.mkv); echo $format_duration
Example output in seconds:
108.501000
Adding the -sexagesimal option will use the HOURS:MM:SS.MICROSECONDS time unit format such as:
0:01:48.501000
Frame Rate
This will provide the average frame rate for the first video stream.
eval $(ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=avg_frame_rate input.mkv); echo $streams_stream_0_avg_frame_rate
Example output for a NTSC-film video:
24000/1001
Example output for a PAL video:
25/1
- Some files can contain multiple video streams.
- Some streams may be variable frame rate.
Width x Height
eval $(ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width input.mkv)
size=${streams_stream_0_width}x${streams_stream_0_height}
echo $size
Example output:
1280x720


