Help with piping rtsp-link from Ubiquiti ip-cam
Added by Ernie Bert over 3 years ago
Hi,
I'm glad to be a TVheadend user. Streaming TV- and Radio channels 24/7 is pure fun. ;-)
But now I want to stream also 2 Ubiquiti ip-cams beeing connected to their own unifi video server
This server offers rtsp-links without username and password. (as well as rtmp and rtmps-links)
An example for a link is rtsp://192.168.174.70:7447/59494e5314817740a7ac1410_0
unifi video server and tvh-server are on the same machine, so security doesn't matter.
The links do work well with vlc. Here is some video information out of vlc:
H264-MPEG4 AVC (part10)(h264),1920x1080,refresh rate 15,4:2:0 YUV full scale
MPEG AAC Audio (mp4a) 22050 Hz,32 bits per sample
I did some attemps with pipe, but none of them worked. Here's my latest one:
2021-07-15 16:03:57.480 mpegts: pipe:///usr/bin/ffmpeg -i rtsp://192.168.174.70:7447/59494e5314817740a7ac1410_0 -vcodec copy -acodec copy -f mpegts pipe:1 - tuning on IPTV #1
2021-07-15 16:03:57.487 subscription: 0075: "scan" subscribing to mux "pipe:///usr/bin/ffmpeg -i rtsp://192.168.174.70:7447/59494e5314817740a7ac1410_0 -vcodec copy -acodec copy -f mpegts pipe:1", weight: 6, adapter: "IPTV #1", network: "ipcam", service: "Raw PID Subscription"
2021-07-15 16:03:57.488 spawn: Executing "/usr/bin/ffmpeg"
2021-07-15 16:03:57.494 iptv: stdin pipe 109 unexpectedly closed: No data
2021-07-15 16:04:12.480 mpegts: pipe:///usr/bin/ffmpeg -i rtsp://192.168.174.70:7447/59494e5314817740a7ac1410_0 -vcodec copy -acodec copy -f mpegts pipe:1 - scan no data, failed
2021-07-15 16:04:12.480 subscription: 0075: "scan" unsubscribing
vlc also likes 127.0.0.1 or localhost, for tvh it makes no difference to local ip.
Thanks for help.
Regards, Ernie Bert
Replies (9)
RE: Help with piping rtsp-link from Ubiquiti ip-cam - Added by saen acro over 3 years ago
This link seams as temporary link, with 100% will not work on other device or after some time.
https://help.ui.com/hc/en-us/articles/221314008-UniFi-Video-How-to-Utilize-RTSP-Directly-From-the-Camera
RE: Help with piping rtsp-link from Ubiquiti ip-cam - Added by clint jones about 3 years ago
pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://root:[email protected]/axis-media/media.amp -vcodec copy -acodec copy -f mpegts -mpegts_service_type 0x01 pipe:1
this works on an axis camera and works well
It is very close to some you are trying perhaps add the password portion to the url?
clint
RE: Help with piping rtsp-link from Ubiquiti ip-cam - Added by Ernie Bert over 1 year ago
I finally found time to go on with this issue.
Now I have a "better" link from my UniFi video camera. It says rtsp://admin:pass@hostname:554/s0 and can be opened via VLC, for testing puposes even from the internet.
I try to include this link in TVheadend, newest version 4.3-2111~ga1cb8cffb, installed on Ubuntu 22.04.2 LTS (GNU/Linux 5.19.0-35-generic x86_64) with Flole Systems repository on cloudsmith.io
I installed ffmpeg by
apt-get install ffmpeg
I add a new IPTV network, I add a new Mux using this new IPTV network.
For url I use
pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:pass@hostname:554/s0 /out -vcodec copy -acodec copy -metadata service_provider=Stream -metadata service_name=Stream -f mpegts -tune zerolatency pipe:1
and get this result. Additional info: First part I used ... hostname:554/s0 /out and second part I used ... hostname:554/s0/out
Difference: the blank space, but it makes no difference.
Please tell my what is wrong. Thanks for help.
RE: Help with piping rtsp-link from Ubiquiti ip-cam - Added by Ernie Bert over 1 year ago
Synology Surveillance Station (App on Synology NAS) is able to import this ipcam-link without problems. The stream works perfectly.
But the output of Surveillance Station, which is also a rtsp-link, also cannot be streamed to TVheadend.
I think I need to know more about pipe syntax. Anybody here who can help?
RE: Help with piping rtsp-link from Ubiquiti ip-cam - Added by clint jones over 1 year ago
possible things to try?
Trim you command down to get started, the metadata portion looks formatted correctly but may not be needed to get started and VLC is not calling Ffmpeg it is going direct
perhaps the zerolatency is in the wrong position? not sure if it matters, but a lot of commands I see are typed this way
metadata service_provider=PiP -metadata service_name=PiP -tune zerolatency -f mpegts pipe:1
Also Is ffmpeg in the directory your calling? Some other distributions put it in another location. pipe:///usr/bin/ffmpeg is the standard debian location I think, it looks like your running something else I'm not sure what Flole Systems repository is?
s0 may not be recognized by FFmpeg? it uses "Map" to pick channels and will pick the first channel if not specified I think
Instead of hostname try the actual Ip address (unless you have it that way for the form)
I didnt see anything after a quick look about the "out" option it may not be needed?
Good Luck
Try
pipe:///check directory location/ffmpeg -loglevel fatal -i rtsp://admin:pass@ip adress:554 -vcodec copy -acodec copy -f mpegts pipe:1
Clint
RE: Help with piping rtsp-link from Ubiquiti ip-cam - Added by Ernie Bert over 1 year ago
No way, there are always errors like "Protocol not found" or "epoll del failed [Bad file descriptor]" or "Could not open input"
/s0 for path is needed
usr/bin/ffmpeg is correct
Maybe ffmpeg needs other parameters
I installed TVheadend from standard Flole Systems repository, [[https://tvheadend.org/projects/tvheadend/wiki/AptRepositories]]
2023-03-26 20:57:56.873 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - close PID 0011 (17) [20/0x7f661c090750] 2023-03-26 20:57:56.873 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - close PID 0010 (16) [20/0x7f661c032670] 2023-03-26 20:57:56.873 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - close PID 0001 (1) [16/0x7f661c063870] 2023-03-26 20:57:56.873 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - close PID 0000 (0) [20/0x7f661c07f8c0] 2023-03-26 20:57:56.873 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - scan no data, failed 2023-03-26 20:57:56.873 subscription: 01EA: "scan" unsubscribing 2023-03-26 20:57:56.873 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - close PID tables subscription [0042/0x7f661c084af0] 2023-03-26 20:57:56.873 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - stopping mux 2023-03-26 20:57:56.873 tvhpoll: epoll del failed [Bad file descriptor] 2023-03-26 20:57:56.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - close PID 0011 (17) [16/0x7f661c072880] 2023-03-26 20:57:56.874 mpegts: removing mux pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 from scan queue 2023-03-26 20:57:56.874 mpegts: adding mux pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 to scan queue weight 2 flags 5000 2023-03-26 20:58:06.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - add raw service 2023-03-26 20:58:06.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - tuning on IPTV #1 2023-03-26 20:58:06.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - open PID 0000 (0) [20/0x7f661c07f8c0] 2023-03-26 20:58:06.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - open PID 0001 (1) [16/0x7f661c063870] 2023-03-26 20:58:06.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - open PID 0010 (16) [20/0x7f661c032670] 2023-03-26 20:58:06.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - open PID 0011 (17) [20/0x7f661c090750] 2023-03-26 20:58:06.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - open PID 0011 (17) [16/0x7f661c072880] 2023-03-26 20:58:06.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - started 2023-03-26 20:58:06.874 mpegts: pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1 - open PID tables subscription [0042/0x7f661c084af0] 2023-03-26 20:58:06.874 subscription: 01EB: "scan" subscribing to mux "pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1", weight: 2, adapter: "IPTV #1", network: "IPCAM", service: "Raw PID Subscription" 2023-03-26 20:58:06.874 iptv: libav: Could not open input 'pipe:///usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1': Protocol not found
RE: Help with piping rtsp-link from Ubiquiti ip-cam - Added by Ernie Bert over 1 year ago
executing
/usr/bin/ffmpeg -loglevel fatal -i rtsp://admin:[email protected]:554/s0 -vcodec copy -acodec copy -f mpegts pipe:1
shows on cmd fast, unreadable output. It seems ffmpeg is able to read the stream
RE: Help with piping rtsp-link from Ubiquiti ip-cam - Added by clint jones over 1 year ago
better than nothing
try it without the /s0
according to the link you posted the s0 was the stream "identifier" for a lack of better words it looks like s0 was a stream either video or audio and the s1 was the other stream
here is the quote from the webpage above.
Enter the credentials when prompted in the third party program. Not all programs will necessarily support this feature or may be formatted differently.
pretty sure if you want to call a certain stream you would use "map"
also the log says protocol not found?
open the stream in vlc again and check the stream is it jpeg, mp4? ect. look on the menu under tools-> codec information. then check if your installation of ffmpeg supports the stream coming out of the camera
ffmpeg -formats | grep h264
for example will show you if you can work with Mp4
some older repository installations did not come with h264 and had to be added with a switch not sure about your version
hang in there I made my own recording scripts and it took several weeks of failure before getting it right here is the script
#!/bin/bash
/usr/bin/ffmpeg rtsp_transport tcp -i "rtsp://root:[email protected]/axis-media/media.amp" \-f segment -segment_time 300 -segment_format mp4 -
reset_timestamps 1 \-strftime 1 -c copy -map 0 /disk99/backright/backrightb--d-%Y-%H-%M.mp4
it will be worth the time when you figure it out
clint
RE: Help with piping rtsp-link from Ubiquiti ip-cam - Added by Allan Caldas over 1 year ago
Does anyone have any news about this?
Would you like to include security cameras with rtsp protocol in HeadEnd TV?
Any news