Step 4: Set Up Streaming Software - Amazon Interactive Video Service

Step 4: Set Up Streaming Software

Below are two examples of setting up Amazon IVS streaming, with Open Broadcast Software (OBS) and FFmpeg. Both support RTMPS, like Amazon IVS. RTMPS enables high security via use of an encrypted TLS stream. You can use any streaming software that supports RTMPS.

For more detail on encoder settings, see this blog post: Setting Up for Streaming with Amazon Interactive Video Service.

Note: The maximum duration of Amazon IVS streams is 48 hours. After that, the stream is terminated and the streaming session is disconnected. A successful reconnect (automatically or manually) starts a new stream.

Streaming with OBS Studio

(OBS Studio) is a free, open-source software suite for recording and live streaming. OBS provides real-time source and device capture, scene composition, encoding, recording, and streaming.

Follow these steps to get up and running quickly with OBS Studio:

  1. Download and install the software: https://obsproject.com/download.

  2. Run the OBS Studio Auto-Configuration Wizard, which appears when you load OBS Studio for the first time. Follow the steps and accept the defaults.

  3. When prompted, enter the Server and Stream Key.

    If you created the channel with the Amazon IVS console:

    • The Server you enter in OBS is the Ingest server from the console, with the addition of port 443 (required for Amazon IVS ingest):

      rtmps://a1b2c3d4e5f6.global-contribute.live-video.net:443/app/

    • The Stream key you enter in OBS is the Stream key from the console:

      sk_us-west-2_abcd1234efgh5678ijkl

    If you created the channel with the AWS CLI:

    • The Server you enter in OBS is a combination of four things:

      • An ingestion protocol: rtmps://

      • The ingestEndpoint from the CLI response:

        a1b2c3d4e5f6.global-contribute.live-video.net

      • A port: 443

      • A path: /app/

      The complete entry is:

      rtmps://a1b2c3d4e5f6.global-contribute.live-video.net:443/app/

    • The Stream key you enter in OBS is the streamKey value from the CLI response:

      sk_us-west-2_abcd1234efgh5678ijkl

  4. In the OBS Studio main window, choose Start Streaming.

For more on streaming with OBS Studio, see OBS Studio Quickstart.

You can modify your OBS settings manually later:

  1. Choose Settings > Stream.

  2. Choose Custom from the dropdown.

  3. Paste in the Server and/or Stream Key.

You can run the wizard again at any time: choose Tools > Auto-Configuration Wizard.

Optionally, in Settings > General, enable local recording to save your live stream for later use. As mentioned earlier, network issues between the broadcast and AWS or within AWS could result in some data loss while recording your stream. In these cases, Amazon IVS prioritizes the live stream over the recording. Recording locally via your streaming tool provides redundancy.

It’s advisable to check for OBS Studio updates regularly and update to the most current version. (For instance, if you get if you get a “Failed to connect to server” error, you may be using an old version of OBS Studio that does not support RTMPS.)

Streaming a Recorded Video with FFmpeg

Follow these steps:

  1. Download and install FFmpeg: https://www.ffmpeg.org/download.html.

  2. Set $VIDEO_FILEPATH to the location of an MP4 video to stream:

    VIDEO_FILEPATH=/home/test/my_video.mp4
  3. Set STREAM_KEY to your StreamKey value:

    STREAM_KEY=sk_us-west-2_abcd1234efgh5678ijkl
  4. Set INGEST_ENDPOINT to your ingestEndpoint:

    INGEST_ENDPOINT=a1b2c3d4e5f6.global-contribute.live-video.net
  5. Start streaming with the following terminal command (this is all one line):

    ffmpeg -re -stream_loop -1 -i $VIDEO_FILEPATH -r 30 -c:v libx264 -pix_fmt yuv420p -profile:v main -preset veryfast -x264opts "nal-hrd=cbr:no-scenecut" -minrate 3000 -maxrate 3000 -g 60 -c:a aac -b:a 160k -ac 2 -ar 44100 -f flv rtmps://$INGEST_ENDPOINT:443/app/$STREAM_KEY

    Note, the above command is an example. For production streaming, tune the parameters to your needs.