View Full Version : Force FFmpeg output only TCP as RTSP proxy
Barabba
20th August 2021, 09:53
Hi! do somebody here knows how to force ffmpeg outputing a TCP rtsp instead of default UDP? I know how to force the input to TCP, with -rtsp_transport tcp option, but I can't find how to force the output.
Read somewhere that someone solved suggesting to use avformat_write_header(ofmt_ctx, &options); but didn't say nothing mode about that.. and this is too generic info. Thanks a lot for help!
StainlessS
20th August 2021, 12:27
Any of these any good,
What steps are needed to stream RTSP from FFmpeg?
https://stackoverflow.com/questions/26999595/what-steps-are-needed-to-stream-rtsp-from-ffmpeg
FFmpeg - capture a rtsp stream and re-stream it to another rtsp-server
https://stackoverflow.com/questions/66538527/ffmpeg-capture-a-rtsp-stream-and-re-stream-it-to-another-rtsp-server
How to minimize the delay in a live streaming with ffmpeg
https://stackoverflow.com/questions/16658873/how-to-minimize-the-delay-in-a-live-streaming-with-ffmpeg
StackOverflow:- Hot answers tagged rtsp
https://stackoverflow.com/tags/rtsp/hot?filter=year
Or more of same, Google:-
"ffmpeg" NEAR "TCP rtsp" site:stackoverflow.com
https://www.google.co.uk/search?q=%22ffmpeg%22+NEAR+%22TCP+rtsp%22+site:stackoverflow.com&ei=v40fYZqRNP-DhbIPsbWnyA4&start=10&sa=N&ved=2ahUKEwja7LLFu7_yAhX_QUEAHbHaCekQ8NMDegQIARBK&biw=1920&bih=909
Good Luck
Barabba
20th August 2021, 20:54
Hi, thanks for links, I've spent hours reading all around, I can't solve my problem.
I?m using this string, it connect to first sopurce by TCP, but ffmpeg is not opening a tcp listenng port. It does open 4 UDP ports with different values (far from what I've specified for tcp), anyway I've tried to connect to them too with VLC, but no one works.
ffmpeg -re -i rtsp://admin:passord@rtsp.source:554/live.sdp -rtsp_transport tcp -f rtsp -rtsp_transport tcp rtsp:/192.168.0.100:50041/
May you kindly correct it if it is wrong?
patul
21st August 2021, 00:58
You need to put the -rstp_transport tcp before the input, something like this
ffmpeg -rtsp_transport tcp -re -i rtsp://admin:password@rtsp.source:554/live.sdp -f rtsp -muxdelay 0.1 rtsp://localhost:7000
Barabba
23rd August 2021, 13:19
thanks for answering me,
I underline the problem is not input (to connect by tcp only to an rtsp source), the problem is output, to stream from ffmpeg only with TCP, ignoring any UDP request and forse to use TCP only. How this can be possible? Thank you.
I've tried some apps on Android TV to show an rtsp stream, they will connect by UDP as first attempt, there are no way to foce this clients to use TCP, I've tried with Windows firewall but didn't work. I need to kill UDP
Thank you
patul
24th August 2021, 00:31
I tried that command, no udp port was opened. Other thing I can think of is
-rtsp_flags prefer_tcp
Barabba
25th August 2021, 21:20
I've solved it using https://github.com/aler9/rtsp-simple-server
in the end you may get a TCP stream from the rtsp://serverIP:port/proxied
seems there are no ways to tell ffmpeg to stream on TCP only
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.