datarhei / restreamer

The Restreamer is a complete streaming server solution for self-hosting. It has a visually appealing user interface and no ongoing license costs. Upload your live stream to YouTube, Twitch, Facebook, Vimeo, or other streaming solutions like Wowza. Receive video data from OBS and publish it with the RTMP and SRT server.
https://docs.datarhei.com/restreamer/
Apache License 2.0
3.78k stars 438 forks source link

I want to get iframe code or player URL. #371

Open fatherslab-taylor opened 2 years ago

fatherslab-taylor commented 2 years ago

A restreamer is an excellent solution for me, who needs to show RTSP on a website. However, I have an unresolved error and I am asking for advice.

I am trying to display an rtsp file on a website using the API.

test rtsp url: rtsp://rtsp.stream/pattern

  1. Get accessToken via /api/login

  2. I created a process using /api/v3/process

    {
    type: "ffmpeg",
    id: `restreamer-ui:ingest:${randomId}`,
    reference: `${randomId}`,
    input: [{
        id: "input_0",
        address: "rtsp://rtsp.stream/pattern",
        options: ["-fflags", "+genpts", "-thread_queue_size", "512", "-stimeout", "5000000", "-rtsp_transport", "tcp"]
    }],
    output: [{
        id: "output_0",
        address: `{memfs}/${randomId}.m3u8`,
        options: ["-dn", "-sn", "-map", "0:0", "-codec:v", "copy", "-vsync", "0", "-copyts", "-start_at_zero", "-map", "0:1", "-codec:a", "copy", "-metadata", `title=http://49.172.228.210:5001/${randomId}/oembed.json`, "-metadata", "service_provider=datarhei-Restreamer", "-f", "hls", "-start_number", "0", "-hls_time", "2", "-hls_list_size", "6", "-hls_flags", "append_list+delete_segments", "-hls_segment_filename", `{memfs}/${randomId}_%04d.ts`, "-y", "-method", "PUT"],
        cleanup: [{
            pattern: `memfs:/${randomId}_*.ts`,
            max_files: 8,
            max_file_age_seconds: 0,
            purge_on_delete: true
        }, {
            pattern: `memfs:/${randomId}.m3u8`,
            max_file_age_seconds: 0,
            purge_on_delete: true
        }]
    }],
    options: ["-err_detect", "ignore_err"],
    autostart: true,
    reconnect: true,
    reconnect_delay_seconds: 15,
    stale_timeout_seconds: 30
    }
  3. I want to get the iframe code or player URL of the created process.

I searched /api/v3/process to solve problem #3, but I can't figure out where the iframe code or player URL is recorded.

Please advise on what to do.

ioppermann commented 2 years ago

The iframe and player URL are created by the UI. If you want that your own process also shows up in the UI then you have to use a UUIDv4 for your ${randomId}. This is the format the UI uses and expects.

Alternatively, you might use any other player for HLS streams and use the .m3u8 as source. Also the ID of the process can be any value if you don't need to rely on the UI.

fatherslab-taylor commented 2 years ago

Can I get what I want in the following way?

  1. Create a process using /api/v3/process.
  2. Check the .m3u8 address using /api/v3/process/{id}
  3. Expose on the website using HLS player.

Am I thinking in the right direction? Are there any HLS players provided by restreamer?