Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using ffprobe to get info from a file in a nice JSON format
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"codec_type": "video",
"codec_time_base": "1001/48000",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 1280,
"height": 720,
"has_b_frames": 0,
"pix_fmt": "yuv420p",
"level": 31,
"is_avc": "1",
"nal_length_size": "4",
"r_frame_rate": "35029/1461",
"avg_frame_rate": "35029/1461",
"time_base": "1/35029",
"start_time": "0.000000",
"duration": "1239.195267",
"bit_rate": "1782423",
"nb_frames": "29711",
"tags": {
"creation_time": "1970-01-01 00:00:00",
"language": "und",
"handler_name": "VideoHandler"
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "Advanced Audio Coding",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "s16",
"sample_rate": "48000",
"channels": 2,
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"start_time": "0.000000",
"duration": "1239.059396",
"bit_rate": "127966",
"nb_frames": "58081",
"tags": {
"creation_time": "2012-04-01 15:42:28",
"language": "jpn",
"handler_name": "GPAC ISO Audio Handler"
}
}
],
"format": {
"filename": "lolwut.mp4",
"nb_streams": 2,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime/MPEG-4/Motion JPEG 2000 format",
"start_time": "0.000000",
"duration": "1239.195000",
"size": "296323860",
"bit_rate": "1913008",
"tags": {
"major_brand": "isom",
"minor_version": "1",
"compatible_brands": "isom",
"creation_time": "2012-04-01 15:42:24"
}
}
}
@reinaldo
Copy link

reinaldo commented Jun 6, 2013

Perfect :)

@emanuelgaspar
Copy link

emanuelgaspar commented Aug 1, 2013

This is just brilliant. Obrigado!

@GregIngelmo
Copy link

GregIngelmo commented Sep 25, 2013

Awesome!

@dustinrjo
Copy link

dustinrjo commented Feb 7, 2014

sweet

@amalgamatedclyde
Copy link

amalgamatedclyde commented Sep 20, 2014

soooo grateful!

@croespino
Copy link

croespino commented Jan 17, 2015

Thanks!

@estabij
Copy link

estabij commented Nov 15, 2015

thanks

@hebertreis
Copy link

hebertreis commented Dec 2, 2015

Great!

@kdresser
Copy link

kdresser commented Aug 14, 2016

Thank you!

@nasermirzaei89
Copy link

nasermirzaei89 commented Oct 4, 2016

how can i get ID3v2 frames?

http://id3.org/id3v2.3.0

@TeamKitsune
Copy link

TeamKitsune commented Mar 16, 2017

Thanks for this. Works for xml as well.

@mikkorantalainen
Copy link

mikkorantalainen commented May 18, 2018

I'd suggest

ffprobe -hide_banner -loglevel fatal -show_error -show_format -show_streams -show_programs -show_chapters -show_private_data -print_format json

because that allows getting possible error messages as JSON, too. In addition, that allows getting more information about the file.

@Casxt
Copy link

Casxt commented Mar 5, 2019

I'd suggest

ffprobe -hide_banner -loglevel fatal -show_error -show_format -show_streams -show_programs -show_chapters -show_private_data -print_format json

because that allows getting possible error messages as JSON, too. In addition, that allows getting more information about the file.

thanks!

@vamsigarla
Copy link

vamsigarla commented Nov 4, 2019

thanks bro...!

@novcod
Copy link

novcod commented Mar 3, 2020

Thanks !

@ToshY
Copy link

ToshY commented May 7, 2020

Thanks

@suyog711
Copy link

suyog711 commented Dec 31, 2020

do we get the size in bytes using ffprobe?

@Xonshiz
Copy link

Xonshiz commented Sep 12, 2021

If you run the very first command mentioned in this gist, you'll see "size" key/property in the JSON result. It's already in bytes.

@chapmanjacobd
Copy link

chapmanjacobd commented Dec 5, 2021

ffprobe -loglevel quiet -sexagesimal -print_format json=compact=1 -show_entries error:stream:format

@eladkarako
Copy link

eladkarako commented Jan 15, 2022

  • -select_streams "s" for just subtitles. -select_streams "s:0" for just the first subtitle (index is zero based).
  • -find_stream_info fill-in missing information by actually read the streams instead of just parsing the header(s). it helps with corrupted files. optionally add -probesize "10000000" and -analyzeduration "2000000" as well, for better results.
  • -pretty a more human-readable output (works with other print formats as well, some builds have this on by default for JSON). it helps to debug stuff in console.
  • 2>/dev/null (linux) or 2>nul (Windows. note: the nul missing last l is intentional) to speed up the command, if you don't need output to console at all. you can keep whatever loglevel you currently have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment