title: Xuggler encoding and muxing
body: <p>I'm trying to use <a href="http://www.xuggle.com/xuggler/" rel="noreferrer">Xuggler</a> (which I <em>believe</em> uses <a href="http://ffmpeg.org/" rel="noreferrer"><code>ffmpeg</code></a> under the hood) to do the following:</p>
  
  <ul>
  <li>Accept a raw MPJPEG video bitstream (from a small TTL serial camera) and encode/transcode it to h.264; and</li>
  <li>Accept a raw audio bitsream (from a microphone) and encode it to AAC; then</li>
  <li>Mux the two (audio and video) bitsreams together into a MPEG-TS container</li>
  </ul>
  
  <p>I've watched/read some of their excellent tutorials, and so far here's what I've got:</p>
  
  <pre><code>// I'll worry about implementing this functionality later, but
  // involves querying native device drivers.
  byte[] nextMjpeg = getNextMjpegFromSerialPort();
  
  // I'll also worry about implementing this functionality as well;
  // I'm simply providing these for thoroughness.
  BufferedImage mjpeg = MjpegFactory.newMjpeg(nextMjpeg);
  
  // Specify a h.264 video stream (how?)
  String h264Stream = "???";
  
  IMediaWriter writer = ToolFactory.makeWriter(h264Stream);
  writer.addVideoStream(0, 0, ICodec.ID.CODEC_ID_H264);
  writer.encodeVideo(0, mjpeg);
  </code></pre>
  
  <p>For one, I think I'm close here, but it's still not correct; and I've only gotten this far by reading the video code examples (not the audio - I can't find any good audio examples).</p>
  
  <p>Literally, I'll be getting byte-level access to the raw video and audio feeds coming into my Xuggler implementation. But for the life of me I can't figure out how to get them into an h.264/AAC/MPEG-TS format. Thanks in advance for any help here.</p>