motioneye-project / motioneye

A web frontend for the motion daemon.
GNU General Public License v3.0
3.93k stars 652 forks source link

Adding RTSP stream results in grey preview, errors in log #2182

Open voidnecron opened 3 years ago

voidnecron commented 3 years ago

Hi,

I have a working MotionEyeOS on RPi 3b and a second MotionEye install on Rasbian 10. With both versions the attached USB cam (a PS3 Eye) works fine, but I can't get the RTSP added correctly. I think it has something to do with the characters in the URL which might not be escaped properly and therefor part of the URL gets dropped. Some info:

uname -a

Linux domoticz 5.4.61-v7+ #1339 SMP Tue Sep 1 18:45:30 BST 2020 armv7l GNU/Linux

cat /etc/debian_version

10.10 motionEye Version | 0.42.1 Motion Version | 4.2.2 OS Version | Raspbian 10 Camera is http://www.escam.cn/product/66-en.html RTSP stream URL is syntax as: rtsp://10.6.3.57:554/user=admin&password=&channel=1&stream=0.sdp?

I tried to add the camera as: rtsp://10.6.3.57/user=admin&password=&channel=1&stream=0.sdp? (blank field for user/pass in GUI) rtsp://10.6.3.57:554/user=admin&password=&channel=1&stream=0.sdp? (blank field for user/pass in GUI) rtsp://10.6.3.57:554/channel=1&stream=0.sdp? (filled fields for user/pass in GUI) rtsp://10.6.3.57:554/channel=1&stream=0.sdp (filled fields for user/pass in GUI) and all the above with single and double quotes, but the GUI doesn't accept quotes so you can't add the stream that way.

Log: [1:ml1:Camera1] [WRN] [ALL] mlp_retry: Retrying until successful connection with camera [1:ml1:Camera1] [ERR] [NET] netcam_rtsp_open_context: Normal resolution: Unable to open camera(Camera1): Server returned 4XX Client Error, but not one of 40{0,1,3,4} [1:ml1:Camera1] [ERR] [VID] vid_start: Netcam RTSP failed to open [1:ml1:Camera1] [ERR] [NET] netcam_rtsp_open_context: Normal resolution: Unable to open camera(Camera1): Server returned 4XX Client Error, but not one of 40{0,1,3,4} [1:ml1:Camera1] [ERR] [VID] vid_start: Netcam RTSP failed to open [1:ml1:Camera1] [WRN] [ALL] motion_init: Could not fetch initial image from camera [1:ml1:Camera1] [WRN] [ALL] motion_init: Motion continues using width and height from config file(s)

Does anyone have a clue why this could be happening? VLC plays the stream correct, but I've already read that VLC is very forgiving and motion(eye) and ffmpeg aren't... Should I escape the question marks and/or ampersands for instance?

Cheers!

starbasessd commented 3 years ago

Not usually. There are literally dozens of entries for the QD500 at: https://www.ispyconnect.com/camera/escam with fixed admin/password combinations, as well as variable. It may be that your specific camera has one of those? If your password is user-setable, could you have a non-valid character in the password? (like a '&') in it?

voidnecron commented 3 years ago

Not usually. There are literally dozens of entries for the QD500 at: https://www.ispyconnect.com/camera/escam with fixed admin/password combinations, as well as variable. It may be that your specific camera has one of those? If your password is user-setable, could you have a non-valid character in the password? (like a '&') in it?

To be sure of all variables I completely removed the password, so it's just the username 'admin' with no password at the moment. But as I mentioned and you now as well, could it be the & (ampersand sign) in the URL? And is there a way to escape it with for instance slashes?

starbasessd commented 3 years ago

& is a special trigger character (as is ? and a few others) and is used quite often in other camera URLs without issue.

voidnecron commented 3 years ago

Ok, I've tried several examples from the ispy website you mentioned on VLC to see which are supported, and all with underscored (_) don't work, and all with ampersands (&) do work: /user=admin&password=tlJwpbo6&channel=1&stream=0.sdp <- works /user=admin_password=tlJwpbo6_channel=1_stream=0.sdp <- doesn't work

So the requestion remains, why does /user=admin&password=tlJwpbo6&channel=1&stream=0.sdp work in VLC but not in MotionEye? Any clue, since you say MotionEye parses the special characters correctly.

starbasessd commented 3 years ago

When adding a camera, Add Camera, Network, you get the box: image For the URL, you use (for example) rtsp://10.6.3.57:554/channel=1&stream=0.sdp? You use Username: admin You use Password: [whatever] For Camera: Have you selected for both the TCP and UDP versions? Once the camera is added, do you select the native resolution of the camera, or something else? I can get gray screen or green screen if I select the wrong resolution. My Foscams want me to select a 16x9 (I use 1280x720 normally)

zagrim commented 3 years ago

Many of those URLs look very suspicious, I mean why would the manufacturer have build a custom URL query parameter parser to pick then up in the path (the format with parameters coming after slash (/)) when probably any HTTP server has the standard URL parsing built-in. So, what if you tried ?user=admin&password=tlJwpbo6&channel=1&stream=0.sdp instead of /user=admin&password=tlJwpbo6&channel=1&stream=0.sdp or /user=admin_password=tlJwpbo6_channel=1_stream=0.sdp (So, put question mark at the front or the parameters and separate them with ampersands, and ditch any remaining question marks from the examples)

As an example with full URL: rtsp://10.6.3.57:554?channel=1&stream=0.sdp