Record video stream from rtsp enabled dvr camera using docker

The Real-Time Streaming Protocol (RTSP) is a tried-and-true video technology. Its used to control audio/video transmission between two endpoints and facilitate the transportation of low-latency streaming content across the internet. Most of DVRs has this rtsp option and it is very possible to record videos from camera directly in linux computer easily by using the following script.
The is the ip address of the DVR device


#!/bin/bash
#testing channel
declare -a arr=("1" "3" "5")
#for folderIndex in {1..4}
for folderIndex in "${arr[@]}"
do

docker run --rm -u $(id -u):$(id -g) --name dvr01_chnl$folderIndex -v /disk/dvr01/ch$folderIndex:/data vimagick/ffmpeg  -i "rtsp://:554/user=admin&password=&channel=$folderIndex&stream=0.sdp" -vcodec  libx264 -crf 20  -acodec copy -map 0 -f segment -strftime 1 -segment_time 300 -segment_format mp4 "/data/%Y-%m-%d_%H-%M-%S.mp4"  2>&1 >/dev/null &

done

Rasika Preethiraj

A technophile at icrony since 2012, In a quest to programmatic automations for scaled organisations through the use of python, php, autoit and machine learning


Comments


Post a Comment



Trending

Latest Posts

Tags

Newsletter

Subscribe to our newsletter for good news, sent out every month.