如何使用ffmpeg获取歌词

How to use FFmpeg to get lyrics?

本文关键字:获取 ffmpeg 何使用      更新时间:2023-10-16

ffmpeg版本:3.3.2

我尝试使用流来获取歌词,但不能。

代码:

AVFormatContext* fmt_ctx = NULL;
int ret;
av_register_all();
if ((ret = avformat_open_input(&fmt_ctx, "media path", NULL, NULL))){
    printf("Fail to open file");
    return;
}
if (fmt_ctx->iformat->read_header(fmt_ctx) < 0) {
    printf("No header format");
    return;
}
for (uint i = 0; i < fmt_ctx->nb_streams; i++){
    auto stream=fmt_ctx->streams[i];
    if(stream->disposition==AV_DISPOSITION_LYRICS){
        printf("lyrics!");//"will not print"
    }
}

disposition是一个野外场,因此请尝试不严格的平等。条件应为:

stream->disposition & AV_DISPOSITION_LYRICS