Closed Kehvarl closed 1 year ago
It appears to be an MJPEG stream so you need to set some additional config options for the camera. Try this config and see if it works any better:
ffmpeg:
camera:
camera_1: # This value has to be unique across all cameras
ffmpeg_loglevel: debug
ffprobe_loglevel: debug
name: Cam 1
host: <ip>
port: 80
path: /control/faststream.jpg?stream=full
input_args:
- f
- mxg
- vsync
- 0
fps: 25
username: <user>
password: <password>
stream_format: mjpeg
protocol: http
If that does not work, please provide the full log during Viserons startup
Still can't get it to load the view. I did have to make a couple more changes to the config to get to this point (Viseron Startup Output attached)
New error:
[2023-07-03 11:48:47] [ERROR ] [viseron.components.ffmpeg.camera.camera_1] - FFmpeg process has exited
[2023-07-03 11:48:52] [ERROR ] [viseron.components.ffmpeg.camera.camera_1] - Restarting frame pipe
Current Config
ffmpeg:
camera:
camera_1: # This value has to be unique across all cameras
ffmpeg_loglevel: trace
ffprobe_loglevel: debug
name: Cam1
host: <IP>
port: 80
path: /control/faststream.jpg?stream=full&fps=10
fps: 10
input_args:
[Viseron_Startup.txt](https://github.com/roflcoopter/viseron/files/11940279/Viseron_Startup.txt)
- f
- mxg
- vsync
- "0"
username: <user>
password: <password>
stream_format: mjpeg
protocol: http
Could you enable debug logging? This will let me see the generated FFmpeg command
logger:
default_level: debug
After enabling logging, I went through again and tried to fix the problem. My new config is:
ffmpeg:
camera:
camera_1: # This value has to be unique across all cameras
ffmpeg_loglevel: trace
ffprobe_loglevel: debug
name: Cam1
host: !secret camera1_ip
port: 80
path: /control/faststream.jpg?stream=full&fps=10
fps: 10
input_args:
- -vsync
- "0"
- -f
- mxg
username: !secret camera1_username
password: !secret camera1_password
#stream_format: mjpeg
rtsp_transport: http
protocol: http
With these changes, according to the logging, the FFMpeg command is:
[2023-07-05 09:28:35] [DEBUG ] [viseron.components.ffmpeg.stream.camera_1] - FFmpeg decoder command: ffmpeg_camera_1 -hide_banner -loglevel trace -vsync 0 -f mxg -rtsp_transport http -i http://*****:*****@<IP>:80/control/faststream.jpg?stream=full&fps=10 -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 -c:v copy /segments/camera_1/%Y%m%d%H%M%S.mp4 -vf fps=1.0 -f rawvideo -pix_fmt nv12 pipe:1
Dropping into the shell, I tried this command directly:
ffmpeg -hide_banner -loglevel trace -vsync 0 -f mxg -rtsp_transport http -i http://*****:*****@<IP>:80/control/faststream.jpg?stream=full&fps=10 -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 -c:v copy /segments/camera_1/%Y%m%d%H%M%S.mp4 -vf fps=1.0 -f rawvideo -pix_fmt nv12
It fails with an error:
Option rtsp_transport not found.
After removing -rtsp_transport http
:
ffmpeg -hide_banner -loglevel trace -vsync 0 -f mxg -i "http://*****:*****@<IP>:80/control/faststream.jpg?stream=full&fps=10" -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 -c:v copy /segments/camera_1/%Y%m%d%H%M%S.mp4 -vf fps=1.0 -f rawvideo -pix_fmt nv12
It fails with repeated error:
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
Last message repeated 109 times
Once I ctrl+c the stream, I then get:
Finishing stream 0:1 without any data written to it.
detected 4 logical cores
[graph_0_in_0_1 @ 0x55abbafa80] Setting 'time_base' to value '1/8000'
[graph_0_in_0_1 @ 0x55abbafa80] Setting 'sample_rate' to value '8000'
[graph_0_in_0_1 @ 0x55abbafa80] Setting 'sample_fmt' to value 's16'
[graph_0_in_0_1 @ 0x55abbafa80] Setting 'channel_layout' to value '0x4'
[graph_0_in_0_1 @ 0x55abbafa80] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x4
[format_out_0_1 @ 0x55abbafe40] Setting 'sample_fmts' to value 'fltp'
[format_out_0_1 @ 0x55abbafe40] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350'
[format_out_0_1 @ 0x55abbafe40] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[AVFilterGraph @ 0x55abbcbda0] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto_resampler_0 @ 0x55abbb07f0] [SWR @ 0x55abbb1fa0] Using s16p internally between filters
[auto_resampler_0 @ 0x55abbb07f0] ch:1 chl:mono fmt:s16 r:8000Hz -> ch:1 chl:mono fmt:fltp r:8000Hz
[aac @ 0x55abbae870] Too many bits 8832.000000 > 6144 per frame requested, clamping to max
[segment @ 0x55abbac170] Selected stream id:0 type:video
[segment @ 0x55abbac170] Opening 'Desktop/20230705095008.mp4' for writing
[file @ 0x55abb799a0] Setting default whitelist 'file,crypto'
[mp4 @ 0x55abbcadb0] Could not find tag for codec mxpeg in stream #0, codec not currently supported in container
[AVIOContext @ 0x55abb79890] Statistics: 0 seeks, 0 writeouts
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 --
Apparently Mxpeg format segments can't be stored in an MP4 container with the -c:v copy
argument since mp4 can't hold mxpeg streams. If I force the filename to Mxpeg, it fails as well, with an argument about no streams in the file.
After experimenting a bit I found that removing -c:v copy
ffmpeg -hide_banner -loglevel trace -vsync 0 -f mxg -i "http://*****:*****@<IP>:80/control/faststream.jpg?stream=full&fps=10" -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 Desktop/%Y%m%d%H%M%S.mp4 -f rawvideo -pix_fmt nv12
Works, and creates MP4 video files.
Attached is the output with logging enabled.
Viseron.txt
I see, thanks for the great report! It appears that MXPEG (actually never heard of this before) needs some special treatment.
Will get right on it
The dev
tag now contains a new config option, raw_command
that you can use to run your custom commands.
I figured this was the best solution since i do not have a camera to test out my changes with. Let me know if you need any help to get the configuration correct. I added a section to the docs which hopefully explains it well enough: https://dev--viseron.netlify.app/components-explorer/components/ffmpeg#raw-command
Is this change up on the jetson-nano-viseron:dev
tag as well as the regular viseron:dev
tag? I'm getting an error that raw_command
is not a valid tag:
[2023-07-11 08:48:39] [ERROR ] [viseron.components] - Error validating config for domain camera and component ffmpeg: extra keys not allowed @ data['camera_1']['raw_command']. Got None
ffmpeg:
camera:
camera_1: # This value has to be unique across all cameras
name: Cam1
host: !secret camera1_ip
port: 80
path: /control/faststream.jpg?stream=full&fps=10
width: 1920
height: 1080
fps: 10
username: !secret camera1_username
password: !secret camera1_password
raw_command: |
ffmpeg -i http://<user>:<pass>@<ip>:80/control/faststream.jpg?stream=full&fps=10 -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 /segments/viseron_vscode_camera/%Y%m%d%H%M%S.mp4 -f rawvideo -pix_fmt nv12
Disregard. I did a new docker image pull
and now the command is recognized.
Thank you!
I'm trying to set up Viseron on a Jetson Nano to act as an NVR for some Mobotix M26 cameras. The streams from these cameras can be accessed either using their onvif profile or through their faststream url, which is the preferred method.
I've tested that the faststream URL opens in VLC and also can be recorded using FFMpeg from the command line, which works without issue. However, I'm having problems getting Viseron to connect.
I receive this error message:
If I run FFProbe from the command line as such:
ffprobe -i "http://<user>:<pass>@<IP>:80/control/faststream.jpg?stream=full"
I get a valid response:Likewise, using FFMpeg from the commandlline:
ffmpeg -f mxg -vsync 0 -i "http://**********:**********@**********/control/faststream.jpg?stream=full" Desktop/test.mp4
Works to create a video clip, so I know the FFMpeg on the Jetson can handle the cameras.My current Camera Domain configuration.