Q2.How to use FFmpeg to record video streams and save them as. flv files - Encoder Series - kiloview

Q2.How to use FFmpeg to record video streams and save them as. flv files

12/24/2025 / 2019

To record a video stream using FFmpeg and save it as a. flv file, you can follow these steps:

1. Install FFmpeg

If you haven't installed FFmpeg yet, you can install it through the following methods:

Windows: Download and install the Windows version from the official FFmpeg website.

Download FFmpeg

Mac: Use the Homebrew command to install:

brew install ffmpeg

Linux: Install using apt or other package managers:

sudo apt update

sudo apt install ffmpeg

2. Record a video stream and save it as. flv

In FFmpeg, use the command line to record video streams.

Assuming you want to record and save as a. flv file from a URL (such as RTMP stream or HTTP stream), you can use the following command:

Ffmpeg-i "video stream URL" - c: v libx264 present fast - c: a aac - f flv "output file name".flv
-i "Video Stream URL": Replace the input stream address with your video stream URL (such as RTMP stream address, HTTP live stream, etc.).
-c: v libx264: Set the video encoding to libx264, which is a commonly used efficient H.264 encoder.
-set fast: Set the encoding speed, where fast represents a faster encoding speed.You can choose from ultra fast, super fast, fast, medium, slow, slow, the slower the encoding, the higher the compression ratio.
-c: a aac: Set the audio encoding to AAC.
-f flv: Set the output format to. flv.
3. Example

Assuming you want to record an RTMP stream, the command would look like this:

ffmpeg -i rtmp://example.com/live/stream -c:v libx264 -preset fast -c:a aac -f flv output.flv

4. End recording

During the recording process, you can press Ctrl+C to end the recording.