the application to record the rtsp stream into file
Install the kind, and create a cluster:
kind create clusterSet up the rbac:
kubectl apply -f ./example/premake loadkubectl apply -f ./example/deploymake test-
create a mock rtsp server, a ffmpeg service that sends the rtsp stream forever and a curl client
kubectl apply -f ./example/mocktest/client.yaml kubectl apply -f ./example/mocktest/rtsp-server.yaml kubectl apply -f ./example/mocktest/ffmpeg.yaml
-
create a secret store the username and password of the rtsp server
kubectl create secret generic test-secret --from-literal=username=admin --from-literal=password=password -n shifu-app
-
send request inside the curl container
kubectl exec curl -it -n shifu-app -- /bin/bashFor exmaple:
curl --header "Content-Type: application/json" \ --request POST --data '{"deviceName":"xyz", "secretName": "test-secret", "serverAddress":"rtsp-server.shifu-app.svc.cluster.local:8554/mystream", "record":true}' \ rtsp-record.shifu-app.svc.cluster.local/register sleep 5s curl --header "Content-Type: application/json" \ --request POST --data '{"deviceName":"xyz", "record":false}' \ rtsp-record.shifu-app.svc.cluster.local/update sleep 1s curl --header "Content-Type: application/json" \ --request POST --data '{"deviceName":"xyz", "record":true}' \ rtsp-record.shifu-app.svc.cluster.local/update sleep 5s curl --header "Content-Type: application/json" \ --request POST --data '{"deviceName":"xyz"}' \ rtsp-record.shifu-app.svc.cluster.local/unregister
Video is named {device_name}_{clip_number}_{YYYY-MM-DD_hh-mm-ss}.mp4. Use kubect cp to export the video.
POD=$(kubectl get pod -l app=rtsp-record-deployment -n shifu-app -o jsonpath="{.items[0].metadata.name}")
# list all videos
kubectl exec ${POD} -n shifu-app -- ls /data/video -hl
# export the video you want
kubectl cp shifu-app/$POD:/data/video/xyz_0_2023-01-19_08-14-35.mp4 ./video_save_name.mp4kubectl delete -f ./example/pre