Concurrent h264 encode/decode instability

4 posts
by rtang » Sun Jan 06, 2013 10:49 pm

I implemented a H264 remote camera application using two Raspberry Pis (minus the camera, of course. The camera data was faked using a rolling frame buffer encoded using RGB565 format). One Pi acted as the camera/encoder and the other Pi acted as the display/decoder. In my setup the encoder/decoder were transmitting/receiving 720p @ 30fps over UDP (if interested:

I then tried to launch both encoder/decoder service on both Pis to simulate a video conferencing application, but encountered instabilities within minutes (when the setup was only doing one way streaming, it had no problem running over 30 minutes). I attempted two way streaming several times and made the same observations. Some symptoms include:

1. OpenMAX started to complain its running out of buffers (il_client_get_output_buffer() returns NULL).
2. The Pi froze and I had to power cycle it.
3. One of my Pi's SD card was corrupted this morning and I had to re-image it (I didn't overclock my Pi). I don't know if this is related.

Can I get rid of point 1 by splitting my video/CPU memory different? I've noticed point 2 occurs to my one of my Pis even when it's idle. Could this relate to a flaky power supply? Does the Pi draw more current as the CPU is under higher load? And if the power supply fails to output the requested current, does this trap Pi in a bad state?

Posts: 49
Joined: Mon Oct 08, 2012 6:27 am
by rtang » Mon Jan 07, 2013 6:52 am
I looked at the code more closely and realized that I was trapping main() using a while(1). This was causing CPU saturation and ultimately point 2 & 3 in my original post (I think). I'm still curious as to why saturating the CPU would cause the Pi to hang?

I replaced the while(1) with a pthread_join(). The system now uses ~20% CPU usage with both encoder/decoder running concurrently. However, the session still failed eventually because il_client_get_input_buffer() (correction from original post) returned NULL.

Posts: 49
Joined: Mon Oct 08, 2012 6:27 am
by jamesh » Mon Jan 07, 2013 7:18 am
Are you leaking a buffer somewhere?
Posts: 10515
Joined: Sat Jul 30, 2011 7:41 pm
by lapin » Tue Jan 15, 2013 1:10 pm
will you make the code available via git, svn or similar? I'd love to have a look at it.
Posts: 1
Joined: Tue Jan 15, 2013 1:04 pm