# FFmpeg Support (/libs/video_support/ffmpeg)



**FFmpeg** is a complete, cross-platform solution to record, convert and stream audio and video.

The FFmpeg is an LVGL extension that interfaces with the official FFmpeg library to help
you add platform-independent recording, converting and streaming audio and video into
your LVGL UI.

The set-up steps below are for Linux, but they can be adapted for other platforms.

For a detailed introduction, see:  [https://www.ffmpeg.org](https://www.ffmpeg.org)

Installing FFmpeg [#installing-ffmpeg]

```bash title="bash" lineNumbers=1
sudo apt install libavformat-dev libavcodec-dev libswscale-dev libavutil-dev
```

Or download the FFmpeg library from [its official download page](https://www.ffmpeg.org/download.html), then install it:

```bash title="bash" lineNumbers=1
./configure --disable-all --disable-autodetect --disable-podpages --disable-asm --enable-avcodec --enable-avformat --enable-decoders --enable-encoders --enable-demuxers --enable-parsers --enable-protocol='file' --enable-swscale --enable-zlib
make
sudo make install
```

Adding FFmpeg to Your Project [#adding-ffmpeg-to-your-project]

To use the `FFmpeg` library in your project, you will need to link against these
libraries:

| Field         | Description            |
| ------------- | ---------------------- |
| `libavformat` | part of FFmpeg library |
| `libavcodec`  | part of FFmpeg library |
| `libavutil`   | part of FFmpeg library |
| `libswscale`  | part of FFmpeg library |

:libm:
:libz:
:libpthread:

If you are using GCC-based toolchain, this can be taken care of by adding the
following command-line options:

```bash title="bash" lineNumbers=1
-lavformat -lavcodec -lavutil -lswscale -lm -lz -lpthread
```

Usage [#usage]

Set the <ApiLink name="LV_USE_FFMPEG" /> in `lv_conf.h` to `1`.

Also set <ApiLink name="LV_FFMPEG_PLAYER_USE_LV_FS" /> in `lv_conf.h` to `1` if you want
to integrate the LVGL [File System (lv\_fs\_drv)](/main-modules/fs) extension into FFmpeg.
This library can load videos and images. The LVGL file system
will always be used when an image is loaded with <ApiLink name="lv_image_set_src" />
regardless of the value of <ApiLink name="LV_FFMPEG_PLAYER_USE_LV_FS" />.

The ffmpeg player uses software decoding by default. If you require a hardware decoder, you must manually specify it using `lv_ffmpeg_player_set_decoder`, such as `h264_v4l2m2m`.

See the examples below for how to correctly use this library.

Events [#events]

* <ApiLink name="LV_EVENT_READY" /> Sent when playback is complete and auto-restart is not enabled.

Learn more about [events](/common-widget-features/events).

Examples [#examples]

Decode image [#decode-image]

<LvglExample name="lv_example_ffmpeg_1" path="libs/ffmpeg/lv_example_ffmpeg_1" />

Decode video [#decode-video]

<LvglExample name="lv_example_ffmpeg_2" path="libs/ffmpeg/lv_example_ffmpeg_2" />

API [#api]
