Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
By using ffmpeg or ffplay you may specify -rtsp_transport tcp switch to force the rtsp stream be opened via tcp. In programming, I'm using libav to open the rtsp stream with the following code:

AVDictionary *options = NULL;
av_dict_set(&options, "rtsp_transport", "tcp", 0);
int status = avformat_open_input(&mFormatContext, path.c_str(), inputFormat, &options);

and I expect the same behavior. But the url path is opened via udp. I may figure this out this way:

I create an sdp file with libav and write the received packets to it. Then I use ffplay to process and play the sdp file. I get errors like:

RTP: missed 1 packets

error while decoding MB 75 38, bytestream -48

If the rtsp stream has been opened via TCP, I should not miss any packets, and the second type of error, I think, is caused by losing packets too. So, it seems that the rtsp_transport option is not working.

Any idea?


I found that av_dict_set works as expected, but the SDP file is made incorrectly (maybe). Its content is like:

o=- 0 0 IN IP4
s=No Name
c=IN IP4
t=0 0
a=tool:libavformat 56.40.101
m=video 43908 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z00AKpY1QPAET8s3AQEBAgA=,aO48gAA=; profile-level-id=4D002A

I researched about it and found that the line beginning with 'm' should contain TCP instead of RTP/AVP, although all of this is my guess. The ffplay is reading the sdp file in the same system, so no socket or network connection exists between ffplay and the sdp file. So my guess may be incorrect. What do you think about the sdp file? May it be incorrect? I make it by av_sdp_create function and don't change it. I write it directly to the file.

What I have tried:

I tried using a dictionary containing rtsp_transport option and set it to tcp, with no success.
Updated 14-Aug-23 19:06pm

1 solution

Support and maintenance of libav was abandoned some years ago according to Libav - Wikipedia[^].
Share this answer
ilostmyid2 15-Aug-23 11:20am    
We're using the fork, ffmpeg, with the same functionality.
Richard MacCutchan 15-Aug-23 11:32am    
Either way, you will need to examine the code to find out where the decision is made to use TCP or UDP.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900