Hi,
> On 04 Apr 2015, at 01:36, robotanarchy <[email protected]> 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
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user