๐Ÿ“ฆ Dregu / janus-record

๐Ÿ“„ record ยท 25 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#!/bin/bash
if [ -z "$1" ] || [ ! -z "$2" ]; then
        echo Usage: ./record \<basename\|stop\>
        exit
fi
SECRET=secret
ID=1
PATH=/home/dregu/record/
CURL="/usr/bin/curl -s"
JQ=/usr/bin/jq
DATE=$(/bin/date +%s)
if [ "$1" == "stop" ]; then
	ACTION=stop
	VIDEO=true
	AUDIO=true
else
	ACTION=start
	AUDIO="\"${PATH}${1}-audio\""
	VIDEO="\"${PATH}${1}-video\""
fi
SESSION=$($CURL -X "POST" http://localhost:8088/janus/ -d "{\"janus\": \"create\", \"transaction\": \"${DATE}s\"}" -H "Content-type: application/json" | $JQ '.data.id')
HANDLE=$($CURL -X "POST" http://localhost:8088/janus/$SESSION -d "{\"janus\": \"attach\", \"transaction\": \"${DATE}h\", \"plugin\": \"janus.plugin.streaming\"}" -H "Content-type: application/json" | $JQ '.data.id')
RESPONSE=$($CURL -X "POST" http://localhost:8088/janus/$SESSION/$HANDLE -d "{\"janus\": \"message\", \"transaction\": \"${DATE}r\", \"body\": {\"request\": \"recording\", \"action\": \"$ACTION\", \"id\": $ID, \"audio\": $AUDIO, \"video\": $VIDEO, \"secret\": \"$SECRET\"}}" -H "Content-type: application/json" | $JQ '.plugindata.data.streaming')
echo $RESPONSE