[Libav-user] C-Sample code for an RTP Video streaming Server

Georg Stein georg_stein at t-online.de
Sat Apr 4 07:32:44 CEST 2015

while i hav ealso some problems to undertsand thid correct i would be 
very interested if there is also a link to this example " how to encode 
a video file with libx264" (could not find it in the ffmpeg sources)


Am 04.04.2015 um 01:47 schrieb Info || Non-Lethal Applications:
> Hi,
>> On 04 Apr 2015, at 01:36, robotanarchy <robotanarchy at bingo-ev.de
>> <mailto:robotanarchy at bingo-ev.de>> wrote:
>> Hello libav-users,
>> I'm just getting started with using libav and it is hard to find any
>> sample code, except for what is in the doc/examples folder of the
>> source tree [1].
>> More specifically, I'd like to create a RTP video streaming server in C.
>> The closest thing to an example code was this [2] on stackoverflow -
>> but it is said not to work well and also it doesn't compile with the
>> latest ffmpeg.
>> I've also tried to fork ffserver, but it also won't compile outside of
>> the ffmpeg source tree. Its main file, ffserver.c [3], has this infront
>> of most of the header files:
>> // FIXME those are internal headers, ffserver _really_
>> shouldn't use them
>> ...so this also doesn't seem to be a good starting point either. I'm
>> wondering if such an RTP server is even possible without these internal
>> headers.
>> If it is, can someone please provide some readable example code, that
>> does nothing but serve a video over RTP?
>> Kind regards,
>> robotanarchy
> We just did that recently and it worked quite well (we were streaming a
> live video source to an iPhone).
> For a very basic approach, you can simply look for examples on how to
> encode a video file with libx264.
> All you need to do make RTP work is set the output URL as you would
> normally set a file.
> Here’s a short snippet:
> _pVideoOutputFmt= av_guess_format("rtp", NULL, NULL);
> _pVideoFormatCtx= avformat_alloc_context();
> avformat_alloc_output_context2(&_pVideoFormatCtx, _pVideoOutputFmt,
> "rtp", _url.c_str());
> /* open the output file, if needed */
> if (!(_pVideoOutputFmt->flags & AVFMT_NOFILE))
> avio_open(&_pVideoFormatCtx->pb, _url.c_str(), AVIO_FLAG_WRITE);
> And don’t forget to do a avformat_network_init(); or else RTP won’t work.
> Hope this helps getting you started!
> Best regards,
> Flo
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

More information about the Libav-user mailing list