Answers.Body: <p>The order in which sections are printed is hard-coded and insensitive to user specification.</p>
  <p>This is the layout in the source.</p>
  <pre><code>if (do_read_frames || do_read_packets) {
  ...
  }
  
  if (do_show_programs) {
  ...
  }
  
  if (do_show_streams) {
  ...
  }
  if (do_show_chapters) {
  ...
  }
  if (do_show_format) {
  ...
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-02T04:19:59.737Z
Answers.LastActivityDate: 2023-05-02T04:19:59.737Z
Answers.UserDisplayName: Gyan
Body: <p>How can I change the output order of FFprobe?</p>
  <p><code>ffprobe -hide_banner -show_streams -show_format space.mkv -of json=c=0 -o output.json</code> creates a json output file with the <code>streams</code> sections first and the <code>format</code> section last.</p>
  <p>I need the reverse order (<code>format</code> section first, <code>streams</code> section last).</p>
  <p>But reordering the parameters (i.e. <code>-show_format -show_streams</code>) has no effect unfortunately.</p>
  <p>This is the output of the command above:</p>
  <pre><code>{
      &quot;streams&quot;: [
          {
              &quot;index&quot;: 0,
              &quot;codec_name&quot;: &quot;h264&quot;,
              &quot;codec_long_name&quot;: &quot;H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10&quot;,
              &quot;profile&quot;: &quot;Main&quot;,
              &quot;codec_type&quot;: &quot;video&quot;,
              &quot;codec_tag_string&quot;: &quot;[0][0][0][0]&quot;,
              &quot;codec_tag&quot;: &quot;0x0000&quot;,
              &quot;width&quot;: 256,
              &quot;height&quot;: 144,
              &quot;coded_width&quot;: 256,
              &quot;coded_height&quot;: 144,
              &quot;closed_captions&quot;: 0,
              &quot;film_grain&quot;: 0,
              &quot;has_b_frames&quot;: 1,
              &quot;sample_aspect_ratio&quot;: &quot;1:1&quot;,
              &quot;display_aspect_ratio&quot;: &quot;16:9&quot;,
              &quot;pix_fmt&quot;: &quot;yuv420p&quot;,
              &quot;level&quot;: 11,
              &quot;color_range&quot;: &quot;tv&quot;,
              &quot;color_space&quot;: &quot;bt709&quot;,
              &quot;color_transfer&quot;: &quot;bt709&quot;,
              &quot;color_primaries&quot;: &quot;bt709&quot;,
              &quot;chroma_location&quot;: &quot;left&quot;,
              &quot;field_order&quot;: &quot;progressive&quot;,
              &quot;refs&quot;: 1,
              &quot;is_avc&quot;: &quot;true&quot;,
              &quot;nal_length_size&quot;: &quot;4&quot;,
              &quot;r_frame_rate&quot;: &quot;3737/250&quot;,
              &quot;avg_frame_rate&quot;: &quot;3737/250&quot;,
              &quot;time_base&quot;: &quot;1/1000&quot;,
              &quot;start_pts&quot;: 0,
              &quot;start_time&quot;: &quot;0.000000&quot;,
              &quot;bits_per_raw_sample&quot;: &quot;8&quot;,
              &quot;extradata_size&quot;: 41,
              &quot;disposition&quot;: {
                  &quot;default&quot;: 1,
                  &quot;dub&quot;: 0,
                  &quot;original&quot;: 0,
                  &quot;comment&quot;: 0,
                  &quot;lyrics&quot;: 0,
                  &quot;karaoke&quot;: 0,
                  &quot;forced&quot;: 0,
                  &quot;hearing_impaired&quot;: 0,
                  &quot;visual_impaired&quot;: 0,
                  &quot;clean_effects&quot;: 0,
                  &quot;attached_pic&quot;: 0,
                  &quot;timed_thumbnails&quot;: 0,
                  &quot;captions&quot;: 0,
                  &quot;descriptions&quot;: 0,
                  &quot;metadata&quot;: 0,
                  &quot;dependent&quot;: 0,
                  &quot;still_image&quot;: 0
              },
              &quot;tags&quot;: {
                  &quot;HANDLER_NAME&quot;: &quot;ISO Media file produced by Google Inc.&quot;,
                  &quot;VENDOR_ID&quot;: &quot;[0][0][0][0]&quot;,
                  &quot;DURATION&quot;: &quot;00:10:53.276000000&quot;
              }
          },
          {
              &quot;index&quot;: 1,
              &quot;codec_name&quot;: &quot;aac&quot;,
              &quot;codec_long_name&quot;: &quot;AAC (Advanced Audio Coding)&quot;,
              &quot;profile&quot;: &quot;HE-AAC&quot;,
              &quot;codec_type&quot;: &quot;audio&quot;,
              &quot;codec_tag_string&quot;: &quot;[0][0][0][0]&quot;,
              &quot;codec_tag&quot;: &quot;0x0000&quot;,
              &quot;sample_fmt&quot;: &quot;fltp&quot;,
              &quot;sample_rate&quot;: &quot;44100&quot;,
              &quot;channels&quot;: 2,
              &quot;channel_layout&quot;: &quot;stereo&quot;,
              &quot;bits_per_sample&quot;: 0,
              &quot;initial_padding&quot;: 0,
              &quot;r_frame_rate&quot;: &quot;0/0&quot;,
              &quot;avg_frame_rate&quot;: &quot;0/0&quot;,
              &quot;time_base&quot;: &quot;1/1000&quot;,
              &quot;start_pts&quot;: 0,
              &quot;start_time&quot;: &quot;0.000000&quot;,
              &quot;extradata_size&quot;: 25,
              &quot;disposition&quot;: {
                  &quot;default&quot;: 1,
                  &quot;dub&quot;: 0,
                  &quot;original&quot;: 0,
                  &quot;comment&quot;: 0,
                  &quot;lyrics&quot;: 0,
                  &quot;karaoke&quot;: 0,
                  &quot;forced&quot;: 0,
                  &quot;hearing_impaired&quot;: 0,
                  &quot;visual_impaired&quot;: 0,
                  &quot;clean_effects&quot;: 0,
                  &quot;attached_pic&quot;: 0,
                  &quot;timed_thumbnails&quot;: 0,
                  &quot;captions&quot;: 0,
                  &quot;descriptions&quot;: 0,
                  &quot;metadata&quot;: 0,
                  &quot;dependent&quot;: 0,
                  &quot;still_image&quot;: 0
              },
              &quot;tags&quot;: {
                  &quot;HANDLER_NAME&quot;: &quot;ISO Media file produced by Google Inc.&quot;,
                  &quot;VENDOR_ID&quot;: &quot;[0][0][0][0]&quot;,
                  &quot;DURATION&quot;: &quot;00:10:53.409000000&quot;
              }
          }
      ],
      &quot;format&quot;: {
          &quot;filename&quot;: &quot;space.mkv&quot;,
          &quot;nb_streams&quot;: 2,
          &quot;nb_programs&quot;: 0,
          &quot;format_name&quot;: &quot;matroska,webm&quot;,
          &quot;format_long_name&quot;: &quot;Matroska / WebM&quot;,
          &quot;start_time&quot;: &quot;0.000000&quot;,
          &quot;duration&quot;: &quot;653.409000&quot;,
          &quot;size&quot;: &quot;5252652&quot;,
          &quot;bit_rate&quot;: &quot;64310&quot;,
          &quot;probe_score&quot;: 100,
          &quot;tags&quot;: {
              &quot;title&quot;: &quot;SpaceX Starship explodes on first launch attempt&quot;,
              &quot;COMMENT&quot;: &quot;https://www.youtube.com/watch?v=gk1BViilFFk&quot;,
              &quot;COMPATIBLE_BRANDS&quot;: &quot;iso6avc1mp41&quot;,
              &quot;MAJOR_BRAND&quot;: &quot;dash&quot;,
              &quot;MINOR_VERSION&quot;: &quot;0&quot;,
              &quot;ARTIST&quot;: &quot;CNN&quot;,
              &quot;DATE&quot;: &quot;20230420&quot;,
              &quot;DESCRIPTION&quot;: &quot;SpaceX’s Starship, the most powerful rocket ever built, took off from a launch pad on the coast of South Texas, but exploded midair before stage separation. #CNN #News&quot;,
              &quot;SYNOPSIS&quot;: &quot;SpaceX’s Starship, the most powerful rocket ever built, took off from a launch pad on the coast of South Texas, but exploded midair before stage separation. #CNN #News&quot;,
              &quot;PURL&quot;: &quot;https://www.youtube.com/watch?v=gk1BViilFFk&quot;,
              &quot;ENCODER&quot;: &quot;Lavf60.4.101&quot;
          }
      }
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-01T11:33:20.980Z
Comments.Text: The order is hardcoded :(
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-01T13:09:05.827Z
Comments.Text: If you know this to be the case (and as a bonus can demonstrate it), please post this as an answer. Assuming there is no way to change the result with FFprobe itself, I will accept this as the correct answer.
Comments.UserDisplayName: summerrain
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-02T00:46:43.400Z
Comments.Text: Why downvote? This is an important question for me.
Comments.UserDisplayName: summerrain
Tags: <ffmpeg><formats><ffprobe>
Title: change output order of FFprobe
UserDisplayName: summerrain
ThreadText: # change output order of FFprobe
  
  (Asked by: username_0 on 2023-04-28)
  
  How can I change the output order of FFprobe?
  
  `ffprobe -hide_banner -show_streams -show_format space.mkv -of json=c=0 -o output.json` creates a json output file with the `streams` sections first and the `format` section last.
  
  I need the reverse order (`format` section first, `streams` section last).
  
  But reordering the parameters (i.e. `-show_format -show_streams`) has no effect unfortunately.
  
  This is the output of the command above:
  
  ```
  {
      "streams": [
          {
              "index": 0,
              "codec_name": "h264",
              "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
              "profile": "Main",
              "codec_type": "video",
              "codec_tag_string": "[0][0][0][0]",
              "codec_tag": "0x0000",
              "width": 256,
              "height": 144,
              "coded_width": 256,
              "coded_height": 144,
              "closed_captions": 0,
              "film_grain": 0,
              "has_b_frames": 1,
              "sample_aspect_ratio": "1:1",
              "display_aspect_ratio": "16:9",
              "pix_fmt": "yuv420p",
              "level": 11,
              "color_range": "tv",
              "color_space": "bt709",
              "color_transfer": "bt709",
              "color_primaries": "bt709",
              "chroma_location": "left",
              "field_order": "progressive",
              "refs": 1,
              "is_avc": "true",
              "nal_length_size": "4",
              "r_frame_rate": "3737/250",
              "avg_frame_rate": "3737/250",
              "time_base": "1/1000",
              "start_pts": 0,
              "start_time": "0.000000",
              "bits_per_raw_sample": "8",
              "extradata_size": 41,
              "disposition": {
                  "default": 1,
                  "dub": 0,
                  "original": 0,
                  "comment": 0,
                  "lyrics": 0,
                  "karaoke": 0,
                  "forced": 0,
                  "hearing_impaired": 0,
                  "visual_impaired": 0,
                  "clean_effects": 0,
                  "attached_pic": 0,
                  "timed_thumbnails": 0,
                  "captions": 0,
                  "descriptions": 0,
                  "metadata": 0,
                  "dependent": 0,
                  "still_image": 0
              },
              "tags": {
                  "HANDLER_NAME": "ISO Media file produced by Google Inc.",
                  "VENDOR_ID": "[0][0][0][0]",
                  "DURATION": "00:10:53.276000000"
              }
          },
          {
              "index": 1,
              "codec_name": "aac",
              "codec_long_name": "AAC (Advanced Audio Coding)",
              "profile": "HE-AAC",
              "codec_type": "audio",
              "codec_tag_string": "[0][0][0][0]",
              "codec_tag": "0x0000",
              "sample_fmt": "fltp",
              "sample_rate": "44100",
              "channels": 2,
              "channel_layout": "stereo",
              "bits_per_sample": 0,
              "initial_padding": 0,
              "r_frame_rate": "0/0",
              "avg_frame_rate": "0/0",
              "time_base": "1/1000",
              "start_pts": 0,
              "start_time": "0.000000",
              "extradata_size": 25,
              "disposition": {
                  "default": 1,
                  "dub": 0,
                  "original": 0,
                  "comment": 0,
                  "lyrics": 0,
                  "karaoke": 0,
                  "forced": 0,
                  "hearing_impaired": 0,
                  "visual_impaired": 0,
                  "clean_effects": 0,
                  "attached_pic": 0,
                  "timed_thumbnails": 0,
                  "captions": 0,
                  "descriptions": 0,
                  "metadata": 0,
                  "dependent": 0,
                  "still_image": 0
              },
              "tags": {
                  "HANDLER_NAME": "ISO Media file produced by Google Inc.",
                  "VENDOR_ID": "[0][0][0][0]",
                  "DURATION": "00:10:53.409000000"
              }
          }
      ],
      "format": {
          "filename": "space.mkv",
          "nb_streams": 2,
          "nb_programs": 0,
          "format_name": "matroska,webm",
          "format_long_name": "Matroska / WebM",
          "start_time": "0.000000",
          "duration": "653.409000",
          "size": "5252652",
          "bit_rate": "64310",
          "probe_score": 100,
          "tags": {
              "title": "SpaceX Starship explodes on first launch attempt",
              "COMMENT": "https://www.youtube.com/watch?v=gk1BViilFFk",
              "COMPATIBLE_BRANDS": "iso6avc1mp41",
              "MAJOR_BRAND": "dash",
              "MINOR_VERSION": "0",
              "ARTIST": "CNN",
              "DATE": "20230420",
              "DESCRIPTION": "SpaceX’s Starship, the most powerful rocket ever built, took off from a launch pad on the coast of South Texas, but exploded midair before stage separation. #CNN #News",
              "SYNOPSIS": "SpaceX’s Starship, the most powerful rocket ever built, took off from a launch pad on the coast of South Texas, but exploded midair before stage separation. #CNN #News",
              "PURL": "https://www.youtube.com/watch?v=gk1BViilFFk",
              "ENCODER": "Lavf60.4.101"
          }
      }
  }
  
  ```
  
  **Tags:** ffmpeg, formats, ffprobe
  
  > **Comments:**
  > **username_1**: The order is hardcoded :(  
  > **username_0**: If you know this to be the case (and as a bonus can demonstrate it), please post this as an answer. Assuming there is no way to change the result with FFprobe itself, I will accept this as the correct answer.  
  > **username_0**: Why downvote? This is an important question for me.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-05-02. Score: 2
  
  The order in which sections are printed is hard-coded and insensitive to user specification.
  
  This is the layout in the source.
  
  ```
  if (do_read_frames || do_read_packets) {
  ...
  }
  
  if (do_show_programs) {
  ...
  }
  
  if (do_show_streams) {
  ...
  }
  if (do_show_chapters) {
  ...
  }
  if (do_show_format) {
  ...
  }
  
  ```
  
  
  ---
  
  