RTSP server not working as OBS Media Source while the exact same URL works in mpv

tacosukoneko

New Member
Hi my problem is, my RTSP source works perfectly in mpv and I can see it, but adding the same URL as a Media Source in OBS on the same system, no matter whether mpv is also running at the same time or not, results in the source not appearing in the preview and not appearing in the scene. To be clear, the exact command outside OBS I used here to prove to myself that the stream is valid is mpv rtsp://127.0.0.1:8082/video/h264The RTSP server is proprietary CamON IP camera app for Android forwarded to the Arch Linux system over adb over USB. The RTSP URL is rtsp://127.0.0.1:8082/video/h264 . CamON also supports MJPEG over HTTP format instead of RTSP, which does work in OBS Media Source with its own HTTP URL, but on this specific locked-bootloader Android device, the MJPEG stream is unusably poor framerate and quality and the RTSP stream shows in mpv as vastly superior quality. I also reproduced this on 2 different Arch Linux systems across 5 different Android devices varying from fully rooted linegeos to fully locked bootloader samsung and from Android 7 to Android 11 (on some of them MJPEG is acceptable quality, but I need to use all of them at the same time and on the desired device in question MJPEG isn't performing with acceptable framerate as explained). I also tried adding mpegts to "Input Format" field which did not help. As a workaround I am currently using mpv with window size equal to RTSP resolution and then adding mpv window as window capture in the scene, but since OBS is supposed to support RTSP it seems backwards to do this. Affecting both obs-studio 27.2.4 from official Arch Linux repositories and obs-studio-git compiled today. This is what mpv prints while it is displaying the stream correctly: https://clbin.com/AZnWX This is the portion of my OBS log after adding the source: https://clbin.com/z0vBW How can I specify "size" , "analyzeduration" or "probesize" in OBS? Could that help?

A full log file from a test reproducing the issue, uploaded from OBS "Upload Current Log File" (port is different here from the above tests because I configured different port, but just before executing OBS I tested the exact URL including port in mpv and observed it work) https://obsproject.com/logs/0DC4catBzSLPpe8y
 

tacosukoneko

New Member
I also asked on FFmpeg and OBS Discord groups and many people rapidly told me many things to try there. Eventually, after trying a huge number of things, I have found a working solution to this issue, based on help from two users there, LiaNdrY#9870 and THECOOKIE94#8933, who each found partial solutions that completely solve the issue when combined.
  1. Install a version of OBS 28 that currently contains the "FFmpeg Options" field in the Media Source GUI, in the case of Arch Linux examples are obs-studio-browser and obs-studio-git. As far as I know, OBS 27 cannot do this (without using the earlier workaround, or similar).
  2. Place the rtsp://127.0.0.1:8082/video/h264 in the "Input" field as previously described, but also add rtsp_transport=tcp rtsp_flags=prefer_tcp in the "FFmpeg Options" field, then click OK
  3. Restart OBS and wait for several minutes. I had to wait for 3 minutes and then the stream finally appeared in the Scene viewport, but in good framerate with only 2 seconds of latency.
1663865628391.png
 
Last edited:

Gwyneth Llewelyn

New Member
I just wanted to add a small note of thanks. In my scenario, I wanted to stream out of OBS, not in, and was having trouble with the synchronisation — everything was being streamed way too quickly (perhaps at 5x - 10x the speed!). Switching to TCP solved the issue! Thank you so much for the tip.
 

Thanatos8088

New Member
I also asked on FFmpeg and OBS Discord groups and many people rapidly told me many things to try there. Eventually, after trying a huge number of things, I have found a working solution to this issue, based on help from two users there, LiaNdrY#9870 and THECOOKIE94#8933, who each found partial solutions that completely solve the issue when combined.
  1. Install a version of OBS 28 that currently contains the "FFmpeg Options" field in the Media Source GUI, in the case of Arch Linux examples are obs-studio-browser and obs-studio-git. As far as I know, OBS 27 cannot do this (without using the earlier workaround, or similar).
  2. Place the rtsp://127.0.0.1:8082/video/h264 in the "Input" field as previously described, but also add rtsp_transport=tcp rtsp_flags=prefer_tcp in the "FFmpeg Options" field, then click OK
  3. Restart OBS and wait for several minutes. I had to wait for 3 minutes and then the stream finally appeared in the Scene viewport, but in good framerate with only 2 seconds of latency.
View attachment 86885

The FFmpeg options trick did it for me. I could get the exact same URL to show in VLC, but never in OBS until I used both the transport and flags settings mentioned. This was specific to an Avigilon camera in my case, but I'm troubleshooting ideas for a colleague and suspect he is facing the same issue with a Barlus ...my Reolink didn't need them and drops straight in, go figure. Long story short, tacosukoneko has likely made short work of a very frustrating problem. Thanks!
 

fakedane

New Member
I don't know how @
I also asked on FFmpeg and OBS Discord groups and many people rapidly told me many things to try there. Eventually, after trying a huge number of things, I have found a working solution to this issue, based on help from two users there, LiaNdrY#9870 and THECOOKIE94#8933, who each found partial solutions that completely solve the issue when combined.
  1. Install a version of OBS 28 that currently contains the "FFmpeg Options" field in the Media Source GUI, in the case of Arch Linux examples are obs-studio-browser and obs-studio-git. As far as I know, OBS 27 cannot do this (without using the earlier workaround, or similar).
  2. Place the rtsp://127.0.0.1:8082/video/h264 in the "Input" field as previously described, but also add rtsp_transport=tcp rtsp_flags=prefer_tcp in the "FFmpeg Options" field, then click OK
  3. Restart OBS and wait for several minutes. I had to wait for 3 minutes and then the stream finally appeared in the Scene viewport, but in good framerate with only 2 seconds of latency.
View attachment 86885
Thank you so much for figuring this out! I'm not sure how you did -- I can't even find a list of FFmpeg Options and clicking on that question mark does nothing. Just one thing to add, for some reason, this didn't work until I exited OBS and came back. Good thing I didn't delete the media source or I wouldn't have noticed that this works! Also, if you need credentials, be sure to pass them using the following format...rtsp://{username}:{password}@{ip address}:{port number}/1 (the 1 is camera specific, as far as I can tell, that was from my camera's manual). I tried this without passing credentials and it did not work for me.
 
Top