| 22 | | $ ffprobe -v error -show_format input.mkv |
| | 22 | $ ffprobe -v error -show_format -show_streams input.mp4 |
| | 23 | [STREAM] |
| | 24 | index=0 |
| | 25 | codec_name=h264 |
| | 26 | codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 |
| | 27 | profile=High |
| | 28 | codec_type=video |
| | 29 | codec_time_base=1/50 |
| | 30 | codec_tag_string=avc1 |
| | 31 | codec_tag=0x31637661 |
| | 32 | width=320 |
| | 33 | height=240 |
| | 34 | has_b_frames=2 |
| | 35 | sample_aspect_ratio=1:1 |
| | 36 | display_aspect_ratio=4:3 |
| | 37 | pix_fmt=yuv420p |
| | 38 | level=13 |
| | 39 | color_range=N/A |
| | 40 | color_space=unknown |
| | 41 | color_transfer=unknown |
| | 42 | color_primaries=unknown |
| | 43 | chroma_location=left |
| | 44 | timecode=N/A |
| | 45 | refs=4 |
| | 46 | is_avc=1 |
| | 47 | nal_length_size=4 |
| | 48 | id=N/A |
| | 49 | r_frame_rate=25/1 |
| | 50 | avg_frame_rate=25/1 |
| | 51 | time_base=1/12800 |
| | 52 | start_pts=0 |
| | 53 | start_time=0.000000 |
| | 54 | duration_ts=384000 |
| | 55 | duration=30.000000 |
| | 56 | bit_rate=34761 |
| | 57 | max_bit_rate=N/A |
| | 58 | bits_per_raw_sample=8 |
| | 59 | nb_frames=750 |
| | 60 | nb_read_frames=N/A |
| | 61 | nb_read_packets=N/A |
| | 62 | DISPOSITION:default=1 |
| | 63 | DISPOSITION:dub=0 |
| | 64 | DISPOSITION:original=0 |
| | 65 | DISPOSITION:comment=0 |
| | 66 | DISPOSITION:lyrics=0 |
| | 67 | DISPOSITION:karaoke=0 |
| | 68 | DISPOSITION:forced=0 |
| | 69 | DISPOSITION:hearing_impaired=0 |
| | 70 | DISPOSITION:visual_impaired=0 |
| | 71 | DISPOSITION:clean_effects=0 |
| | 72 | DISPOSITION:attached_pic=0 |
| | 73 | TAG:language=und |
| | 74 | TAG:handler_name=VideoHandler |
| | 75 | [/STREAM] |
| | 76 | [STREAM] |
| | 77 | index=1 |
| | 78 | codec_name=aac |
| | 79 | codec_long_name=AAC (Advanced Audio Coding) |
| | 80 | profile=LC |
| | 81 | codec_type=audio |
| | 82 | codec_time_base=1/44100 |
| | 83 | codec_tag_string=mp4a |
| | 84 | codec_tag=0x6134706d |
| | 85 | sample_fmt=fltp |
| | 86 | sample_rate=44100 |
| | 87 | channels=1 |
| | 88 | channel_layout=mono |
| | 89 | bits_per_sample=0 |
| | 90 | id=N/A |
| | 91 | r_frame_rate=0/0 |
| | 92 | avg_frame_rate=0/0 |
| | 93 | time_base=1/44100 |
| | 94 | start_pts=-1024 |
| | 95 | start_time=-0.023220 |
| | 96 | duration_ts=1324024 |
| | 97 | duration=30.023220 |
| | 98 | bit_rate=56517 |
| | 99 | max_bit_rate=N/A |
| | 100 | bits_per_raw_sample=N/A |
| | 101 | nb_frames=1293 |
| | 102 | nb_read_frames=N/A |
| | 103 | nb_read_packets=N/A |
| | 104 | DISPOSITION:default=1 |
| | 105 | DISPOSITION:dub=0 |
| | 106 | DISPOSITION:original=0 |
| | 107 | DISPOSITION:comment=0 |
| | 108 | DISPOSITION:lyrics=0 |
| | 109 | DISPOSITION:karaoke=0 |
| | 110 | DISPOSITION:forced=0 |
| | 111 | DISPOSITION:hearing_impaired=0 |
| | 112 | DISPOSITION:visual_impaired=0 |
| | 113 | DISPOSITION:clean_effects=0 |
| | 114 | DISPOSITION:attached_pic=0 |
| | 115 | TAG:language=und |
| | 116 | TAG:handler_name=SoundHandler |
| | 117 | [/STREAM] |
| 39 | | If you only want `size=56164272` you can add `grep`: |
| 40 | | |
| 41 | | {{{ |
| 42 | | $ ffprobe -v error -show_format input.mkv | grep size |
| 43 | | size=56164272 |
| 44 | | }}} |
| 45 | | |
| 46 | | There are several methods to get only the value such as by using `awk`: |
| 47 | | |
| 48 | | {{{ |
| 49 | | $ ffprobe -v error -show_format input.mkv | awk -F= '/size/{print $NF}' |
| 50 | | 56164272 |
| 51 | | }}} |
| 52 | | |
| 53 | | Or with `eval` and `echo`: |
| 54 | | |
| 55 | | {{{ |
| 56 | | eval $(ffprobe -v error -show_format -show_entries format=size -of flat=s=_ input.mkv); echo $format_size |
| 57 | | 56164272 |
| | 137 | From the above example, if you would only want `size=368644`: |
| | 138 | {{{ |
| | 139 | $ ffprobe -v error -show_entries format=size -of default=noprint_wrappers=1 input.mp4 |
| | 140 | size=368644 |
| | 141 | }}} |
| | 142 | |
| | 143 | If you would only want the value with no key: |
| | 144 | |
| | 145 | {{{ |
| | 146 | $ ffprobe -v error -show_entries format=size -of default=noprint_wrappers=1:nokey=1 input.mp4 |
| 65 | | {{{ |
| 66 | | eval $(ffprobe -v error -show_format -of flat=s=_ input.mkv | grep format_duration); echo $format_duration |
| 67 | | }}} |
| 68 | | |
| 69 | | Alternatively you can omit `grep` by using the `-show_entries` option: |
| 70 | | |
| 71 | | {{{ |
| 72 | | eval $(ffprobe -v error -show_format -of flat=s=_ -show_entries format=duration input.mkv); echo $format_duration |
| 73 | | }}} |
| 74 | | |
| 75 | | Example output in seconds: |
| 76 | | |
| 77 | | {{{ |
| 78 | | 108.501000 |
| 79 | | }}} |
| 80 | | |
| 81 | | Adding the `-sexagesimal` option will use the `HOURS:MM:SS.MICROSECONDS` time unit format such as: |
| 82 | | |
| 83 | | {{{ |
| 84 | | 0:01:48.501000 |
| | 154 | Format (container) duration: |
| | 155 | |
| | 156 | {{{ |
| | 157 | $ ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4 |
| | 158 | 30.024000 |
| | 159 | }}} |
| | 160 | |
| | 161 | Adding the `-sexagesimal` option will use the `HOURS:MM:SS.MICROSECONDS` time unit format: |
| | 162 | |
| | 163 | {{{ |
| | 164 | 0:00:30.024000 |
| | 165 | }}} |
| | 166 | |
| | 167 | Duration of the first video stream: |
| | 168 | |
| | 169 | {{{ |
| | 170 | $ ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 input.mp4 |
| | 171 | 30.000000 |