The Automatic Encoder Configuration API allows you to automatically configure encoding settings before going Live on Facebook. The API is designed to be stateless and lightweight so user authentication or tokens are not required.
To automatically configure encoder settings, send a GET
request to the video_encoder_settings
endpoint.
curl -i -X GET \ "https://graph.facebook.com/{graph-api-version}/video_encoder_settings ?video_type=live &input_video_width=1920 &input_video_height=1080 &input_video_framerate=30 &input_video_bitrate=6000 &input_audio_channels=2 &input_audio_samplerate=48000 &cap_streaming_protocols=rtmps &cap_video_codecs=h264 &cap_audio_codecs=aac"
On success, your app will receive the following response:
{ "streaming_protocol":"rtmps", "rtmps_settings": { "video_codec":"h264", "video_codec_settings": { "video_bitrate":6000, "video_width":1920, "video_height":1080, "video_framerate":30, "video_h264_profile":"high", "video_h264_level":"4.1", "video_gop_size":60, "video_gop_type": "fixed", "video_gop_closed": true, "video_gop_num_b_frames":3, "video_gop_num_ref_frames":3, "video_scan_mode": "progressive", "rate_control_mode": "cbr", "buffer_size": 12000 }, "audio_codec":"aac", "audio_codec_settings": { "audio_bitrate":256, "audio_channels":2, "audio_samplerate":48000 } } }
The following fields are required for all GET video_endcoder_settings
endpoint requests.
video_encoder_settings Fields | Description |
---|---|
| A comma separated list of audio codecs you are capable of sending to Facebook. |
| A comma separated list of streaming protocols, in order of preference. |
| A comma separated list of video codecs you are capable of sending to Facebook. |
| The number of audio channels in the audio input, for example, |
| The audio sample rate, for example, |
| The video bitrate, in kbps, for example, |
| The video frame rate for example, |
| The height of the video, for example, |
| The width of your video, for example, |
| The type of video, |
The response returned contains recommendations for your encoder such as the streaming protocol, and audio and video codecs and settings for each.
Response Fields | Description |
---|---|
| The recommended streaming protocol. |
|
|
A audio_codec_settings
object contains the audio encoding settings for the recommended audio codec. Different codecs will have different values, but they share some common settings.
Common Audio Codec Settings | Recommendation |
---|---|
| Audio bitrate in kbps. |
| Number of audio channels. |
| Recommended audio sample rate, for example, |
A video_codec_settings
object contains the video encoding settings for the recommended video codec. Different codecs will have different values, but they all share some common settings.
Common Video Codec Setting | Description |
---|---|
| The recommended size of buffer in kb, for example, |
| The recommended pixel aspect ratio as a decimal value, for example, |
| The recommended rate control mode. |
| The recommended video max bit rate, in kbps. |
| The recommended video frame rate, in frames per second. |
| The recommendation for a closed GOPs, |
| The recommended number of B frames in a GOP, for example, |
| The recommended number of reference frames in a GOP, for example, |
| Recommended GOP size, in frames. |
| The recommended GOP type. |
| The recommended |
| The recommended h264 profile. |
| The recommended video height, in pixels. |
| The recommended scan mode. |
| The recommended video width, in pixels. |