sclaflin / Plate-Minder

Monitor a video source for license plates and record them. Zero cloud dependencies.
MIT License
155 stars 22 forks source link

Details on how to debug? #16

Closed Deckoz2302 closed 1 year ago

Deckoz2302 commented 2 years ago

So, I've got the stack up and running. Temporarily on Windows docker desktop. The web UI connects to plate-minder and updates the config file. Manually uploading or posting to oalpr via localhost:3000 works as well images from my cameras, or MP4 as the file source in plate-minder work

But I've tried RTSP streams and mjpeg streams with no results. Where as the same h264 recorded video as a file source from frigate from that RTSP stream does work.

How can I find out why nothing is being detected over RTSP or mjpeg RTSP?

sclaflin commented 1 year ago

If uploading still images to the openALPR wrapper works, the web UI is working, and manually configured mp4 files from the camera work, the only obvious thing left is that the H264 source stream isn't entered correctly.

If there's a problem with the stream, you should be able to see error messages from the web UI. For example:

image

If you're not seeing error messages, it's probably picked up the stream correctly. You can confirm this by adding a motion filter and toggling on the "Debug Image" option. You should see cropped sections of your stream where motion was detected.

If you've gotten to this point, then I'd look at the stream quality you're getting. It's possible you're running a low-res stream and the image quality isn't fine enough to make out a license plate.

Deckoz2302 commented 1 year ago

So I've tried multiple streams. Most of my streams are 4k h264, or 1080p. Using quality sensors. The snapshots(jpeg)or recordings work great for direct upload to oalpr or as a file source. Which were recorded from the RTSP stream I am using.

I don't get errors like you have posted , but about once every 5 minutes I see a 'stream has no output[0]' or something along those lines.

I doubt it is the stream quality. Here are a couple of still jpeg from the camera. I can Include an MP4 as well if needed. But I am using the main RTSP feed, not substreams. I'm also using intel quicksync. Rtsp of these events results in nothing, but MP4 or jpeg of these events as a file source works completely fine.

Removed Images.

Deckoz2302 commented 1 year ago

Forgot to mention, enabling debug with motion filter, shows no image. But just shows the broken image symbol, for both RTSP and file sources.

image

These are Dahua camera's so the rtsp stream is in the format

rtsp://username:password@192.168.XXX.XXX:554/cam/realmonitor?channel=1&subtype=0

subtype=0 is the main full resolution rtsp stream. here are a couple examples of that stream's config. Which I utilize in Frigate for full resolution recording - that work 100%

image image

Deckoz2302 commented 1 year ago

Removed Image

Here's a terrible MP4 used as a file source, that doesn't work as RTSP.

Sorry for three comments. Just trying to provide as much as I can, or at least enough so you can see I am truly having trouble with RTSP. As RTSP or mjpeg. Not recognition itself

sclaflin commented 1 year ago

That you can't see a debug image while using the camera rtsp stream is concerning. When you use a pre-recorded video, do debug images show up with that? If so, it does seem like something is going wrong when streaming.

You could monitor the log output of the plate-minder container to see if there's any meaningful errors.

Plate-minder uses ffmpeg to convert sources (rtsp, mp4 files, etc) into mjpeg streams. Maybe try running ffmpeg from within the plate-minder container to see if you get any errors:

/usr/lib/jellyfin-ffmpeg/ffmpeg -hide_banner -loglevel error -i "rtsp://username:[password@192.168.XXX.XXX](mailto:password@192.168.XXX.XXX):554/cam/realmonitor?channel=1&subtype=0" -f mjpeg -q:v 4 -r 1/1 -an out.mjpeg

If it works correctly, it shouldn't output anything to the screen and should start streaming to an "out.mjpeg" file. You'll have to close the program (CTRL+C) to get it to stop.

Deckoz2302 commented 1 year ago

So

image

sclaflin commented 1 year ago

ffmpeg seems happy, so that's not the problem. It's strange that there were no errors reported, yet you can't see an out.mjpeg file within your current directory.

The plate-minder project runs in the /app path of the container. Try changing to that path and try running the ffmpeg command again for a few moments. You should see the out.mjpeg file there.

When you streamed the mp4 file, were you able to see debug images through the web UI?

Deckoz2302 commented 1 year ago

I was indeed running from the /app directory

One thing I noticed in the output is Failed to parse interval end specification

and SDP is reporting 0.0.0.0?

[rtsp @ 0x5615887f1ac0] SDP: v=0 o=- 2252014719 2252014719 IN IP4 0.0.0.0 s=Media Server c=IN IP4 0.0.0.0 t=0 0 a=control:* a=packetization-supported:DH a=rtppayload-supported:DH a=range:npt=now- m=video 0 RTP/AVP 96 a=control:trackID=0 a=framerate:30.000000 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1;profile-level-id=4D002A;sprop-parameter-sets=Z00AKpY1QPAET8s3BQEFQAAAAwBAAAAPIQA=,aO4xsgA= a=recvonly

When I stream the MP4 recorded from frigate from this RTSP Stream, I can indeed see debug. In frigate my ffmpeg config looks like this

ffmpeg: global_args: -hide_banner -loglevel warning hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp output_args: detect: -f rawvideo -pix_fmt yuv420p record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac rtmp: -c copy -f flv

Deckoz2302 commented 1 year ago

Here's some additional. When nothing happens, after a moment I CTRL+C to cancel and get the following in addtion to the above screenshot. image

Deckoz2302 commented 1 year ago

Ok, so I've gotten the following to work adding '-rtsp_transport tcp'

/usr/lib/jellyfin-ffmpeg/ffmpeg -hide_banner -loglevel debug -rtsp_transport tcp -i "rtsp://username:passwword@192.168.XXX.XXX:554/cam/realmonitor?channel=1&subtype=0" -f mjpeg -r 1/1 -an out.mjpeg"

which outputs the file under ./data/out.mjpeg on the host. or /app/data/out.mjpeg in the containter, when running the above command from the /app directory.

However, when I add it to my plate-miner config.yaml file as an input ARG, I am still getting no image under debug

I had to rebuild the containers, just re-up'd with docker compose and it works now with the inputargs. (doesn't work without the args)

sources:
  - type: rtsp
    name: front_left_lp_cam
    captureInterval: 1
    preInputArgs:
      - -rtsp_transport
      - tcp
    preOutputArgs: []
    alwaysRestart: true
    url: rtsp://username:passwword@192.168.XXX.XXX:554/cam/realmonitor?channel=1&subtype=0
Deckoz2302 commented 1 year ago

I've added a PR to update documentation for others. Thank you for your help

https://github.com/sclaflin/Plate-Minder/pull/17