相关疑难解决方法(0)

使用FFmpeg检索专辑封面

我正在开发一个依赖于FFmpeg来检索音频元数据的Android应用程序.我知道可以使用FFMpeg以编程方式检索专辑封面.但是,一旦您解码了艺术(MP3中的视频帧),如何生成图像文件(PNG)以便在应用程序中使用?我搜遍了所有但似乎无法找到一个有效的例子.

编辑,这是解决方案:

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>

void retrieve_album_art(const char *path, const char *album_art_file) {
    int i, ret = 0;

    if (!path) {
        printf("Path is NULL\n");
        return;
    }

    AVFormatContext *pFormatCtx = avformat_alloc_context();

    printf("Opening %s\n", path);

    // open the specified path
    if (avformat_open_input(&pFormatCtx, path, NULL, NULL) != 0) {
        printf("avformat_open_input() failed");
        goto fail;
    }

    // read the format headers
    if (pFormatCtx->iformat->read_header(pFormatCtx) < 0) {
        printf("could not read the format header\n");
        goto fail;
    }

    // find the first attached picture, if available
    for …
Run Code Online (Sandbox Code Playgroud)

audio java-native-interface android metadata ffmpeg

10
推荐指数
1
解决办法
9350
查看次数

标签 统计

android ×1

audio ×1

ffmpeg ×1

java-native-interface ×1

metadata ×1