如何在不停止流式传输的情况下保存 VoD 录制内容?

How can I save VoD recordings without stopping streaming?

如何在不停止流的情况下间隔停止录制以将 Ant Media Server 中的 VoD 保存在我的流源和网络摄像机中?

您可以使用 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 interval

第一个参数是您要使用的域,例如:https://someexample.com:5443/WebRTCAppEE

第二个参数是您要使用的流 ID。前任。 stream123.

第三个参数是你想要重新开始记录的间隔时间。持续时间单位是秒。所以60等于1分钟。