Open mtmongoose opened 3 years ago
You dont need to specify hwaccel args when using the *_nvenc
decoders/encoders, try removing that.
If that doesnt work please paste your full config so i can look at it.
Oh, I didn't realize that. I'll try it now.
You mention _nvenc decoders/encoders. I'm only aware of an encoder that fits that naming pattern for the NVIDIA GPU. The decoder I always use is hevc_cuvid, can you point me to the decoder with a name like _nvenc?
You are right, its h264_nvenc
/hevc_nvenc
for encoding and h264_cuvid
/hevc_cuvid
for decoders
Thank you for confirming, I do appreciate your help. I'm not an FFMPEG expert.
I tried commenting out hwaccel_args, so no longer applying hardware acceleration option "cuda" and I'm getting the same results. Below is my full config yaml, beginning and ending curly braces are just for formatting within the post.
logging:
level: debug
color_log: true
object_detection:
type: deepstack
host: *********
port: 5000
image_width: 300
image_height: 300
#custom_model:
#api_key:
timeout: 10
interval: 1
labels:
- label: person
confidence: 0.5
trigger_recorder: true
require_motion: true
#- label: dog
# confidence: 0.5
# trigger_recorder: true
# require_motion: true
- label: car
confidence: 0.5
trigger_recorder: true
require_motion: true
#postprocessor:
#face_recognition:
#type: dlib
#expire_after: 10
#logging:
#level: info
recorder:
lookback: 10
timeout: 10
retain: 7
folder: /recordings
segments_folder: /ffmpeg_segments
#hwaccel_args:
#- -hwaccel
#- cuda
codec: hevc_nvenc
#audio_codec: libfdk_aac
extension: mkv
mqtt:
broker: !secret mqttIP
port: 1883
username: !secret mqttUser
password: !secret mqttPass
#enable: true
#discovery_prefix: homeassistant
cameras:
#------------------------------------------------------------------------------
#FRONT PORCH CONFIG
#------------------------------------------------------------------------------
- name: FrontPorch
#ffprobe_loglevel: debug
#ffmpeg_loglevel: debug
mqtt_name: viseron_frontporch
host: !secret frontporchIP
port: 554
username: !secret user1
password: !secret pass1
path: /cam/realmonitor?channel=1&subtype=0&unicast=true&proto=onvif
width: 2592
height: 1520
fps: 15
frame_timeout: 20
codec: hevc_cuvid
audio_codec: none
#hwaccel_args:
#- -hwaccel
#- cuda
#- -c:v
#- hevc_cuvid
#pix_fmt: yuv420p
publish_image: true
substream:
port: 554
path: /cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif
width: 704
height: 480
fps: 15
frame_timeout: 20
codec: hevc_cuvid
audio_codec: none
#hwaccel_args:
#- -hwaccel
#- cuda
#- -c:v
#- hevc_cuvid
#pix_fmt: yuv420p
static_mjpeg_streams:
large:
width: 2592
height: 1520
draw_objects: true
small:
width: 704
height: 480
draw_objects: true
motion_detection:
interval: 1
threshold: 25 #0-255
trigger_recorder: true
trigger_detector: true
timeout: true
max_timeout: 15
frames: 3
Below is what I believe to be relevant lines from the container log:
[2021-07-07 08:56:12] [DEBUG ] [viseron.cleanup ] - Items in /recordings/2021-07-07/FrontPorch: 0, [2021-07-07 08:56:12] [DEBUG ] [viseron.cleanup ] - Removing directory /recordings/2021-07-07/FrontPorch, [2021-07-07 08:56:12] [DEBUG ] [viseron.nvr.frontporch ] - Initializing NVR thread, [2021-07-07 08:56:12] [DEBUG ] [viseron.camera.frontporch] - Initializing camera FrontPorch, [2021-07-07 08:56:12] [DEBUG ] [viseron.camera.frontporch] - Resolution: 704x480 @ 15 FPS, [2021-07-07 08:56:12] [DEBUG ] [viseron.camera.frontporch] - Starting decoder thread, [2021-07-07 08:56:12] [DEBUG ] [viseron.camera.frontporch] - Running decoder frontporch.object_detection at 1.0s interval, every 15.0 frame(s), [2021-07-07 08:56:12] [DEBUG ] [viseron.camera.frontporch] - Camera FrontPorch initialized, [2021-07-07 08:56:12] [DEBUG ] [viseron.motion.frontporch] - Initializing motion detector, [2021-07-07 08:56:12] [DEBUG ] [viseron.motion.frontporch] - Starting decoder thread, [2021-07-07 08:56:12] [DEBUG ] [viseron.motion.frontporch] - Running decoder frontporch.motion_detection at 1s interval, every 15 frame(s), [2021-07-07 08:56:12] [DEBUG ] [viseron.motion.frontporch] - Motion detector initialized, [2021-07-07 08:56:12] [DEBUG ] [viseron.nvr.frontporch ] - Starting camera, [2021-07-07 08:56:12] [DEBUG ] [viseron.camera.frontporch] - Starting capture thread, [2021-07-07 08:56:12] [DEBUG ] [viseron.camera.stream.frontporch] - FFMPEG decoder command: frontporch -hide_banner -loglevel error -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts -use_wallclock_as_timestamps 1 -vsync 0 -stimeout 5000000 -c:v hevc_cuvid -rtsp_transport tcp -i rtsp://:@!!!@192.168.44.6:554/cam/realmonitor?channel=1&subtype=1 -filter:v fps=1 -f rawvideo -pix_fmt nv12 pipe:1, [2021-07-07 08:56:12] [DEBUG ] [viseron.recorder.frontporch] - Initializing ffmpeg recorder, [2021-07-07 08:56:12] [DEBUG ] [viseron.camera.stream_segments.frontporch] - FFMPEG decoder command: frontporch_segments -hide_banner -loglevel error -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts -use_wallclock_as_timestamps 1 -vsync 0 -stimeout 5000000 -c:v hevc_cuvid -rtsp_transport tcp -i rtsp://:@!!!@192.168.44.6:554/cam/realmonitor?channel=1&subtype=0 -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 -c:v copy -c:a none /ffmpeg_segments/FrontPorch/%Y%m%d%H%M%S.mkv, [2021-07-07 08:56:12] [DEBUG ] [viseron.nvr.frontporch ] - Waiting for first frame, [2021-07-07 08:56:12] [DEBUG ] [viseron.nvr.frontporch ] - NVR thread initialized, [2021-07-07 08:56:12] [ERROR ] [viseron.camera.stream.frontporch] - [hevc @ 0x5628a61a04c0] VPS 0 does not exist, [2021-07-07 08:56:12] [ERROR ] [viseron.camera.stream_segments.frontporch] - [hevc @ 0x55fc5174d440] VPS 0 does not exist, [2021-07-07 08:56:14] [ERROR ] [viseron.camera.stream_segments.frontporch] - Last message repeated 1 times, [2021-07-07 08:56:14] [ERROR ] [viseron.camera.stream_segments.frontporch] - Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input, [2021-07-07 08:56:14] [ERROR ] [viseron.camera.stream_segments.frontporch] - Error initializing output stream 0:0 -- , [2021-07-07 08:56:14] [ERROR ] [viseron.camera.stream_segments.frontporch] - , [2021-07-07 08:56:14] [DEBUG ] [viseron.nvr.frontporch ] - First frame received, [2021-07-07 08:56:17] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 1, max area size: 0.61788, [2021-07-07 08:56:18] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 2, max area size: 0.37274, [2021-07-07 08:56:19] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 3, max area size: 0.35689, [2021-07-07 08:56:19] [DEBUG ] [viseron.nvr.frontporch.motion] - Motion detected, [2021-07-07 08:56:19] [DEBUG ] [viseron.nvr.frontporch ] - Starting object detector, [2021-07-07 08:56:19] [INFO ] [viseron.recorder.frontporch] - Starting recorder, [2021-07-07 08:56:19] [DEBUG ] [viseron.recorder.frontporch] - Creating folder /recordings/2021-07-07/FrontPorch, [2021-07-07 08:56:20] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 4, max area size: 0.29077, [2021-07-07 08:56:21] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:21] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 5, max area size: 0.27243, [2021-07-07 08:56:22] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:22] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 6, max area size: 0.24727, [2021-07-07 08:56:23] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:23] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 7, max area size: 0.22843, [2021-07-07 08:56:24] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:24] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 8, max area size: 0.17624, [2021-07-07 08:56:25] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:25] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 9, max area size: 0.14483, [2021-07-07 08:56:26] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:26] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 10, max area size: 0.13755, [2021-07-07 08:56:27] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:27] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 11, max area size: 0.12726, [2021-07-07 08:56:28] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:28] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 12, max area size: 0.10737, [2021-07-07 08:56:29] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:29] [DEBUG ] [viseron.nvr.frontporch.motion] - Consecutive frames with motion: 13, max area size: 0.10183, [2021-07-07 08:56:30] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:30] [DEBUG ] [viseron.nvr.frontporch.motion] - Motion stopped, [2021-07-07 08:56:30] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 9, [2021-07-07 08:56:31] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:31] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 8, [2021-07-07 08:56:32] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:32] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 7, [2021-07-07 08:56:33] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:33] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 6, [2021-07-07 08:56:34] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:34] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 5, [2021-07-07 08:56:35] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:35] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 4, [2021-07-07 08:56:36] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:36] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 3, [2021-07-07 08:56:37] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:37] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 2, [2021-07-07 08:56:38] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:38] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 1, [2021-07-07 08:56:39] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:39] [INFO ] [viseron.nvr.frontporch ] - Stopping recording in: 0, [2021-07-07 08:56:39] [INFO ] [viseron.recorder.frontporch] - Stopping recorder, [2021-07-07 08:56:39] [DEBUG ] [viseron.recorder.frontporch] - Concatenating segments, [2021-07-07 08:56:39] [ERROR ] [viseron.recorder.frontporch] - Could not get duration for: /ffmpeg_segments/FrontPorch/20210707085614.mkv. Error: /ffmpeg_segments/FrontPorch/20210707085614.mkv: End of file, [2021-07-07 08:56:39] [DEBUG ] [viseron.recorder.frontporch] - Segment information: {}, [2021-07-07 08:56:39] [ERROR ] [viseron.recorder.frontporch] - No segments were found, [2021-07-07 08:56:40] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:40] [DEBUG ] [viseron.nvr.frontporch ] - Not recording, pausing object detector, [2021-07-07 08:56:41] [DEBUG ] [viseron.nvr.frontporch.object] - Objects: [], [2021-07-07 08:56:41] [ERROR ] [viseron.watchdog.subprocess_watchdog] - Process frontporch_segments has exited, restarting,
Hmm are you sure your cameras RTSP stream is hevc
?
Can you show me the output of docker exec -it viseron ffprobe rtsp://user:pass@192.168.44.6:554/cam/realmonitor?channel=1&subtype=1
You need to add your credentials to the command
I think you might be onto something with changing up the URL used. Below are the ffprobe results with the URL you proposed:
[hevc @ 0x561e23e3b0c0] VPS 0 does not exist Last message repeated 1 times Input #0, rtsp, from 'rtsp://***@****:554/cam/realmonitor?channel=1&subtype=1': Metadata: title : Media Server Duration: N/A, start: 0.130000, bitrate: N/A Stream #0:0: Video: hevc, yuv420p(tv), 704x480, 100 tbr, 90k tbn, 90k tbc [hevc @ 0x561e23e6ebc0] VPS 0 does not exist
And here are the results with the URL I am currently using. The last line looks suspicious and seems like it correlates to this error in the debug log "Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input,"
[hevc @ 0x55eb25e5eb80] VPS 0 does not exist Last message repeated 1 times Input #0, rtsp, from 'rtsp://****@***:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif': Metadata: title : Media Server Duration: N/A, start: 0.090000, bitrate: N/A Stream #0:0: Video: hevc, yuv420p(tv), 704x480, 100 tbr, 90k tbn, 90k tbc Stream #0:1: Data: none [hevc @ 0x55eb25eb26c0] VPS 0 does not exist Unsupported codec with id 0 for input stream 1
Well I was wrong, using the shortened URL "rtsp://***@****:554/cam/realmonitor?channel=1&subtype=1", I still see the error "Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input"
I use MotioneEye and the following ffmpeg command works inside of it for recording from the same camera.
ffmpeg -hwaccel cuda -copyts -fflags +genpts -i 'rtsp://**@****:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=onvif' -c:v hevc_nvenc -reset_timestamps 1 -segment_time 8 %f.mp4
Okay that is interesting! Can you play around a little with the command and see if its one of the default flags that are causing issues?
Start with a really basic command and then add on flags like -c:v hevc_nvenc
etc etc
You can do so like this:
docker run -it --rm --entrypoint "" roflcoopter/amd64-cuda-viseron:1.8.0 ffmpeg -i "rtsp://@**:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=onvif" -f null /dev/null
I don't think it's any of the default flags. I was unable to produce a valid file no matter what flags used unless I specified an encoder, copying the decoded video stream in all cases produced a file without video (just a black screen).
I think it might be a poor implementation of X265 by Dahua or at least the firmware that is on the cameras.
Yes that seems very likely. Does this work for you or does it also error out?
docker run -it --rm --entrypoint "" roflcoopter/amd64-cuda-viseron:1.8.0 ffmpeg -hide_banner -loglevel error -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts -use_wallclock_as_timestamps 1 -vsync 0 -stimeout 5000000 -c:v hevc_cuvid -rtsp_transport tcp -i rtsp://:@!!!@192.168.44.6:554/cam/realmonitor?channel=1&subtype=0 -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 -c:v hvec_nvenc -c:a none /ffmpeg_segments/FrontPorch/%Y%m%d%H%M%S.mk
If it does work i can make a config option that you can use to specify a codec for the segements, right now copy
is hardcoded
Your provided FFMPEG command works. :-)
A parameter for specifying an encoder should do the trick and might be useful to some, albeit probably very few others also. Thank you for considering that option, since it will significantly decrease file size and some network bandwidth versus changing the cameras to use X264.
Great! I got some other stuff cooking right now but ill get to it in the coming week or so
I may take a look and see if I can submit a pull request for it. I've been looking for a project to get involved in, if you're open to that.
On Thu, Jul 8, 2021 at 4:08 PM Jesper @.***> wrote:
Great! I got some other stuff cooking right now but ill get to it in the coming week or so
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/roflcoopter/viseron/issues/249#issuecomment-876746558, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXVZ53HHWGGRRWRIFKNIEDTWYHTFANCNFSM4753Q52A .
I'm using the following recorder configuration and expecting the output for the FFMPEG command to show the encoder used as hevc_nvenc.
recorder: lookback: 10 timeout: 10 retain: 7 folder: /recordings segments_folder: /ffmpeg_segments hwaccel_args:
audio_codec: libfdk_aac
extension: mkv
Below is the FFMPEG command being generated which results in a video file being created, but the video is empty (just a blank/black screen).
FFMPEG decoder command: ******_segments -hide_banner -loglevel error -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts -use_wallclock_as_timestamps 1 -vsync 0 -stimeout 5000000 -hwaccel cuda -c:v hevc_cuvid -rtsp_transport tcp -i rtsp://*****:*****@********:554/stream0 -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 -c:v copy -c:a pcm_alaw /ffmpeg_segments/********/%Y%m%d%H%M%S.mkv