Skip to content

Instantly share code, notes, and snippets.

@nrk
Created April 2, 2012 19:19
Show Gist options
  • Save nrk/2286511 to your computer and use it in GitHub Desktop.
Save nrk/2286511 to your computer and use it in GitHub Desktop.
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"
}
}
}
@duffxp
Copy link

duffxp commented May 6, 2022

Hello.

Great list! However, does anyone know how to find the duration of stream (HLS or MPEG-DASH) segments?

@daiplusplus
Copy link

daiplusplus commented Jun 8, 2022

@quintanaplaca I believe that information is in the .m3u8 file's #EXTINF tags, and not the segment blob (while a segment blob will have a duration, I think (though am uncertain) that clients will prefer timing data from the m3u8 file as that's more canonical.... or something. YMMV. IANAL. Etc.

To quote Apple: https://developer.apple.com/documentation/http_live_streaming/example_playlists_for_http_live_streaming/video_on_demand_playlist_construction (emphasis mine)

#EXTINF: A record marker that describes the media file identified by the URL that follows it. Each media file URL must be preceded by an EXTINF tag. This tag contains a duration attribute that's an integer or floating-point number in decimal positional notation that specifies the duration of the media segment in seconds. This value must be less than or equal to the target duration.

@duffxp
Copy link

duffxp commented Jun 10, 2022

@Jehoel, thank you for your reply. Really, you are right. I would like a way to analyze HLS and MPEG-DASH stream with FFmpeg (the segmentSize, segmentDuration) and check its integrity.

@irzhywau
Copy link

irzhywau commented Sep 7, 2023

is there a way to grab these informations using one of library provided by ffmpeg using C?

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