scottlamb / moonfire-nvr

Moonfire NVR, a security camera network video recorder
Other
1.22k stars 137 forks source link

RTSP/ffmpeg: incorrect "bad cseq" log message after socket timeout #126

Closed scottlamb closed 2 years ago

scottlamb commented 3 years ago

Describe the bug Moonfire NVR logs confusing and incorrect things after a RTSP socket timeout, eg:

Apr 30 06:38:37 nuc moonfire-nvr[191256]: s-driveway-main moonfire_base::clock] getting next packet took PT10.128102479S!
Apr 30 06:38:47 nuc moonfire-nvr[191256]: s-driveway-main moonfire_ffmpeg::rtsp] 0x7fd5c406bd00: RTP: PT=60: bad cseq d186 expected=c4f3
Apr 30 06:38:47 nuc moonfire-nvr[191256]: s-driveway-main moonfire_base::clock] getting next packet took PT10.655021428S!
Apr 30 06:38:47 nuc moonfire-nvr[191256]: s-driveway-main moonfire_nvr::streamer] driveway-main: sleeping for Duration { secs: 1, nanos: 0 } after error: packet with no pts
Apr 30 06:38:48 nuc moonfire-nvr[191256]: s-driveway-main moonfire_nvr::streamer] driveway-main: Opening input: rtsp://admin:redacted@192.168.5.111/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
Apr 30 06:38:49 nuc moonfire-nvr[191256]: s-driveway-main moonfire_base::clock] opening rtsp://admin:redacted@192.168.5.111/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif took PT1.075105258S!

I got a packet capture at the same time this happened (by leaving sudo tcpdump -Uw %Y%m%d%H%M%S-driveway.pcap -s 0 -G 300 -i surveil 'host 192.168.5.111' running). Select packets I found in Wireshark (looking with filter tcp.dstport eq 54150 and rtp.channel eq 0)

pkt 64242 ts 06:38:27.106454 rtp seq 0xc4f2 ts 0x516f45e1
pkt 64243 ts 06:38:27.106468 is the NVR acking 64242
pkt 64244 ts 06:38:47.244250 rtp seq 0xc4f3 ts 0x516f45e1
...
pkt 64787 ts 06:38:47.357532 rtp seq 0cd186 ts 0x5187f267 (17.967 sec later)

Strange things here:

To Reproduce Steps to reproduce the behavior:

  1. Monitor a Dahua camera. Maybe overload it with smart codec, smart motion detection, lots of IVS rules, etc.
  2. Wait a while.

Expected behavior If the socket timeout (currently hardcoded to 10 seconds) is exceeded, Moonfire NVR should log a clear message to that effect and retry.

Server (please complete the following information):

Build from git: v0.6.3-23-ga1e78ea. ffmpeg version:

Apr 27 22:45:48 nuc moonfire-nvr[191256]: main moonfire_ffmpeg] Initialized ffmpeg. Versions:
Apr 27 22:45:48 nuc moonfire-nvr[191256]: compiled="4.2.4-1ubuntu0.1" running="4.2.4-1ubuntu0.1"
Apr 27 22:45:48 nuc moonfire-nvr[191256]: avutil: compiled=56.31.100 running=56.31.100 configuration="--prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared"
Apr 27 22:45:48 nuc moonfire-nvr[191256]: avcodec: compiled=58.54.100 running=58.54.100 configuration="--prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared"
Apr 27 22:45:48 nuc moonfire-nvr[191256]: avformat: compiled=58.29.100 running=58.29.100 configuration="--prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared"

Camera (please complete the following information):

Desktop (please complete the following information): n/a

Smartphone (please complete the following information): n/a

Additional context Add any other context about the problem here.