---
# System prepended metadata

title: 直播流相關

---


#### Curl
```=
##沒有id##
curl -s "http://127.0.0.1:1985/api/v1/streams/?count=65535" |awk -F'[' '{print $2}'|awk -F '},{' '{for(i=1; i<=NF; ++i) print $i}' | awk -F "," '{print $2" | "$4" | "$12" | "$16" "$17" "$18" | "$19" "$20" | "$21" "$22" | "$14}' | sed 's/{//g' | sed 's/\"//g' | sed 's/}//g' | sed 's/]//g' |sort -k 2

curl -s "http://127.0.0.1:1985/api/v1/streams/?count=65535" |awk -F'[' '{print $2}'|awk -F '},{' '{for(i=1; i<=NF; ++i) print $i}' | awk -F "," '{print $2" | "$4" | "$12" | "$16" "$17" "$18" | "$19" "$20" | "$14}' | sed 's/{//g' | sed 's/\"//g' | sed 's/}//g' | sed 's/]//g' |sort -k 2

name:BTCB01m | app:cb | kbps:recv_30s:1007 | video:codec:H264 profile:Baseline level:5.1 | width:1280 height:720 | audio:codec:AAC sample_rate:44100 | publish:active:true

```

#### SRS
```=
###srs rpm upgrade
rpm -Uvh srs.rpm

###srs rpm downgrade
rpm -Uvh --oldpackage srs.rpm

###srs 強制安裝新版
rpm -ivh --force srs.rpm


不論升或降板 srs.conf都不會被砍掉 所以如果有版本差異要注意conf有沒有不支援的部分

升降板之後都要restart後才會生效


###卸載
yum remove srs

srs.conf會被砍掉

#### HLS Seting

    hls {
        enabled                 on; 
        hls_caption_relay       on;    
        hls_fragment           0.9;
        hls_td_ratio             1;
        hls_window               5;    切片數量n+1
        hls_tdof_threshold     0.2;    ts 每片 1.001 時  TARGETDURATION 會認為2 ,設0.2的話1.2也會認為 1
        hls_cleanup_preserved    2;    切片保留 預設5片,設2為5+2
        #hls_cleanup             on;
        hls_path        ./objs/nginx/html;
        hls_m3u8_file   [app]/[stream].m3u8;
        hls_ts_file     [app]/[stream]-[seq].ts;
    }

```
#### SRS Log
```=
建立規則
## srslog ##

touch /etc/logrotate.d/srslog

vi /etc/logrotate.d/srslog

/usr/local/srs/objs/srs.log {
    daily
    rotate 7
    compress
    delaycompress
    copytruncate
    missingok
    dateext
    dateformat .%Y%m%d
    sharedscripts
}

加入排程
logrotate -f /etc/logrotate.d/srslog



## srs gateway log ## (flv edge)

touch /etc/logrotate.d/srsgwlog

vi /etc/logrotate.d/srsgwlog

/usr/local/srs-http-stream-gateway/logs/srs-http-stream-gateway.log {
    daily
    rotate 7
    compress
    delaycompress
    copytruncate
    missingok
    dateext
    dateformat .%Y%m%d
    sharedscripts
}

加入排程
logrotate -f /etc/logrotate.d/srsgwlog



```


#### Screen
```=
screen -ls
```

#### FFmpeg
```=
/usr/local/bin/ffmpeg -fflags nobuffer -f flv -i rtmp://127.0.0.1:1935/cb/BTCB01 -c:v copy -c:a copy -f flv rtmp://10.66.112.48:1935/cb/BTCB01
```

#### chronyc
```=
chronyc -a makestep
```

#### chkSRSStream
```=
chkSRSStream
```



#### Node.js
```=
/opt/nodejs/WSService/edge.js
Show 是看設定  
Logs 是看目前的log
pm2 list 
pm2 show IDname (0-11)
pm2 logs 
pm2 logs IDname (0-11)

刪除
npm remove pm2 -g
```
#### ffprobe
```=
ffprobe -show_frames  rtmp://127.0.0.1/mx/BTMX02 -select_streams v
```