go2rtc icon indicating copy to clipboard operation
go2rtc copied to clipboard

Question how to use API

Open ankhafizov opened this issue 3 months ago • 9 comments

Greetings!

I want to read mp4 video frame by frame using opencv, and frame by frame push it to go2rtc service. I expect that this framed sequence become a video inside go2rtc, thich I can open in browser.

response = requests.put("http://localhost:1984/api/streams?src=no&name=mystream")
cap = cv2.VideoCapture(video_path)

def send_frame(frame):
    _, img_encoded = cv2.imencode(".jpeg", frame)
    response = requests.post(go2rtc_url, data=img_encoded.tobytes())

    if response.status_code == 200:
        print(f"OK. {response.content.strip()}")
    else:
        print(f"ERROR: {response.status_code} - {response.content.strip()}")


try:
    while True:
        ret, frame = cap.read()

        if not ret:
            break

        send_frame(frame)
        time.sleep(0.1)

this is my script. It does not work and I don't know why. The error log inside the docker container is:

2024-11-18 15:14:10 17:14:10.866 WRN github.com/AlexxIT/go2rtc/internal/mjpeg/init.go:142 > error="mjpeg: no receivers"

ankhafizov avatar Nov 18 '24 12:11 ankhafizov