[Libav-user] Server out stream as RTP

Charles linux2 at orion15.org
Fri Sep 23 21:43:22 EEST 2016

On 09/23/2016 07:04 AM, Simon Brown wrote:
> On 23 September 2016 at 09:27, Simon Brown <simon.k.brown at gmail.com <mailto:simon.k.brown at gmail.com>> wrote:
>     Hi,
>     I'm trying to serve a transport stream generated by hardware out on as an RTP stream.  Is there an example I can use to help me do

With ffmpeg or writing code to use the libs?
Probably get more ffmpeg help over in ffmpeg-user at ffmpeg.org

>     this?  I've been looking through ffserver.c but that is much more complicated than I need, and seems to be largely aimed at serving
>     files out.
>     Cheers,
>     Simon
> Ok, I've taken a step back.
> If I type:
> ffplay -i tcp://localhost:60010?listen
> in one window, and
> ffmpeg -i INPUT -f mpegts tcp://localhost:60010

Not sure how to send mpegts over TCP, you can RTP on top of TCP but normally mpegts is UDP.

Try something like this:
ffmpeg -i INPUT -c:v copy -listen 1 -f mpegts "udp://"

ffplay -i udp://
vlc udp/ts://@

"-c:v copy" is the no transcode copy video only handling

You will need a multicast route (all multicast)
route add -net netmask dev eth0
OR single
route add -net netmask dev eth0

This will allow you to connect multiple listeners to the stream.

> my video plays.
> For my use though, I don't want to wade through ffmpeg.c to find what it's doing, and wanted a much simpler example that isn't transcoding,
> but just transmitting a ready made transport stream.  I found in the examples directory "http_multiclient.c" and thought this would do for
> me, at least as a starting point.
> My problem is that if I start ffplay with "?listen" first, then http_multiclient won't connect, yet if I start http_multiclient first it
> says "Client not accepted" and aborts.
> My http_multiclient command line is:
> ./http_multiclient ts_file tcp://localhost:60010
> It seems that http_multiclient is trying to listen on the server socket, but not avio_accept is returning immediately with a "client not
> accepted".  How can I make this work?
> Regards,
> Simon

I was not able to get that sample to work, it always core dumped on
ret = ffurl_accept(sc, &cc); in libavformat/aviobuf.c
Prob because of the     av_assert0(!*c); in avio.c since I have a debug build.

If you are trying to write code to do this, start with transcoding.c
In the main while loop, just use the "else"
         } else {
             /* remux this frame without reencoding */

That should get you pretty close to what you want...ignore the extra code
open in, open out, while in frame write out frame...


More information about the Libav-user mailing list