[English]

FFmpeg support(FFmpeg 支持)

显示原文

A complete, cross-platform solution to record, convert and stream audio and video.

Detailed introduction: https://www.ffmpeg.org


用于录制、转换和流式传输音频和视频的完整跨平台解决方案。

详细介绍:https://www.ffmpeg.org

Install FFmpeg(安装 FFmpeg)

显示原文

Download first FFmpeg from here, then install it:

./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

首先从这里下载 FFmpeg,然后安装它:

./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

Add FFmpeg to your project(将 FFmpeg 添加到您的项目)

显示原文
  • Add library: FFmpeg (for GCC: -lavformat -lavcodec -lavutil -lswscale -lm -lz -lpthread)


  • 添加库:(对于 GCC:FFmpeg-lavformat -lavcodec -lavutil -lswscale -lm -lz -lpthread)

Usage(用法)

显示原文

Enable LV_USE_FFMPEG in .

See the examples below.

Note:

FFmpeg extension doesn't use LVGL's file system. You can

simply pass the path to the image or video as usual on your operating system or platform.


LV_USE_FFMPEG 中启用 lv_conf.h

请参阅以下示例。

注意:

FFmpeg 扩展不使用 LVGL 的文件系统。您可以只需像往常一样在操作中传递图像或视频的路径即可系统或平台。

Example

[English]

Decode image

#include "../../lv_examples.h"
#if LV_BUILD_EXAMPLES
#if LV_USE_FFMPEG

/**
 * Open an image from a file
 */
void lv_example_ffmpeg_1(void)
{
    lv_obj_t * img = lv_image_create(lv_screen_active());
    lv_image_set_src(img, "./lvgl/examples/libs/ffmpeg/ffmpeg.png");
    lv_obj_center(img);
}

#else

void lv_example_ffmpeg_1(void)
{
    /*TODO
     *fallback for online examples*/

    lv_obj_t * label = lv_label_create(lv_screen_active());
    lv_label_set_text(label, "FFmpeg is not installed");
    lv_obj_center(label);
}

#endif
#endif

Decode video

#include "../../lv_examples.h"
#if LV_BUILD_EXAMPLES
#if LV_USE_FFMPEG

/**
 * Open a video from a file
 */
void lv_example_ffmpeg_2(void)
{
    /*birds.mp4 is downloaded from http://www.videezy.com (Free Stock Footage by Videezy!)
     *https://www.videezy.com/abstract/44864-silhouettes-of-birds-over-the-sunset*/
    lv_obj_t * player = lv_ffmpeg_player_create(lv_screen_active());
    lv_ffmpeg_player_set_src(player, "./lvgl/examples/libs/ffmpeg/birds.mp4");
    lv_ffmpeg_player_set_auto_restart(player, true);
    lv_ffmpeg_player_set_cmd(player, LV_FFMPEG_PLAYER_CMD_START);
    lv_obj_center(player);
}

#else

void lv_example_ffmpeg_2(void)
{
    /*TODO
     *fallback for online examples*/

    lv_obj_t * label = lv_label_create(lv_screen_active());
    lv_label_set_text(label, "FFmpeg is not installed");
    lv_obj_center(label);
}

#endif
#endif

API

lv_ffmpeg.h

lv_types.h