Home » Guides » Encoding Recommendations » Live Transcoding Guide and Recommendations

permalink Live Transcoding Guide and Recommendations

Live Streaming takes a single high quality RTMP stream and converts it to multiple bitrate RTMP and HLS streams for viewing by users on a variety of devices and bandwidths. Files can also be created when the stream is completed, giving you a non-segmented video for playback on other devices.

Supported Encoders

Zencoder accepts RTMP input and has been tested with several streaming clients for creating your source video stream.

Other encoders may work but have not been tested yet. We will expand this list as we are able to test more.

Supported CDNs and Streaming Servers

Zencoder can stream generated live outputs to multiple streaming media servers via RTMP and HLS.

  • Akamai
  • Edgecast
  • Limelight
  • Flash Media Server
  • Wowza
  • YouTube
  • Amazon CloudFront (HLS)
  • Fastly

Other CDNs and servers may work but have not been tested yet. We will expand this list as we are able to test more.

Supported Formats

Input

For best results, use H.264 and AAC codecs in your RTMP stream. We also support VP6 and MP3, but quality may not be as high when using these codecs. Sending Zencoder the highest quality stream that your upstream connection supports will improve the quality of the streams generated.

Output

Live output videos can be published to an RTMP server or uploaded as HLS segments. Regular, non-live files can also be generated when the input stream has ended.

Geographic Considerations

The farther data needs to go, the greater the latency and delay in playback. To reduce latency make sure to use servers in the region closest to the streaming source.

When streaming to Akamai via RTMP the endpoint should be close to the Zencoder transcoding server. Contact support for assistance setting this up.

Limitations and Known Issues

  • Max input resolution of 1080p
  • Max input bitrate of 10mbps
  • Input must be 30 fps or less
  • Audio-only outputs are supported, but cannot be he-aac or 48khz aac
  • Stream duration is limited to 18 hours
  • Streaming must begin within 30 minutes of job creation
  • HTTP POST uploads (for HLS) have only been tested with Akamai
  • DRM is currently not supported
  • Microsoft Smooth Streaming is currently not supported for live streaming

The Parts of an API Request

Job Creation and Response

To create a Live Streaming job set live_stream to true and specify at least one output with URL to a compatible host.

{
  "live_stream": true,
  "outputs": [
    {
        "label": "rtmp_300",
        "size": "480x270",
        "video_bitrate": 300,
        "url": "rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/eventname_01_300@63239"
    }
  ]
}
  

  true
  
    
      
      300
      480x270
      rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/eventname_01_300@63239
    
  

When a Live Streaming job is created, the response to the API request will contain a URL and stream name. Publish your RTMP stream to this URL and Zencoder will begin transcoding to the requested output streams, as explained in the rest of this guide.

{
  "stream_url":"rtmp://live0.us-va.zencoder.io:1935/live",
  "stream_name":"8f4dc774cfd3ed79f27f65c0c43ee5cf",
  "id":123456,
  "outputs":[...]
}

  
    123456
    rtmp://live0.us-va.zencoder.io:1935/live
    8f4dc774cfd3ed79f27f65c0c43ee5cf
    
      
        ...
      
    
  

Output

RTMP Outputs

For RTMP outputs, simply specifying an RTMP output URL is enough to publish the stream to your server. This will create an output with the default quality of 3, which determines the bitrate to use to create a good quality video based on the input. Since the bitrate generated with quality can vary, it is recommended to specify a video bitrate to target bitrates for the devices and users who will be watching the stream.

{
  "live_stream": true,
  "outputs": [
    {
        "video_bitrate": 1200,
        "url": "rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/live_01_300@63239"
    }
  ]
}

  true
  
    
      1200
      rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/live_01_300@63239
    
  

The format of the ouput file in the URL must match the format in the example above: live_01_300, where live is the event name, 01 is the angle, and 300 is the bitrate. Each is separated by an underscore. Bitrate is not required.

By default the stream will use the H.264 and AAC codecs for video and audio. MP3 can also be used for audio.

For RTMP servers requiring authentication, the username and password can be provided via the URL, like rtmp://username:password@outputserver:1935/app/streamname/live_01_300@63239. This can be used to publish to Wowza or FMS servers, as well as many CDNs, such as Akamai.

We will simultaneously publish to a secondary_url if specified. When a primary and backup url are provided by the CDN (such as Akamai), secondary_url should always be set to the backup. This will provide redundancy in case there are issues with the primary stream.

HLS Outputs

HLS outputs are created similarly to regular HTTP Live Streaming outputs, with the addition of the live_stream flag. As with RTMP outputs, specifying a video bitrate to target bitrates for the devices and users who will be watching the stream is recommended.

{
  "audio_bitrate": 56,
  "audio_sample_rate": 22050,
  "url": "http://post.example.akamaihd.net/PATH/TO/eventname_01_640.m3u8",
  "decoder_bitrate_cap": 900,
  "decoder_buffer_size": 2400,
  "max_frame_rate": 30,
  "public": 1,
  "type": "segmented",
  "video_bitrate": 600,
  "width": 400,
  "format": "ts",
  "live_stream": true
}

  56
  22050
  http://post.example.akamaihd.net/PATH/TO/eventname_01_640.m3u8
  900
  2400
  30
  1
  segmented
  600
  400
  ts
  true

Live HLS outputs can be uploaded to any compatible server supported by Zencoder, including S3 and FTP. They can also be transferred to Akamai for HLS Live Delivery via HTTP POST, using an output URL like http://example.akamaihd.net/12355/1234567890/eventname_ios_300.m3u8.

File Outputs

Output videos in any other format or using any other codecs will be transcoded and uploaded after the input stream has completed.

{
  "label":"archive",
  "url":"s3://example-bucket/eventname_archive.mp4"
}

  
  s3://example-bucket/eventname_archive.mp4

NOTE: Setting live_stream with unsupported formats (non-HLS) will cause those outputs to fail.

Full Request

A full request can create RTMP and HLS outputs, plus an HLS playlist to tell players the available streams for different bandwidths.

{
    "live_stream": true,
    "outputs": [
        {
            "label": "rtmp_300",
            "size": "480x270",
            "video_bitrate": 300,
            "url": "rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/eventname_01_300@63239"
        },
        {
            "label": "rtmp_600",
            "size": "640x360",
            "video_bitrate": 600,
            "url": "rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/eventname_01_600@63239"
        },
        {
            "label": "rtmp_1200",
            "size": "1280x720",
            "video_bitrate": 1200,
            "url": "rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/eventname_01_1200@63239"
        },
        {
            "label": "hls_300",
            "size": "480x270",
            "video_bitrate": 300,
            "url": "http://post.bcoveliveios-i.akamaihd.net/IOSSTREAM/PUBLISHERID/eventname_01_300.m3u8",
            "type": "segmented",
            "live_stream": true
        },
        {
            "label": "hls_600",
            "size": "640x360",
            "video_bitrate": 600,
            "url": "http://post.example.akamaihd.net/PATH/TO/eventname_ios_600.m3u8",
            "type": "segmented",
            "live_stream": true
        },
        {
            "label": "hls_1200",
            "size": "1280x720",
            "video_bitrate": 120,
            "url": "http://post.example.akamaihd.net/PATH/TO/eventname_01_1200.m3u8",
            "type": "segmented",
            "live_stream": true
        },
        {
            "url": "http://post.example.akamaihd.net/PATH/TO/master.m3u8",
            "type": "playlist",
            "streams": [
                {
                    "bandwidth": 300,
                    "path": "eventname_01_300.m3u8"
                },
                {
                    "bandwidth": 600,
                    "path": "eventname_01_600.m3u8"
                },
                {
                    "bandwidth": 1200,
                    "path": "eventname_01_1200.m3u8"
                }
            ]
        },
        {
          "label":"archive",
          "url":"s3://example-bucket/eventname_archive.mp4"
        }
    ]
}

  true
  
    
      
      300
      480x270
      rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/eventname_01_300@63239
    
    
      
      600
      640x360
      rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/eventname_01_600@63239
    
    
      
      1200
      1280x720
      rtmp://user:pass@server.akamaientrypoint.net/EntryPoint/eventname_01_1200@63239
    
    
      
      true
      300
      480x270
      segmented
      http://post.example.akamaihd.net/PATH/TO/eventname_01_300.m3u8
    
    
      
      true
      600
      640x360
      segmented
      http://post.example.akamaihd.net/PATH/TO/eventname_01_600.m3u8
    
    
      
      true
      120
      1280x720
      segmented
      http://post.example.akamaihd.net/PATH/TO/eventname_01_1200.m3u8
    
    
      
        
          300
          eventname_01_300.m3u8
        
        
          600
          eventname_01_600.m3u8
        
        
          1200
          eventname_01_1200.m3u8
        
      
      playlist
      http://post.example.akamaihd.net/PATH/TO/master.m3u8
    
    
      
      s3://example-bucket/eventname_archive.mp4
    
  

Notes

S3 Permissions

When creating HLS outputs on Amazon S3, you must set permissions in your API request to deal with the way AWS makes the file accessible. Not doing this can lead to delays in permissions being applied, and cause issues during playback. Add the settings below to any HLS outputs to ensure that permissions are set correctly.

NOTE: Due to S3's eventual consistency approach to redundancy, files uploaded there are not always immediately available. This could cause issues with live HLS playback on S3.

"headers": {
  "x-amz-acl": "public-read"
},
"access_control": [
  {
    "permission": "FULL_CONTROL",
    "grantee": "aws@zencoder.com"
  },
  {
    "permission": "READ",
    "grantee": "http://acs.amazonaws.com/groups/global/AllUsers"
  }
]

    public-read
  
  
    
      FULL_CONTROL
      aws@zencoder.com
    
    
      READ
      http://acs.amazonaws.com/groups/global/AllUsers
    
  

Akamai & HLS Playlists

For the master playlist Akamai expects the filename will be index.m3u8, master.m3u8, or playlist.m3u8. If it is not you may get 404 responses when trying to access the playlist. This can be overridden in your Akamai configuration. See Akamai's documentation for more information.

Waiting Jobs Limit

We have a defult limit of 5 waiting streams per account. If you reach this limit, you will need to cancel or start streaming to one of the waiting streams in order to create a new live job. If you need this limit increased, please contact support.