title: Decode android's hardware encoded H264 camera feed using ffmpeg in real time
body: <p>I'm trying to use the hardware <code>H264</code> encoder on Android to create video from the camera, and use <code>FFmpeg</code> to mux in audio (all on the Android phone itself)</p>
  
  <p>What I've accomplished so far is packetizing the <code>H264</code> video into <code>rtsp</code> packets, and decoding it using VLC (over <code>UDP</code>), so I know the video is at least correctly formatted. However, I'm having trouble getting the video data to <code>ffmpeg</code> in a format it can understand.</p>
  
  <p>I've tried sending the same <code>rtsp</code> packets to a port 5006 on localhost (over UDP), then providing <code>ffmpeg</code> with the <code>sdp</code> file that tells it which local port the video stream is coming in on and how to decode the video, if I understand <code>rtsp</code> streaming correctly. However this doesn't work and I'm having trouble diagnosing why, as <code>ffmpeg</code> just sits there waiting for input.</p>
  
  <p>For reasons of latency and scalability I can't just send the video and audio to the server and mux it there, it has to be done on the phone, in as lightweight a manner as possible.</p>
  
  <p>What I guess I'm looking for are suggestions as to how this can be accomplished. The optimal solution would be sending the packetized <code>H264</code> video to <code>ffmpeg</code> over a pipe, but then I can't send <code>ffmpeg</code> the <code>sdp</code> file parameters it needs to decode the video.</p>
  
  <p>I can provide more information on request, like how <code>ffmpeg</code> is compiled for Android but I doubt that's necessary.</p>
  
  <p>Oh, and the way I start <code>ffmpeg</code> is through command line, I would really rather avoid mucking about with jni if that's at all possible.</p>
  
  <p>And help would be much appreciated, thanks.</p>