> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# FFmpeg

> Push a live stream to Gcore Video Streaming with FFmpeg over RTMP using recommended encoding settings and optional resolution downscaling.

FFmpeg can push a live stream to Gcore Video Streaming over RTMP. Configure it with the server URL and stream key from the Gcore Customer Portal, then run FFmpeg with the recommended encoding settings for live ingest.

## Setup

1. Install FFmpeg. Download instructions are available on [ffmpeg.org](https://ffmpeg.org/download.html).

2. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **Streaming** → **Live Streaming**, then open the live stream settings for the target stream. In the **URLs for encoder** section, select **RTMP** and copy the **Server** URL and **Stream Key** values.

![Live stream settings page showing the URLs for encoder section with Server and Stream Key fields](https://mintcdn.com/gcore/LVdb0BfWcbtbIM-o/images/docs/streaming/live-streaming/broadcasting-software/ffmpeg/live-stream-encoder-urls.png?fit=max\&auto=format\&n=LVdb0BfWcbtbIM-o\&q=85\&s=19f12d5d1ebf1476741c57390a971f30)

Append the Stream Key to the Server URL to form the full RTMP URL:

```
rtmp://vp-push-ed2.gvideo.co/in/400448?cdf2a7ccf990e464c2b…
```

3. Open a terminal and run FFmpeg with the input source and the RTMP URL:

```bash theme={null}
ffmpeg {INPUT_OPTIONS} \
  -c:v libx264 -preset veryfast -b:v 2000k \
  -profile:v baseline -vf format=yuv420p \
  -r 30 -g 60 \
  -c:a aac -b:a 128k -ar 48000 -ac 2 \
  -f flv {RTMP_URL}
```

Replace `{INPUT_OPTIONS}` with the FFmpeg input flags for the camera, screen capture, or media file. Replace `{RTMP_URL}` with the URL formed in step 2.

## Recommended encoding settings

| Setting | Value | FFmpeg flag |
| - | - | - |
| Video encoder | H.264 | `-c:v libx264` |
| Video bitrate | 2000 Kbps (720p) or 4000 Kbps (1080p) | `-b:v 2000k` or `-b:v 4000k` |
| CPU preset | veryfast | `-preset veryfast` |
| Profile | Baseline | `-profile:v baseline -vf format=yuv420p` |
| Frame rate | 30 fps | `-r 30` |
| Keyframe interval | 60 frames (2 seconds at 30 fps) | `-g 60` |
| Audio encoder | AAC | `-c:a aac` |
| Audio bitrate | 128 Kbps | `-b:a 128k` |
| Sample rate | 48 kHz | `-ar 48000` |
| Channels | Stereo | `-ac 2` |

## Downscale resolution (optional)

To reduce the source resolution, replace `-vf format=yuv420p` in the main command with a combined filter chain that applies both scaling and pixel format conversion:

```bash theme={null}
-vf "scale=1280:720:flags=bicubic,format=yuv420p"
```

Keep the rest of the command unchanged.
