Yohann Martineau, blog

Posts from 2010-04

Send audio and video to X-Lite using ffmpeg

2010-04-10 11:28:46

Send Video

I've been struggling for long to find a way to send video to X-Lite. Now I can, using sipp and ffmpeg. I'm using a custom sipp script based on uas scenario. I've just added video media in uas script, in 200 OK SDP, using H263-1998 media description (and attributes) proposed in X-Lite SDP offer. This media contains size options (QCIF, CIF, etc.). Then I send INVITE to sipp from X-Lite using an account that does not need registration. I look at traces to find the port on which X-Lite is willing to receive video RTP packets, and I send a video to X-Lite using the following command:

  ffmpeg -re -i file.flv -f rtp -an -vcodec h263 -s 176x144 rtp://1.2.3.4:5678

file.flv is a video retrieved from youtube using any youtube grabber website.

But don't try this using ffmpeg as is, because ffmpeg always send RTP packets using payload type 96, which is a dynamic payload type. To make it work, you have to apply the following patch on ffmpeg, to use a payload type proposed by X-Lite, here 115:

index 5df101e..3c15a8b 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -78,7 +78,7 @@ static int rtp_write_header(AVFormatContext *s1)
 
     s->payload_type = ff_rtp_get_payload_type(st->codec);
     if (s->payload_type < 0)
-        s->payload_type = RTP_PT_PRIVATE + (st->codec->codec_type == AVMEDIA_TY
+        s->payload_type = 115;
 
     s->base_timestamp = ff_random_get_seed();
     s->timestamp = s->base_timestamp;

If I understand correctly, for the moment, it's not possible to manually set the payload type of RTP packets sent from ffmpeg. A long thread on ffmpeg mailing list seems to show that it's not possible yet.

This patch is (of course) not for production use, but at least, it works. Let's hope that ffmpeg will make this parameter configurable...

Send audio

To send audio, it's quite "easy", the following command should work out of the box :

  ffmpeg -re -i file.flv -vn -acodec pcm_mulaw -ar 8000 -ac 1 -f rtp rtp://1.2.3.4:5678?pkt_size=172

Here, the trick is to force ffmpeg to use 172 UDP packets, because X-Lite only accept RTP packets which payload size is exactly 160. RTP (standard) header size is 12 bytes, thus pkt_size must be 172.

Permanent link
protocol, multimedia, development, english

Comments