Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From the discussion in the comments I rephrase your question and split it into two:</p> <h2>I want to extract NAL units from H264 RTP packets in pure java and dump them into an Annex B H264 file.</h2> <p>How do I do that? Is there a library?</p> <p>The payload of these packets is specified in <a href="http://www.ietf.org/rfc/rfc3984.txt" rel="nofollow">RFC3984</a>. </p> <p>I don't know any Java library that performs this out of the box. But implementation is fairly simple as long as the packaging type is not interleaved:</p> <p>RFC3984 allows three packaging type </p> <ul> <li>Single NAL unit mode</li> <li>Non-interleaved mode</li> <li>Interleaved mode</li> </ul> <p>as long as your packet source is sending in single NAL unit mode or non-interleaved mode you can extract the NAL units without any further processing from the packets and dump them to disk with 0x00,0x00,0x00,0x01 as divider between them. </p> <p>If the packaging type is interleaved you need to put a lot more work into that since than you will have to look into the NALs and re-order them to be in decoding order.</p> <h2>I mux raw Annex B H264 files into an MP4 container in pure Java</h2> <p>You can you use my <a href="https://github.com/sannies/mp4parser" rel="nofollow">mp4parser</a> project to generate a MP4 from the Annex B format. Have a look at the <a href="https://github.com/sannies/mp4parser/blob/master/examples/src/main/java/com/googlecode/mp4parser/muxformats/H264Example.java" rel="nofollow">H264Example</a> - that should give you an idea on how to use it. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload