CESNET / UltraGrid

UltraGrid low-latency audio and video network transmission system
http://www.ultragrid.cz
Other
490 stars 55 forks source link

problems with RTSP client for PTZ Optics HD Box camera #400

Open MartinPulec opened 1 month ago

MartinPulec commented 1 month ago

Apologies to resurrect this old discussion, but I seem to be having some issues here - FFPLAY works fine;

ffplay -v verbose rtsp://admin:admin@192.168.1.15/1
ffplay version 6.1.1 Copyright (c) 2003-2023 the FFmpeg developers
  built with gcc 14 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-lcms2 --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcodec2 --enable-libcdio --enable-libdrm --enable-libjack --enable-libjxl --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-libplacebo --enable-librsvg --enable-librav1e --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libshaderc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libvpl --enable-runtime-cpudetect
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Initialized opengl renderer.
[tcp @ 0x7f5160003780] Starting connection attempt to 192.168.1.15 port 554
[tcp @ 0x7f5160003780] Successfully connected to 192.168.1.15 port 554
[rtsp @ 0x7f5160000c80] SDP:aq=    0KB vq=    0KB sq=    0B f=0/0   
v=0
o=CameraStreaming 3132335948 1236907222000 IN IP4 192.168.1.15
s=10
c=IN IP4 0.0.0.0
t=0 0
a=control:*
m=video 0 RTP/AVP 26
a=control:trackID=0
a=rtpmap:26 JPEG/90000
a=framesize:26 1920-1080
m=audio 0 RTP/AVP 104
a=control:trackID=1
a=rtpmap:104 MPEG4-GENERIC/48000/2
a=fmtp:104 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1190

[rtsp @ 0x7f5160000c80] setting jitter buffer size to 5000B f=0/0   
    Last message repeated 1 times
Input #0, rtsp, from 'rtsp://admin:admin@192.168.1.15/1':0B f=0/0   
  Metadata:
    title           : 10
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: mjpeg (Baseline), 1 reference frame, yuvj420p(pc, bt470bg/unknown/unknown, center), 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
[ffplay_abuffer @ 0x7f51600a7740] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:stereo
[ffplay_abuffersink @ 0x7f51600c4ec0] auto-inserting filter 'auto_aresample_0' between the filter 'ffplay_abuffer' and the filter 'ffplay_abuffersink'
[auto_aresample_0 @ 0x7f5160053500] ch:2 chl:stereo fmt:fltp r:48000Hz -> ch:2 chl:stereo fmt:s16 r:48000Hz
[ffplay_abuffer @ 0x7f51600c4ec0] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:stereo
[ffplay_abuffersink @ 0x7f5160053500] auto-inserting filter 'auto_aresample_0' between the filter 'ffplay_abuffer' and the filter 'ffplay_abuffersink'
[auto_aresample_0 @ 0x7f51600a7740] ch:2 chl:stereo fmt:fltp r:48000Hz -> ch:2 chl:stereo fmt:s16 r:48000Hz
[ffplay_buffer @ 0x7f5148118900] w:1920 h:1080 pixfmt:yuvj420p tb:1/90000 fr:30/1 sar:1/1
[auto_scale_0 @ 0x7f51481195c0] w:iw h:ih flags:'' interl:0
[ffplay_buffersink @ 0x7f5148118cc0] auto-inserting filter 'auto_scale_0' between the filter 'ffplay_buffer' and the filter 'ffplay_buffersink'
[swscaler @ 0x7f5148127a00] deprecated pixel format used, make sure you did set range correctly
[auto_scale_0 @ 0x7f51481195c0] w:1920 h:1080 fmt:yuvj420p sar:1/1 -> w:1920 h:1080 fmt:yuv420p sar:1/1 flags:0x00000004
[swscaler @ 0x7f5148127a00] deprecated pixel format used, make sure you did set range correctly
[auto_scale_0 @ 0x7f51481195c0] w:1920 h:1080 fmt:yuvj420p sar:1/1 -> w:1920 h:1080 fmt:yuv420p sar:1/1 flags:0x00000004
[swscaler @ 0x7f5148127a00] deprecated pixel format used, make sure you did set range correctly
[auto_scale_0 @ 0x7f51481195c0] w:1920 h:1080 fmt:yuvj420p sar:1/1 -> w:1920 h:1080 fmt:yuv420p sar:1/1 flags:0x00000004
[swscaler @ 0x7f5148127a00] deprecated pixel format used, make sure you did set range correctly
[auto_scale_0 @ 0x7f51481195c0] w:1920 h:1080 fmt:yuvj420p sar:1/1 -> w:1920 h:1080 fmt:yuv420p sar:1/1 flags:0x00000004
Created 1920x1080 texture with SDL_PIXELFORMAT_IYUV.

However UltraGrid is giving me some error message:

UltraGrid.AppImage -t rtsp://admin:admin@192.168.1.15/1:rtp_rx_port=554
UltraGrid 1.9.4 (tags/v1.9.4 rev a3b3cad built Jun 27 2024 07:54:18)

Display device   : none
Capture device   : rtsp
Audio capture    : none
Audio playback   : none
MTU              : 1500 B
Video compression: none
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : none

[rtsp]    cURL V7.68.0 loaded
[rtsp] RTSP/1.0 405 Method Not Allowed
[rtsp]  CSeq: 5
[rtsp] Server: Rtsp Server
[rtsp] Allow: OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN, SET_PARAMETER
[rtsp] 
[rtsp] [rtsp_teardown] curl_easy_perform(curl) failed: RTSP CSeq mismatch or invalid CSeq (85)
[rtsp error] could not configure rtsp capture properly, 
        please check your parameters. 
Exiting...

Unable to start video capture device rtsp
Unable to open capture device: rtsp
Exit

I did a few searches and found this extremely old StackOverflow post;

https://stackoverflow.com/questions/18525980/rtsp-client-sending-delimited-data-before-session-has-been-completely-set-up

The RTSP server device is a PTZ Optics HD Box camera (PoE) - it might just be that it's putting out a bad stream.

My apologies in advance if this is a poor question, and I have missed something simple.

Originally posted by @Allethrium in https://github.com/CESNET/UltraGrid/discussions/178#discussioncomment-10024003

MartinPulec commented 1 month ago

Hi, I've looked into it and make some observations and changes.

  1. there is one regression - a freeze at exit, unfortunately both in continuous and stable, now fixed in continuous, will be backported to 1.9.5
  2. the URI specification should be rather rtsp://admin:admin@192.168.1.15:554/1 (port number normally a part of the URL - rtp_rx_port specifies video RTP RX port, I don't recall any real use case for that; I've already hidden the option in help)

Except that, I've also made couple of further improvements:

  1. if the RTSP port number is the default 554, it can be omitted (3cebc5059cb, 209c6fdb); I believe that the port 80 was used implicitly
  2. added usage examples to help (2c6fe441)

The changes are already included in the continuous build. Please let us know if it works now with the proposed RTSP port syntax.

Allethrium commented 1 month ago

The changes in the continuous build are a big improvement, thank you !

Unfortunately I still can't get rtsp working from this device, but that seems to be more a problem with the device itself. I am going to poke at it more and try to see what's going on.

Just out of interest: is there a verbose switch I can use for UG to see more complete logging?

Allethrium commented 1 month ago

So I just tried a passthrough from the camera device with ffmpeg to the MediaMTX/Simple RTMP server with similar results.

UG Command Line: UltraGrid.AppImage --tool uv --control-port 6160 -f V:rs:200:250 -t rtsp://192.168.1.32:8554/stream -c libavcodec:encoder=libaom-av1:usage=realtime:cpu-used=8:safe -P 5005  9000 192.168.1.32

Output:

UltraGrid 1.9+ (master rev ef8c7d4 built Jul 16 2024 11:27:47)

Display device   : none
Capture device   : rtsp
Audio capture    : none
Audio playback   : none
MTU              : 9000 B
Video compression: libavcodec:encoder=libaom-av1:usage=realtime:cpu-used=8:safe
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : rs:200:250

[rtsp] Using URI rtsp://192.168.1.32:8554/stream
[rtsp]    cURL V7.68.0 loaded
[rtsp] RTSP/1.0 501 Not Implemented
[rtsp] CSeq: 3
[rtsp] Server: gortsplib
[rtsp] 
Unable to start video capture device rtsp
Unable to open capture device: rtsp
Exit

FFMPEG command (stream copy):

ffmpeg -i rtsp://admin:admin@192.168.1.15:554/1 -c copy -f rtsp rtsp://localhost:8554/stream

VLC is able to open the stream, so it appears that everything is working, however UG is not picking it up.

Adding a slash gives me a slightly different output that's more in line with what attempting a direct connection to the camera device gives:


[rtsp] Using URI rtsp://192.168.1.32:8554/stream/
[rtsp]    cURL V7.68.0 loaded
[rtsp] RTSP/1.0 400 Bad Request
[rtsp] CSeq: 2
[rtsp] Server: gortsplib
[rtsp] 
[rtsp] [rtsp_teardown] curl_easy_perform(curl) failed: RTSP CSeq mismatch or invalid CSeq (85)
[rtsp error] could not configure rtsp capture properly, 
        please check your parameters. 
Exiting...

Unable to start video capture device rtsp
Unable to open capture device: rtsp
Exit

The RTSP server is outputting only this:


2024/07/17 15:33:33 INF [RTSP] [conn 192.168.1.32:34242] opened
2024/07/17 15:33:33 INF [RTSP] [conn 192.168.1.32:34242] closed: EOF

Obviously even If I could get it working this way, it's not a practical solution as the ffmpeg binary and rtsp server introduces a horrendous latency, but I figured I would try it out to provide more information.

For completeness sake here is the command I used to launch the mediaserver container:

podman run --network=host -p 8554:8554 -p 1935:1935 -p 8888:8888 -p 8889:8889 -p 8890:8890/udp -p 8189:8189/udp bluenviron/mediamtx:latest

MartinPulec commented 1 month ago

Just out of interest: is there a verbose switch I can use for UG to see more complete logging?

Sure, -V (verbose), -VV debug, -VVV (debug2) or --verbose=<level>. But specifically with rtsp capture module there is not much more logging in "verbose" mode.

Anyways, related to this, I've just added a verbose logging of the options that are being set to see, what exactly does the RTSP/1.0 501 Not Implemented error cause. It should be rebuilt already in continuous for Linux (and hopefully for other platforms few moments later). Would it be possible to re-run UG now with -V? I don't need the whole output, several lines between the error 501 would be sufficient.

FFMPEG command (stream copy):

ffmpeg -i rtsp://admin:admin@192.168.1.15:554/1 -c copy -f rtsp rtsp://localhost:8554/stream

Thanks, I'll try tomorrow to see if I am able to reproduce.

Adding a slash gives me a slightly different output that's more in line with what attempting a direct connection to the camera device gives:

I am not expert on RTSP URI syntax but it may be possible, that the slash isn't allowed there.

I hope that I'll be able to give you more info if I am able to to reproduce with FFmpeg. At least I've just noticed a potential problem in the output:

[1721315141.229] [rtsp] Setting CURLOPT_USERNAME to 0x7451f5f7c810
[1721315141.230] [rtsp] Setting CURLOPT_PASSWORD to 0x7451f5f7cdf0

even when user:pass is not provided in URI, which I suppose is not correct.

Allethrium commented 1 month ago

Great - Here is the output from the new continuous build with the command UltraGrid.AppImage --tool uv --control-port 6160 -f V:rs:200:250 -t rtsp://admin:admin@192.168.1.15/1:decompress -c libavcodec:encoder=libaom-av1:usage=realtime:cpu-used=8:safe -P 5004 -m 9000 192.168.1.32 -VV

UltraGrid 1.9+ (master rev f7dd228 built Jul 18 2024 15:08:14)

Display device   : none
Capture device   : rtsp
Audio capture    : none
Audio playback   : none
MTU              : 9000 B
Video compression: libavcodec:encoder=libaom-av1:usage=realtime:cpu-used=8:safe
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : rs:200:250

[1721317937.898] [module] Locking lock 0x7ffe213a16b8
[1721317937.898] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.898] [module] Locking lock 0x7ffe213a16b8
[1721317937.898] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.898] [module] Locking lock 0x7ffe213a16b8
[1721317937.898] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.898] [module] Locking lock 0x562fd76e1a70
[1721317937.898] [module] Unlocking lock 0x562fd76e1a70
[1721317937.898] [module] Locking lock 0x562fd76e1a70
[1721317937.898] [module] Unlocking lock 0x562fd76e1a70
[1721317937.898] [module] Locking lock 0x562fd76e1bc0
[1721317937.898] [module] Unlocking lock 0x562fd76e1bc0
[1721317937.898] [module] Locking lock 0x7ffe213a16b8
[1721317937.898] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.898] Display initialized-none
[1721317937.898] [module] Locking lock 0x7ffe213a16b8
[1721317937.898] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.898] [rtsp] Using URI rtsp://admin:admin@192.168.1.15:554/1
[1721317937.900] Found empty UDP port pair 54954/54955
[1721317937.901] Connected IP version 6
    Last message repeated 1 times
[1721317937.901] Created database entry 0x6aea69ae (1 sources)
[1721317937.901] Created new RTP session with SSRC 0x6aea69ae.
[1721317937.901] Socket recv buffer size set to 456192 B (requested 228096 B)
[1721317937.901] Socket send buffer size set to 114688 B (requested 57344 B)
[1721317937.901] Added participant 6aea69ae
[1721317937.901] [rtsp] rtp receiver init done
[1721317937.901] [rtsp] selected flags:
[1721317937.901] [rtsp]       uri: rtsp://admin:admin@192.168.1.15:554/1
[1721317937.901] [rtsp]       port: 54954
[1721317937.901] [rtsp]       decompress: 1

[rtsp]    cURL V7.68.0 loaded
[1721317937.902] [rtsp] Setting CURLOPT_NOSIGNAL to 1
[1721317937.902] [rtsp] request V1.0
[1721317937.902] [rtsp]     Project web site: http://code.google.com/p/rtsprequest/
[1721317937.902] [rtsp]     Requires cURL V7.20 or greater

[1721317937.902] [rtsp] Setting CURLOPT_NOSIGNAL to 1
[1721317937.902] [rtsp] Setting CURLOPT_VERBOSE to 1
[1721317937.902] [rtsp] Setting CURLOPT_NOPROGRESS to 1
[1721317937.902] [rtsp] Setting CURLOPT_HEADERDATA to 0x7ffe2139f940
[1721317937.902] [rtsp] Setting CURLOPT_HEADERFUNCTION to 0x7f7462906420
[1721317937.902] [rtsp] Setting CURLOPT_URL to 0x562fd76e21a8
[1721317937.902] 
[rtsp] OPTIONS rtsp://admin:admin@192.168.1.15:554/1
[1721317937.902] [rtsp] Setting CURLOPT_RTSP_STREAM_URI to rtsp://admin:admin@192.168.1.15:554/1
[1721317937.902] [rtsp] Setting CURLOPT_USERNAME to 0x7ffe213a0140
[1721317937.902] [rtsp] Setting CURLOPT_PASSWORD to 0x7ffe213a0720
[1721317937.902] [rtsp] Setting CURLOPT_RTSP_REQUEST to 1
*   Trying 192.168.1.15:554...
* TCP_NODELAY set
* Connected to 192.168.1.15 (192.168.1.15) port 554 (#0)
* Server auth using Basic with user 'admin'
> OPTIONS rtsp://admin:admin@192.168.1.15:554/1 RTSP/1.0
CSeq: 1
Authorization: Basic YWRtaW46YWRtaW4=

< RTSP/1.0 200 OK
[1721317937.925] [rtsp] RTSP/1.0 200 OK
< CSeq: 1
[1721317937.925] [rtsp] CSeq: 1
< Public: OPTIONS,DESCRIBE,SETUP,TEARDOWN,PLAY,SET_PARAMETER,GET_PARAMETER
[1721317937.925] [rtsp] Public: OPTIONS,DESCRIBE,SETUP,TEARDOWN,PLAY,SET_PARAMETER,GET_PARAMETER
[1721317937.925] [rtsp] 
< 
* Connection #0 to host 192.168.1.15 left intact
[1721317937.925] 
[rtsp] DESCRIBE rtsp://admin:admin@192.168.1.15:554/1
[1721317937.925] [rtsp] Setting CURLOPT_WRITEDATA to 0x562fd75c4530
[1721317937.925] [rtsp] Setting CURLOPT_RTSP_REQUEST to 2
* Found bundle for host 192.168.1.15: 0x562fd7707ce0 [serially]
* Re-using existing connection! (#0) with host 192.168.1.15
* Connected to 192.168.1.15 (192.168.1.15) port 554 (#0)
* Server auth using Basic with user 'admin'
> DESCRIBE rtsp://admin:admin@192.168.1.15:554/1 RTSP/1.0
CSeq: 2
Accept: application/sdp
Authorization: Basic YWRtaW46YWRtaW4=

< RTSP/1.0 200 OK
[1721317937.936] [rtsp] RTSP/1.0 200 OK
< CSeq: 2
[1721317937.936] [rtsp] CSeq: 2
< Content-Type: application/sdp
[1721317937.936] [rtsp] Content-Type: application/sdp
< Cache-Control: must-revalidate
[1721317937.936] [rtsp] Cache-Control: must-revalidate
< Content-Length: 402
[1721317937.936] [rtsp] Content-Length: 402
< Content-Base: rtsp://admin:admin@192.168.1.15:554/1
[1721317937.936] [rtsp] Content-Base: rtsp://admin:admin@192.168.1.15:554/1
[1721317937.936] [rtsp] 
< 
* Connection #0 to host 192.168.1.15 left intact
[1721317937.936] [rtsp] Setting CURLOPT_WRITEDATA to 0x7f746a5f75c0
[rtsp] SDP:
[rtsp] v=0
[rtsp] o=CameraStreaming 3132335948 1236907222000 IN IP4 192.168.1.15
[rtsp] s=10
[rtsp] c=IN IP4 0.0.0.0
[rtsp] t=0 0
[rtsp] a=control:*
[rtsp] m=video 0 RTP/AVP 26
[rtsp] a=control:trackID=0
[rtsp] a=rtpmap:26 JPEG/90000
[rtsp] a=framesize:26 1920-1080
[rtsp] m=audio 0 RTP/AVP 104
[rtsp] a=control:trackID=1
[rtsp] a=rtpmap:104 MPEG4-GENERIC/48000/2
[rtsp] a=fmtp:104 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1190
[rtsp] 

[1721317937.936] [rtsp] TRACK = trackID=0 FOR CODEC = 
[1721317937.936] [rtsp] TRACK = trackID=1 FOR CODEC = 

 0        0
 1        0
 2        0
 3        0
 4        0
 5        0
 6        0
 7        0
 8        0
 9        0

Lost:              0
Intervals:         0
Total:             0
ooo:               0 --    -nan

[1721317937.936] 
[rtsp] TEARDOWN rtsp://admin:admin@192.168.1.15:554/1
[1721317937.936] [rtsp] Setting CURLOPT_RTSP_REQUEST to 7
* Found bundle for host 192.168.1.15: 0x562fd7707ce0 [serially]
* Re-using existing connection! (#0) with host 192.168.1.15
* Connected to 192.168.1.15 (192.168.1.15) port 554 (#0)
* Server auth using Basic with user 'admin'
> TEARDOWN rtsp://admin:admin@192.168.1.15:554/1 RTSP/1.0
CSeq: 3
Authorization: Basic YWRtaW46YWRtaW4=

< RTSP/1.0 405 Method Not Allowed
[1721317937.938] [rtsp] RTSP/1.0 405 Method Not Allowed
<  CSeq: 5
[1721317937.938] [rtsp]  CSeq: 5
< Server: Rtsp Server
[1721317937.938] [rtsp] Server: Rtsp Server
< Allow: OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN, SET_PARAMETER
[1721317937.938] [rtsp] Allow: OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN, SET_PARAMETER
[1721317937.938] [rtsp] 
< 
* The CSeq of this request 3 did not match the response 0
* Connection #0 to host 192.168.1.15 left intact
[1721317937.938] [rtsp] [rtsp_teardown] curl_easy_perform(curl) failed: RTSP CSeq mismatch or invalid CSeq (85)
[rtsp error] could not configure rtsp capture properly, 
        please check your parameters. 
Exiting...

[1721317937.938] Unable to start video capture device rtsp
[1721317937.938] [module] Locking lock 0x7ffe213a16b8
[1721317937.938] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.938] [module] Locking lock 0x562fd76e20d8
[1721317937.938] [module] Unlocking lock 0x562fd76e20d8
Unable to open capture device: rtsp
[1721317937.938] [module] Locking lock 0x7ffe213a16b8
[1721317937.938] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.938] [module] Locking lock 0x562fd75c5bd8
[1721317937.938] [module] Unlocking lock 0x562fd75c5bd8
[1721317937.938] [module] Locking lock 0x562fd76e1bc0
[1721317937.938] [module] Unlocking lock 0x562fd76e1bc0
[1721317937.938] [module] Locking lock 0x562fd76e1c88
[1721317937.938] [module] Unlocking lock 0x562fd76e1c88
[1721317937.938] [module] Locking lock 0x562fd76e1a70
[1721317937.938] [module] Unlocking lock 0x562fd76e1a70
[1721317937.938] [module] Locking lock 0x562fd76e1bc0
[1721317937.938] [module] Unlocking lock 0x562fd76e1bc0
[1721317937.938] [module] Locking lock 0x562fd76e1a70
[1721317937.938] [module] Unlocking lock 0x562fd76e1a70
[1721317937.938] [module] Locking lock 0x562fd76e1b20
[1721317937.938] [module] Unlocking lock 0x562fd76e1b20
[1721317937.938] [module] Locking lock 0x7ffe213a16b8
[1721317937.938] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.938] [module] Locking lock 0x562fd76e1a70
[1721317937.938] [module] Unlocking lock 0x562fd76e1a70
[1721317937.938] [module] Locking lock 0x7ffe213a16b8
[1721317937.938] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.938] [module] Locking lock 0x562fd76e1fb8
[1721317937.938] [module] Unlocking lock 0x562fd76e1fb8
[1721317937.938] [module] Locking lock 0x7ffe213a16b8
[1721317937.938] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.938] [module] Locking lock 0x562fd75c52a8
[1721317937.938] [module] Unlocking lock 0x562fd75c52a8
[1721317937.938] [module] Locking lock 0x7ffe213a16b8
[1721317937.938] [module] Unlocking lock 0x7ffe213a16b8
[1721317937.938] [module] Locking lock 0x562fd76e1838
[1721317937.938] [module] Unlocking lock 0x562fd76e1838
Exit
[1721317937.962] [module] Locking lock 0x7ffe213a16b8
[1721317937.962] [module] Unlocking lock 0x7ffe213a16b8
MartinPulec commented 1 month ago

Great, thanks for the UltraGrid output.

I think that I can see the current problem now. In your SDP, there is:

[rtsp] m=video 0 RTP/AVP 26
[rtsp] a=control:trackID=0
[rtsp] a=rtpmap:26 JPEG/90000
[rtsp] a=framesize:26 1920-1080
[rtsp] m=audio 0 RTP/AVP 104
[rtsp] a=control:trackID=1
[rtsp] a=rtpmap:104 MPEG4-GENERIC/48000/2
[rtsp] a=fmtp:104 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1190

So the video is MJPEG and audio AAC (not sure if in stream container, like MPEG PES). The current implementation of RTSP client in UltraGrid has currently quite limited set of supported codecs. I think that we can add JPEG with not so much effort. I'll see what about AAC (if it is also important for you), I don't have currently how to test (eg. if I get FFmpeg to produce one).

Allethrium commented 1 month ago

Great!

Audio isn't strictly speaking necessary for my purposes but I suppose it would be nice-to-have.

Allethrium commented 1 month ago

Just gave it a try on the recently published 1.9.5, same behavior;

UltraGrid 1.9.5 (tags/v1.9.5 rev 4c4434b built Jul 22 2024 13:07:55)

Display device   : none
Capture device   : rtsp
Audio capture    : none
Audio playback   : none
MTU              : 9000 B
Video compression: libavcodec:encoder=libaom-av1:usage=realtime:cpu-used=8:safe
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : rs:200:250

[1721658331.106] Found empty UDP port pair 60424/60425
[1721658331.106] Connected IP version 6
    Last message repeated 1 times
[1721658331.106] Socket recv buffer size set to 456192 B (requested 228096 B)
[1721658331.106] Socket send buffer size set to 114688 B (requested 57344 B)
[1721658331.106] [rtsp] rtp receiver init done
[1721658331.106] [rtsp] selected flags:
[1721658331.106] [rtsp]       uri: rtsp://admin:admin@192.168.1.15/1
[1721658331.106] [rtsp]       port: 60424
[1721658331.106] [rtsp]       decompress: 1

[rtsp]    cURL V7.68.0 loaded
[1721658331.108] [rtsp] request V1.0
[1721658331.108] [rtsp]     Project web site: http://code.google.com/p/rtsprequest/
[1721658331.108] [rtsp]     Requires cURL V7.20 or greater

[1721658331.108] 
[rtsp] OPTIONS rtsp://admin:admin@192.168.1.15/1
[1721658331.126] [rtsp] RTSP/1.0 200 OK
[1721658331.126] [rtsp] CSeq: 1
[1721658331.126] [rtsp] Public: OPTIONS,DESCRIBE,SETUP,TEARDOWN,PLAY,SET_PARAMETER,GET_PARAMETER
[1721658331.126] [rtsp] 
[1721658331.126] 
[rtsp] DESCRIBE rtsp://admin:admin@192.168.1.15/1
[1721658331.137] [rtsp] RTSP/1.0 200 OK
[1721658331.137] [rtsp] CSeq: 2
[1721658331.137] [rtsp] Content-Type: application/sdp
[1721658331.137] [rtsp] Cache-Control: must-revalidate
[1721658331.137] [rtsp] Content-Length: 402
[1721658331.137] [rtsp] Content-Base: rtsp://admin:admin@192.168.1.15/1
[1721658331.137] [rtsp] 
[rtsp] SDP:
[rtsp] v=0
[rtsp] o=CameraStreaming 3132335948 1236907222000 IN IP4 192.168.1.15
[rtsp] s=10
[rtsp] c=IN IP4 0.0.0.0
[rtsp] t=0 0
[rtsp] a=control:*
[rtsp] m=video 0 RTP/AVP 26
[rtsp] a=control:trackID=0
[rtsp] a=rtpmap:26 JPEG/90000
[rtsp] a=framesize:26 1920-1080
[rtsp] m=audio 0 RTP/AVP 104
[rtsp] a=control:trackID=1
[rtsp] a=rtpmap:104 MPEG4-GENERIC/48000/2
[rtsp] a=fmtp:104 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1190
[rtsp] 

[1721658331.137] [rtsp] TRACK = trackID=0 FOR CODEC = 
[1721658331.137] [rtsp] TRACK = trackID=1 FOR CODEC = 
[1721658331.137] 
[rtsp] TEARDOWN rtsp://admin:admin@192.168.1.15/1
[1721658331.140] [rtsp] RTSP/1.0 405 Method Not Allowed
[1721658331.140] [rtsp]  CSeq: 5
[1721658331.140] [rtsp] Server: Rtsp Server
[1721658331.140] [rtsp] Allow: OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN, SET_PARAMETER
[1721658331.140] [rtsp] 
[1721658331.140] [rtsp] [rtsp_teardown] curl_easy_perform(curl) failed: RTSP CSeq mismatch or invalid CSeq (85)
[rtsp error] could not configure rtsp capture properly, 
        please check your parameters. 
Exiting...

[1721658331.140] Unable to start video capture device rtsp
Unable to open capture device: rtsp
Exit
Allethrium commented 3 weeks ago

Tested again on this morning's continuous build - curl error gone, now the error message says "no usable video stream" as per log below;

UltraGrid 1.9+ (master rev a893667 built Jul 25 2024 14:32:36)

Display device   : none
Capture device   : rtsp
Audio capture    : none
Audio playback   : none
MTU              : 9000 B
Video compression: libavcodec:encoder=libaom-av1:usage=realtime:cpu-used=8:safe
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : rs:200:250

[1721920942.143] [module] Locking lock 0x7ffdc81b9298
[1721920942.143] [module] Unlocking lock 0x7ffdc81b9298
[1721920942.143] [module] Locking lock 0x7ffdc81b9298
[1721920942.143] [module] Unlocking lock 0x7ffdc81b9298
[1721920942.143] [module] Locking lock 0x7ffdc81b9298
[1721920942.143] [module] Unlocking lock 0x7ffdc81b9298
[1721920942.143] [module] Locking lock 0x5630224ea580
[1721920942.143] [module] Unlocking lock 0x5630224ea580
[1721920942.143] [module] Locking lock 0x5630224ea580
[1721920942.143] [module] Unlocking lock 0x5630224ea580
[1721920942.143] [module] Locking lock 0x5630224ea6d0
[1721920942.143] [module] Unlocking lock 0x5630224ea6d0
[1721920942.143] [module] Locking lock 0x7ffdc81b9298
[1721920942.143] [module] Unlocking lock 0x7ffdc81b9298
[1721920942.143] Display initialized-none
[1721920942.143] [module] Locking lock 0x7ffdc81b9298
[1721920942.143] [module] Unlocking lock 0x7ffdc81b9298
[1721920942.143] [rtsp] Using URI rtsp://admin:admin@192.168.1.15:554/1
[1721920942.145] Found empty UDP port pair 55648/55649
[1721920942.145] Connected IP version 6
    Last message repeated 1 times
[1721920942.145] Created database entry 0x51b691a7 (1 sources)
[1721920942.145] Created new RTP session with SSRC 0x51b691a7.
[1721920942.145] Socket recv buffer size set to 456192 B (requested 228096 B)
[1721920942.145] Socket send buffer size set to 114688 B (requested 57344 B)
[1721920942.145] Added participant 51b691a7
[1721920942.145] [rtsp] rtp receiver init done
[1721920942.145] [rtsp] selected flags:
[1721920942.145] [rtsp]       uri: rtsp://admin:admin@192.168.1.15:554/1
[1721920942.145] [rtsp]       port: 55648
[1721920942.145] [rtsp]       decompress: 1

[rtsp]    cURL V7.68.0 loaded
[1721920942.147] [rtsp] Setting CURLOPT_NOSIGNAL to 1
[1721920942.147] [rtsp] request V1.0
[1721920942.147] [rtsp]     Project web site: http://code.google.com/p/rtsprequest/
[1721920942.147] [rtsp]     Requires cURL V7.20 or greater

[1721920942.147] [rtsp] Setting CURLOPT_NOSIGNAL to 1
[1721920942.147] [rtsp] Setting CURLOPT_VERBOSE to 1
[1721920942.147] [rtsp] Setting CURLOPT_NOPROGRESS to 1
[1721920942.147] [rtsp] Setting CURLOPT_HEADERDATA to 0x5630224eacb0
[1721920942.147] [rtsp] Setting CURLOPT_HEADERFUNCTION to 0x7ff073903580
[1721920942.147] [rtsp] Setting CURLOPT_URL to rtsp://admin:admin@192.168.1.15:554/1
[1721920942.147] 
[rtsp] OPTIONS rtsp://admin:admin@192.168.1.15:554/1
[1721920942.147] [rtsp] Setting CURLOPT_RTSP_STREAM_URI to rtsp://admin:admin@192.168.1.15:554/1
[1721920942.147] [rtsp] Setting CURLOPT_USERNAME to admin
[1721920942.147] [rtsp] Setting CURLOPT_PASSWORD to admin
[1721920942.147] [rtsp] Setting CURLOPT_RTSP_REQUEST to 1
[1721920942.147] Performing cURL operation(s)
*   Trying 192.168.1.15:554...
* TCP_NODELAY set
* Connected to 192.168.1.15 (192.168.1.15) port 554 (#0)
* Server auth using Basic with user 'admin'
> OPTIONS rtsp://admin:admin@192.168.1.15:554/1 RTSP/1.0
CSeq: 1
Authorization: Basic YWRtaW46YWRtaW4=

< RTSP/1.0 200 OK
[1721920942.178] [rtsp] RTSP/1.0 200 OK
< CSeq: 1
[1721920942.178] [rtsp] CSeq: 1
< Public: OPTIONS,DESCRIBE,SETUP,TEARDOWN,PLAY,SET_PARAMETER,GET_PARAMETER
[1721920942.178] [rtsp] Public: OPTIONS,DESCRIBE,SETUP,TEARDOWN,PLAY,SET_PARAMETER,GET_PARAMETER
[1721920942.178] [rtsp] 
< 
* Connection #0 to host 192.168.1.15 left intact
[1721920942.178] 
[rtsp] DESCRIBE rtsp://admin:admin@192.168.1.15:554/1
[1721920942.178] [rtsp] Setting CURLOPT_WRITEDATA to 0x5630223cd530
[1721920942.178] [rtsp] Setting CURLOPT_HEADERFUNCTION to 0x7ff073903690
[1721920942.178] [rtsp] Setting CURLOPT_RTSP_REQUEST to 2
[1721920942.178] Performing cURL operation(s)
* Found bundle for host 192.168.1.15: 0x563022510c70 [serially]
* Re-using existing connection! (#0) with host 192.168.1.15
* Connected to 192.168.1.15 (192.168.1.15) port 554 (#0)
* Server auth using Basic with user 'admin'
> DESCRIBE rtsp://admin:admin@192.168.1.15:554/1 RTSP/1.0
CSeq: 2
Accept: application/sdp
Authorization: Basic YWRtaW46YWRtaW4=

< RTSP/1.0 200 OK
[1721920942.184] [rtsp] RTSP/1.0 200 OK
< CSeq: 2
[1721920942.184] [rtsp] CSeq: 2
< Content-Type: application/sdp
[1721920942.184] [rtsp] Content-Type: application/sdp
< Cache-Control: must-revalidate
[1721920942.184] [rtsp] Cache-Control: must-revalidate
< Content-Length: 402
[1721920942.184] [rtsp] Content-Length: 402
< Content-Base: rtsp://admin:admin@192.168.1.15:554/1
[1721920942.184] [rtsp] Content-Base: rtsp://admin:admin@192.168.1.15:554/1
[1721920942.184] [rtsp] Using base URL from headers: rtsp://admin:admin@192.168.1.15:554//
[1721920942.184] [rtsp] 
< 
* Connection #0 to host 192.168.1.15 left intact
[1721920942.184] [rtsp] Setting CURLOPT_WRITEDATA to 0x7ff07c9f75c0
[1721920942.184] [rtsp] Setting CURLOPT_HEADERFUNCTION to 0x7ff073903580
[rtsp] SDP:
[rtsp] v=0
[rtsp] o=CameraStreaming 3132335948 1236907222000 IN IP4 192.168.1.15
[rtsp] s=10
[rtsp] c=IN IP4 0.0.0.0
[rtsp] t=0 0
[rtsp] a=control:*
[rtsp] m=video 0 RTP/AVP 26
[rtsp] a=control:trackID=0
[rtsp] a=rtpmap:26 JPEG/90000
[rtsp] a=framesize:26 1920-1080
[rtsp] m=audio 0 RTP/AVP 104
[rtsp] a=control:trackID=1
[rtsp] a=rtpmap:104 MPEG4-GENERIC/48000/2
[rtsp] a=fmtp:104 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1190
[rtsp] 

[1721920942.184] [rtsp] Multiple media of same type, using last one...[1721920942.184] [rtsp] AUDIO TRACK = rtsp://admin:admin@192.168.1.15:554//trackID=1 FOR CODEC = MPEG4-GENERIC
[1721920942.184] [rtsp] VIDEO TRACK = rtsp://admin:admin@192.168.1.15:554//trackID=0 FOR CODEC = JPEG
[1721920942.184] [rtsp] No usable/supported video stream found!

 0        0
 1        0
 2        0
 3        0
 4        0
 5        0
 6        0
 7        0
 8        0
 9        0

Lost:              0
Intervals:         0
Total:             0
ooo:               0 --    -nan

[1721920942.184] Unable to start video capture device rtsp
[1721920942.184] [module] Locking lock 0x7ffdc81b9298
[1721920942.184] [module] Unlocking lock 0x7ffdc81b9298
[1721920942.184] [module] Locking lock 0x5630224eabe8
[1721920942.184] [module] Unlocking lock 0x5630224eabe8
Unable to open capture device: rtsp
Allethrium commented 3 weeks ago

Another update:

I was able to get into the device settings and configure it to output an H.264 stream, which DOES work fine via RTSP. However JPEG does not work, nor does H.265.

MartinPulec commented 3 weeks ago

Thanks for the update, I can confirm that for video only H.264 is currently supported for RTSP. I believe that I'll be able to add JPEG soon (H.265 could be also possible later).

MartinPulec commented 2 weeks ago

I'll be able to add JPEG soon

JPEG done, it should be already included in the continuous builds. It won't be, however, ported to UltraGrid 1.9.X but to next major version. I'd be glad if you could test - it should decode the JPEG formats specified in RFC 2435, but the format allows also custom types.