Closed anderbak closed 3 years ago
I use the following command to record a video to a number of separate files of nearly fixed duration:
ffmpeg -hide_banner -loglevel warning -i rtsp://192.168.1.64:554/Streaming/Channels/101 -c copy -f segment -segment_time 120 -reset_timestamps 1 -strftime 1 -y "capture-%Y-%m-%d %H-%M-%S.mp4"
The command is triggered by AppDaemon when the system is armed and a person is detected. That video is streamed directly from the camera. Sample config is here.
To record the video stream from Watsor (with rendered object detections) add ffmpeg.encoder
section in config:
ffmpeg:
decoder:
...
encoder:
- -hide_banner
- -loglevel
- error
- -hwaccel
- vaapi
- -hwaccel_device
- /dev/dri/renderD128
- -hwaccel_output_format
- yuv420p
- -f
- rawvideo
- -pix_fmt
- rgb24
- -i # detection output stream will follow -input ffmpeg argument automatically
- -an
- -f
- mp4
- -vcodec
- libx264
- -pix_fmt
- yuv420p
- -y
- -vf
- "drawtext='text=%{localtime\\:%c}': x=w-tw-lh: y=h-2*lh: fontcolor=white: box=1: boxcolor=black@0.55"
- -f
- segment
- -segment_time
- 120
- -reset_timestamps
- 1
- -strftime
- 1
and then output: !ENV "${HOME}/Videos/detect-%Y-%m-%d %H-%M-%S.mp4"
Note that hwaccel
options are optional and intended to enable video hardware acceleration.
It seems availability of strftime
option depends on ffmpeg version. Some distributions may not have it.
This is exactly what I was looking for. Thank you very much!
Great job with this. Super easy to use. Successfully using it with with Nvidia Pascal GPU pushing MQTT to Home Assistant.
I'm struggling with something I think should be simple, I don't think this is an issue - just a lack of understanding on my part.
I'd like the filename to include the date and time so recordings can be easily found, but I can't seem to get the syntax right.
I'm tying to do something like output: !ENV "/recordings/south/202011231928.mp4"
Date formatted like YYYYMMDDHHMM.
Any help is appreciated! Thanks.