-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart
More file actions
executable file
·89 lines (73 loc) · 2.01 KB
/
Copy pathstart
File metadata and controls
executable file
·89 lines (73 loc) · 2.01 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
#-----------------------------------------------------------------------------------
# This script is to:
# 1. run stream server: rtsp/rtmp/hls
# 2. init video stream
#
# Author: Hao Feng (F1)
#
# Init Date: Dec. 15, 2022
# Last Date: Mar. 27, 2023
#
# Copyright (c) 2022-, FATAVAY CO., LTD.
#-----------------------------------------------------------------------------------
#--- parse setting yaml file
set_file="setting.yaml"
# dirs
logs_dir=`cat $set_file | yq '.dir.logs'`
hls_dir=`cat $set_file | yq '.dir.hls'`
run_dir=`cat $set_file | yq '.dir.run'`
server_dir=`cat $set_file | yq '.dir.server'`
# if save video files
if_save=`cat $set_file | yq '.save'`
# port
http_port=`cat $set_file | yq '.port.http'`
rtsp_port=`cat $set_file | yq '.port.rtsp'`
rtmp_port=`cat $set_file | yq '.port.rtmp'`
# -----
# python environment
os=`uname`
python_dir=`cat $set_file | yq '.dir.python'`
# -----
# activate python environment
source $python_dir/envs/bin/activate
# -----
# start server
echo
echo " start rtsp server ... "
cd $server_dir
nohup ./rtsp-simple-server.$os >& ../$logs_dir/server.log &
cd ..
sleep 2
echo
echo " start http server ... "
nohup python $run_dir/start_http.py $http_port >& $logs_dir/http.log &
sleep 2
# -----
# start streams
#streams=(c1 c2 2k 4k bd fight)
#streams=(c1 c2 2k 4k)
streams=`cat $set_file | yq '.stream[]'`
echo " streams: $streams"
echo
echo " start streams ... "
cd $run_dir
for s in ${streams[@]}; do
echo " - s = $s "
nohup bash ./stream.s $s $rtsp_port $rtmp_port $if_save >& ../$logs_dir/$s.log &
done
cd ..
# -----
# clean *.ts
time=`cat $set_file | yq '.clean.time'`
remain=`cat $set_file | yq '.clean.remain'`
cd $run_dir
nohup bash ./clean.s $time $remain ${streams[@]} >& ../$logs_dir/clean.log &
# -----
#
echo
echo " video stream address is like: "
echo " - http://127.0.0.1:$http_port/hls/${streams[0]}.m3u8"
echo " - rstp://127.0.0.1:$rtsp_port/rtsp/${streams[0]}.live"
echo " - rstp://127.0.0.1:$rtmp_port/rtmp/${streams[0]}.live"
echo