【发布时间】:2021-01-27 11:50:41
【问题描述】:
如何在不停止流的情况下停止间隔录制以将 Ant Media Server 中的 VoD 保存在我的流源和 IP 摄像机中?
【问题讨论】:
标签: ant-media-server
如何在不停止流的情况下停止间隔录制以将 Ant Media Server 中的 VoD 保存在我的流源和 IP 摄像机中?
【问题讨论】:
标签: ant-media-server
您可以使用 python 脚本来实现。假设你已经安装了 python3 和 pip。 以下脚本以用户定义的间隔停止并再次开始录制:
import sys
import sched, time
try:
import requests
print("requests library already installed!")
except ImportError:
try:
import pip
print("requests library is being installed")
pip.main(['install', '--user', 'requests'])
import requests
except ImportError:
print("pip is not installed, so it needs to be installed first to proceed further.\nYou can install pip with the following command:\nsudo apt install python3-pip")
slp=sched.scheduler(time.time,time.sleep)
def startStopRecording(s):
print("Stopping the recording of "+sys.argv[2])
response=requests.put(sys.argv[1]+"/rest/v2/broadcasts/"+sys.argv[2]+"/recording/false")
if response.json()["success"]:
print("recording of "+sys.argv[2]+" stopped successfully")
print(response.content)
print("starting the recording of "+sys.argv[2])
response=requests.put(sys.argv[1]+"/rest/v2/broadcasts/"+sys.argv[2]+"/recording/true")
print(response.content)
if response.json()["success"]:
print("recording of "+sys.argv[2]+" started successfully")
s.enter(int(sys.argv[3]),1,startStopRecording,(s,))
else:
print("Couldn't start the recording of "+sys.argv[2])
print("content of the response:\n"+response.content)
sys.exit()
else:
print("Couldn't stop the recording of "+sys.argv[2])
print("content of the response:")
print(response.content)
sys.exit()
slp.enter(int(sys.argv[3]),1,startStopRecording,(slp,))
slp.run()
示例用法如下:python3 file.py https://domain/{Application} streamId 间隔
第一个参数是您要使用的域,例如:https://someexample.com:5443/WebRTCAppEE
第二个参数是您要使用的流 id。前任。流 123。
第三个参数是你想要重新开始录制的时间间隔。持续时间单位是秒。所以 60 等于 1 分钟。
【讨论】: