Changes between Version 3 and Version 4 of FFprobeTips


Ignore:
Timestamp:
Apr 13, 2015, 6:54:21 AM (4 years ago)
Author:
llogan
Comment:

simplify

Legend:

Unmodified
Added
Removed
Modified
  • FFprobeTips

    v3 v4  
    2020
    2121{{{
    22 $ ffprobe -v error -show_format input.mkv
     22$ ffprobe -v error -show_format -show_streams input.mp4
     23[STREAM]
     24index=0
     25codec_name=h264
     26codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
     27profile=High
     28codec_type=video
     29codec_time_base=1/50
     30codec_tag_string=avc1
     31codec_tag=0x31637661
     32width=320
     33height=240
     34has_b_frames=2
     35sample_aspect_ratio=1:1
     36display_aspect_ratio=4:3
     37pix_fmt=yuv420p
     38level=13
     39color_range=N/A
     40color_space=unknown
     41color_transfer=unknown
     42color_primaries=unknown
     43chroma_location=left
     44timecode=N/A
     45refs=4
     46is_avc=1
     47nal_length_size=4
     48id=N/A
     49r_frame_rate=25/1
     50avg_frame_rate=25/1
     51time_base=1/12800
     52start_pts=0
     53start_time=0.000000
     54duration_ts=384000
     55duration=30.000000
     56bit_rate=34761
     57max_bit_rate=N/A
     58bits_per_raw_sample=8
     59nb_frames=750
     60nb_read_frames=N/A
     61nb_read_packets=N/A
     62DISPOSITION:default=1
     63DISPOSITION:dub=0
     64DISPOSITION:original=0
     65DISPOSITION:comment=0
     66DISPOSITION:lyrics=0
     67DISPOSITION:karaoke=0
     68DISPOSITION:forced=0
     69DISPOSITION:hearing_impaired=0
     70DISPOSITION:visual_impaired=0
     71DISPOSITION:clean_effects=0
     72DISPOSITION:attached_pic=0
     73TAG:language=und
     74TAG:handler_name=VideoHandler
     75[/STREAM]
     76[STREAM]
     77index=1
     78codec_name=aac
     79codec_long_name=AAC (Advanced Audio Coding)
     80profile=LC
     81codec_type=audio
     82codec_time_base=1/44100
     83codec_tag_string=mp4a
     84codec_tag=0x6134706d
     85sample_fmt=fltp
     86sample_rate=44100
     87channels=1
     88channel_layout=mono
     89bits_per_sample=0
     90id=N/A
     91r_frame_rate=0/0
     92avg_frame_rate=0/0
     93time_base=1/44100
     94start_pts=-1024
     95start_time=-0.023220
     96duration_ts=1324024
     97duration=30.023220
     98bit_rate=56517
     99max_bit_rate=N/A
     100bits_per_raw_sample=N/A
     101nb_frames=1293
     102nb_read_frames=N/A
     103nb_read_packets=N/A
     104DISPOSITION:default=1
     105DISPOSITION:dub=0
     106DISPOSITION:original=0
     107DISPOSITION:comment=0
     108DISPOSITION:lyrics=0
     109DISPOSITION:karaoke=0
     110DISPOSITION:forced=0
     111DISPOSITION:hearing_impaired=0
     112DISPOSITION:visual_impaired=0
     113DISPOSITION:clean_effects=0
     114DISPOSITION:attached_pic=0
     115TAG:language=und
     116TAG:handler_name=SoundHandler
     117[/STREAM]
    23118[FORMAT]
    24 filename=input.mkv
     119filename=input.mp4
    25120nb_streams=2
    26121nb_programs=0
    27 format_name=matroska,webm
    28 format_long_name=Matroska / WebM
    29 start_time=0.000000
    30 duration=108.501000
    31 size=56164272
    32 bit_rate=4141106
     122format_name=mov,mp4,m4a,3gp,3g2,mj2
     123format_long_name=QuickTime / MOV
     124start_time=-0.023220
     125duration=30.024000
     126size=368644
     127bit_rate=98226
    33128probe_score=100
    34 TAG:encoder=libebml v0.7.7 + libmatroska v0.8.1
    35 TAG:creation_time=2008-10-22 06:43:30
     129TAG:major_brand=isom
     130TAG:minor_version=512
     131TAG:compatible_brands=isomiso2avc1mp41
     132TAG:title=FFprobe Tips
     133TAG:encoder=Lavf56.15.101
    36134[/FORMAT]
    37135}}}
    38136
    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
     137From 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
     140size=368644
     141}}}
     142
     143If 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
    58147}}}
    59148
    60149* `-v` sets the loglevel. `error` will omit the build and "generic" file information, but will allow errors to be shown in addition to the desired `ffprobe` output.
    61 * `-print_format` is useful to change the output format. Available formats are: default, compact, csv, flat, ini, json, xml.
     150* `-print_format` (or the alias `-of`) is useful to change the output format. Available formats are: default, compact, csv, flat, ini, json, xml.
    62151
    63152== Duration ==
    64153
    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
     154Format (container) duration:
     155
     156{{{
     157$ ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
     15830.024000
     159}}}
     160
     161Adding the `-sexagesimal` option will use the `HOURS:MM:SS.MICROSECONDS` time unit format:
     162
     163{{{
     1640:00:30.024000
     165}}}
     166
     167Duration 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
     17130.000000
    85172}}}
    86173
     
    90177
    91178{{{
    92 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
     179$ ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 input.mp4
    93180}}}
    94181
     
    109196
    110197== Width x Height ==
     198
     199Using `eval`:
    111200
    112201{{{