Answers.Body: <p><a href="https://stackoverflow.com/questions/6014904/h264-frame-viewer">https://stackoverflow.com/questions/6014904/h264-frame-viewer</a> has some good answers. For example, <a href="https://github.com/shi-yan/H264Naked" rel="nofollow noreferrer">https://github.com/shi-yan/H264Naked</a> worked well when I tried it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-03T23:07:06.670Z
Answers.LastActivityDate: 2020-04-03T23:07:06.670Z
Answers.UserDisplayName: theicfire
Answers.Body: <p>You can use the trace_headers bitstream filter in ffmpeg</p>
  
  <pre><code>ffmpeg -i in.264 -c copy -bsf:v trace_headers -f null - 2&gt; NALUS.txt
  </code></pre>
  
  <p>The text file will have data like this,</p>
  
  <pre><code>[AVBSFContext @ 00000000027d3580] Packet: 102 bytes, no pts, dts -31999, duration 40000.
  [AVBSFContext @ 00000000027d3580] Slice Header
  [AVBSFContext @ 00000000027d3580] 0           forbidden_zero_bit                                          0 = 0
  [AVBSFContext @ 00000000027d3580] 1           nal_ref_idc                                                10 = 2
  [AVBSFContext @ 00000000027d3580] 3           nal_unit_type                                           00001 = 1
  [AVBSFContext @ 00000000027d3580] 8           first_mb_in_slice                                           1 = 0
  [AVBSFContext @ 00000000027d3580] 9           slice_type                                              00110 = 5
  [AVBSFContext @ 00000000027d3580] 14          pic_parameter_set_id                                        1 = 0
  [AVBSFContext @ 00000000027d3580] 15          frame_num                                                0001 = 1
  [AVBSFContext @ 00000000027d3580] 19          pic_order_cnt_lsb                                      000100 = 4
  [AVBSFContext @ 00000000027d3580] 25          num_ref_idx_active_override_flag                            1 = 1
  [AVBSFContext @ 00000000027d3580] 26          num_ref_idx_l0_active_minus1                                1 = 0
  [AVBSFContext @ 00000000027d3580] 27          ref_pic_list_modification_flag_l0                           0 = 0
  [AVBSFContext @ 00000000027d3580] 28          luma_log2_weight_denom                                      1 = 0
  [AVBSFContext @ 00000000027d3580] 29          chroma_log2_weight_denom                                    1 = 0
  [AVBSFContext @ 00000000027d3580] 30          luma_weight_l0_flag[i]                                      0 = 0
  [AVBSFContext @ 00000000027d3580] 31          chroma_weight_l0_flag[i]                                    0 = 0
  [AVBSFContext @ 00000000027d3580] 32          adaptive_ref_pic_marking_mode_flag                          0 = 0
  [AVBSFContext @ 00000000027d3580] 33          cabac_init_idc                                              1 = 0
  [AVBSFContext @ 00000000027d3580] 34          slice_qp_delta                                      000010011 = -9
  [AVBSFContext @ 00000000027d3580] 43          disable_deblocking_filter_idc                               1 = 0
  [AVBSFContext @ 00000000027d3580] 44          slice_alpha_c0_offset_div2                                  1 = 0
  [AVBSFContext @ 00000000027d3580] 45          slice_beta_offset_div2                                      1 = 0
  [AVBSFContext @ 00000000027d3580] 46          cabac_alignment_one_bit                                     1 = 1
  [AVBSFContext @ 00000000027d3580] 47          cabac_alignment_one_bit                                     1 = 1
  </code></pre>
  
  <p>You'll have to parse the file to count frames.</p>
  
  <hr>
  
  <p>Alternatively, H.264 Stream Analysis appears to be a frontend for h264_bitstream. Latest source available from <a href="https://sourceforge.net/projects/h264bitstream/files/h264bitstream/0.1.9/" rel="noreferrer">https://sourceforge.net/projects/h264bitstream/files/h264bitstream/0.1.9/</a>. It can be easily compiled on Windows under MinGW/MSYS2.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-20T17:33:38.660Z
Answers.LastActivityDate: 2018-04-20T17:33:38.660Z
Answers.UserDisplayName: Gyan
Body: <p>I have a raw H.264 file. I would like to retrive both length and frame number of every NAL unit in this file. The result must be printed to file. </p>
  
  <p>Is there any tool to do this?</p>
  
  <p>I have tried using H.264 Stream Analysis on Windows and it works well, but I cannot find an option for printing to file.</p>
  
Tags: <h.264><decoding><analysis>
Title: Print to file: Details of every NAL unit in raw H.264 file
UserDisplayName: fonnes
ThreadText: # Print to file: Details of every NAL unit in raw H.264 file
  
  (Asked by: username_0 on 2018-04-19)
  
  I have a raw H.264 file. I would like to retrive both length and frame number of every NAL unit in this file. The result must be printed to file.
  
  Is there any tool to do this?
  
  I have tried using H.264 Stream Analysis on Windows and it works well, but I cannot find an option for printing to file.
  
  **Tags:** h.264, decoding, analysis
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-04-20. Score: 9 | Accepted answer
  
  You can use the trace\_headers bitstream filter in ffmpeg
  
  ```
  ffmpeg -i in.264 -c copy -bsf:v trace_headers -f null - 2> NALUS.txt
  
  ```
  
  The text file will have data like this,
  
  ```
  [AVBSFContext @ 00000000027d3580] Packet: 102 bytes, no pts, dts -31999, duration 40000.
  [AVBSFContext @ 00000000027d3580] Slice Header
  [AVBSFContext @ 00000000027d3580] 0           forbidden_zero_bit                                          0 = 0
  [AVBSFContext @ 00000000027d3580] 1           nal_ref_idc                                                10 = 2
  [AVBSFContext @ 00000000027d3580] 3           nal_unit_type                                           00001 = 1
  [AVBSFContext @ 00000000027d3580] 8           first_mb_in_slice                                           1 = 0
  [AVBSFContext @ 00000000027d3580] 9           slice_type                                              00110 = 5
  [AVBSFContext @ 00000000027d3580] 14          pic_parameter_set_id                                        1 = 0
  [AVBSFContext @ 00000000027d3580] 15          frame_num                                                0001 = 1
  [AVBSFContext @ 00000000027d3580] 19          pic_order_cnt_lsb                                      000100 = 4
  [AVBSFContext @ 00000000027d3580] 25          num_ref_idx_active_override_flag                            1 = 1
  [AVBSFContext @ 00000000027d3580] 26          num_ref_idx_l0_active_minus1                                1 = 0
  [AVBSFContext @ 00000000027d3580] 27          ref_pic_list_modification_flag_l0                           0 = 0
  [AVBSFContext @ 00000000027d3580] 28          luma_log2_weight_denom                                      1 = 0
  [AVBSFContext @ 00000000027d3580] 29          chroma_log2_weight_denom                                    1 = 0
  [AVBSFContext @ 00000000027d3580] 30          luma_weight_l0_flag[i]                                      0 = 0
  [AVBSFContext @ 00000000027d3580] 31          chroma_weight_l0_flag[i]                                    0 = 0
  [AVBSFContext @ 00000000027d3580] 32          adaptive_ref_pic_marking_mode_flag                          0 = 0
  [AVBSFContext @ 00000000027d3580] 33          cabac_init_idc                                              1 = 0
  [AVBSFContext @ 00000000027d3580] 34          slice_qp_delta                                      000010011 = -9
  [AVBSFContext @ 00000000027d3580] 43          disable_deblocking_filter_idc                               1 = 0
  [AVBSFContext @ 00000000027d3580] 44          slice_alpha_c0_offset_div2                                  1 = 0
  [AVBSFContext @ 00000000027d3580] 45          slice_beta_offset_div2                                      1 = 0
  [AVBSFContext @ 00000000027d3580] 46          cabac_alignment_one_bit                                     1 = 1
  [AVBSFContext @ 00000000027d3580] 47          cabac_alignment_one_bit                                     1 = 1
  
  ```
  
  You'll have to parse the file to count frames.
  
  ---
  
  Alternatively, H.264 Stream Analysis appears to be a frontend for h264\_bitstream. Latest source available from <https://sourceforge.net/projects/h264bitstream/files/h264bitstream/0.1.9/>. It can be easily compiled on Windows under MinGW/MSYS2.
  
  
  ---
  
  ### Answer by username_1 on 2020-04-03. Score: 1
  
  <https://stackoverflow.com/questions/6014904/h264-frame-viewer> has some good answers. For example, <https://github.com/shi-yan/H264Naked> worked well when I tried it.
  
  
  ---
  
  