[libav-api] Opening and Decoding UDP MpegTS

Luca Barbato lu_zero at gentoo.org
Wed Nov 2 03:27:05 CET 2011

On 11/1/11 1:07 PM, Evgeny Yakimov wrote:
> Hello
> I'm trying to open a UDP mpegts stream, and decode it using libavcodec
> and ultimately encode it using my own application which uses x264/faac
> to encode it directly. I've managed to get this working by reading raw
> frames and the encoding part of my application works fine, however
> whenever I try to open libav I get seg faults. I've uploaded my code to:
> http://pastebin.com/rkFQKMWB
> Please let me know if I'm openning the stream incorrectly, note that for
> my test case the options pairs are:
> 'f' => "mpegts"
> 'u' => "udp://:1500",
> ignore the 'l' for now
> I'm using avconv to generate the UDP mpegts.
> The problem is that the segfault actually occurs in the thread that does
> the x264 encoding, I "think" that due to the way I'm using libav, that
> its corrupting some of the memory used by the x264 encoding thread.
> I have also tried doing this,  by commenting out both the :
> avcodec_open2 , and the avcodec_decode_audio3 , avcodec_decode_video2
> and sending my application blank dummy blank frames / samples. So
> basically I receive the blank packets without decoding them and
> substituted them with blank "payloads" when I do this I no longer get
> the seg faults, which suggests that I'm missusing one of these calls.

Try to run the code in valgrind. If it is memory corruption it will spot 
it quickly.

Btw if you are using udp make sure you set the system buffers to be 
large enough.

More information about the libav-api mailing list