[FFmpeg-devel] UDP Multicast

Thomas Volkert silvo at gmx.net
Mon Mar 30 10:03:28 CEST 2015

Andre Lopes wrote:
> H
> I was trying to setup a ffmpeg client to work with an Arecont camera in multicast and realized that the camera would only return a multicast stream after an RSTP call, if the SETUP was requested with the following transport:
> Transport: RTP/AVP;multicast;client_port=xxxxx
> Since the current implementation of the FFMpeg client is sending the transport  the values RTP/AVP/UDP;multicast and this was not being recognized by the camera, I have changed the FFMpeg code to send the required transport definition. This way the client started to receive a multicast stream from the camera.
> The diff is the following:
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index c9ffba4..ecbfdf5 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1451,7 +1451,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
>           else if (lower_transport == RTSP_LOWER_TRANSPORT_UDP_MULTICAST) {
>               snprintf(transport, sizeof(transport) - 1,
> -                     "%s/UDP;multicast", trans_pref);
> +                     "%s;multicast;client_port=%d-%d", trans_pref, rtsp_st->sdp_port, rtsp_st->sdp_port + 1);

You are right, UDP is the default transport protocol and "/UDP" could be 
omitted - see RFC 2326. But your camery should be able to parse 
"RTP/AVP/UDP" correctly. So, I think the following line should also work 
in your case - does it?:

+                     "%s/UDP;multicast;client_port=%d-%d", trans_pref, rtsp_st->sdp_port, rtsp_st->sdp_port + 1);

If this is the case I would prefer this solution to keep the code 
similar to the RTP/UDP unicast case.

>           }
>           if (s->oformat) {
>               av_strlcat(transport, ";mode=record", sizeof(transport));
> Could this patch be included in the ffmpeg code?

Best regards,

More information about the ffmpeg-devel mailing list