如何从FFMPEG获取文件描述符

how to get file descriptor from ffmpeg

本文关键字:文件 描述 获取 FFMPEG      更新时间:2023-10-16


我在我的 c++ 项目中使用 ffmpeg,我需要获取打开的文件的文件描述符,如下所示:

    AVFormatContext* pFormatCtx = avformat_alloc_context();
    avformat_open_input(&pFormatCtx, "C:\a.avi", NULL, NULL);
    uint64_t fileDescriptor = getDescriptor();

是否可以获取描述符以及如何获取?

在某些情况下,以下内容可能有效:

#include "libavformat/avio.h"
[..]
AVIOContext *pb = pFormatCtx->pb;
URLContext *url = pb->opaque;
int fd = ffurl_get_file_handle(url);
很明显,

您在这里访问内部变量,因此,如果它有效,请认为自己很幸运。不要提供使用它的代码,因为它不是公共 API。