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

Step 5: Set Up Streaming Software

You can stream to Amazon IVS with the native mobile broadcast SDK or other streaming software (like the two examples below, Open Broadcast Software (OBS) and FFmpeg). These 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.

Key encoder settings are keyframe interval (2 seconds) and resolution/bitrate/frame rate (which are interrelated). For more detail on encoder settings, see:

Notes:

  • 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.

  • If your encoder stops sending data (e.g., due to a temporary network issue), Amazon IVS waits for 30 seconds. If no broadcaster data is received during this time, Amazon IVS disconnects.

Streaming with the Amazon IVS Broadcast SDK

To broadcast from your iOS or Android applications, you can use the Amazon IVS broadcast SDK. The broadcast SDK leverages the Amazon IVS architecture and will see continual improvement and new features, alongside Amazon IVS. As a native mobile broadcast SDK, it is designed to minimize the performance impact on your application and on the devices with which your users access your application.

To broadcast from … You can use … Notes
Your Android or iOS applications Amazon IVS Android or iOS broadcast SDK As a native mobile broadcast SDK, it is designed to minimize the performance impact on your application and on the devices with which your users access your application.
A web environment Amazon IVS Web broadcast SDK As a web broadcast SDK, the Amazon IVS Web Broadcast SDK allows you to broadcast from web environments using WebRTC. It boasts cross-browser and cross-platform support.

For details, see Amazon IVS Broadcast SDK.

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. At Stream Information, choose Custom... from the Service dropdown and enter the Server (Ingest 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:

      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. For Video Output Resolution and Bitrate, refer to Channel Types in Amazon IVS Streaming Configuration. If either value chosen by the OBS wizard exceeds the values allowed by Amazon IVS, you should manually adjust the values to avoid a failed connection to Amazon IVS. After the wizard completes:

    1. To adjust video resolution, use Settings > Video > Output (Scaled) Resolution.

    2. To adjust video bitrate, use Settings > Output > Streaming > Video Bitrate.

  5. We recommend a 2-second Keyframe Interval to improve the stream stability and avoid buffering in the viewer playback. After the wizard completes, go to Settings > Output > Output Mode, select Advanced, and on the Streaming tab, ensure that Keyframe Interval is 2.

  6. 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 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 (from the AWS CLI):

    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.