【问题标题】:Using ffMPEG on Windows with only the DLL's?在仅 DLL 的 Windows 上使用 ffMPEG?
【发布时间】:2012-10-27 02:08:39
【问题描述】:

我真正想要的是store frames of a video into a char array,使用 ffMPEG。
约束是仅使用 MSVC。由于可维护性问题,不允许使用Windows building tweak

因此考虑使用shared build 来完成任务。它仅由 DLL 组成。没有lib 文件,所以我尝试使用HINSTANCE hInstLibrary = LoadLibrary("avcodec-54.dll"); 加载其中一个DLL,它可以工作。但是我在任何地方都找不到这个 DLL 的接口。有人可以帮忙吗?我如何知道我可以调用 DLL 的哪些函数以及我可以传递哪些参数以便获取视频帧?

【问题讨论】:

  • 使用开发版本的相关页面:stackoverflow.com/questions/11701635/…。相信我,用这个链接中的答案编写程序比在下面的答案中容易得多,因为下面的答案需要加载一个 DLL 函数并将其用作 functionname_proc

标签: visual-studio-2010 visual-c++ ffmpeg


【解决方案1】:

使用来自

的ffmpeg的公共接口
ffmpegdir/include/libavcodec/
ffmpegdir/include/libavformat/
etc.

例如,要打开文件进行读取,请使用 ffmpegdir/include/libavformat/avformat.h 中的 avformat_open_input

AVFormatContext * ctx= NULL;
int err = avformat_open_input(&ctx, file_name, NULL, NULL);

你可以从http://ffmpeg.zeranoe.com/builds/获取最新版本的ffmpeg

可以在开发版本 (http://ffmpeg.zeranoe.com/builds/win32/dev/) 中找到公共头文件。

更新: 这是一个工作示例(没有额外的静态链接)

#include "stdafx.h"
#include <windows.h>
#include <libavformat/avformat.h>

typedef int (__cdecl *__avformat_open_input)(AVFormatContext **, const char *, AVInputFormat *, AVDictionary **);
typedef void (__cdecl *__av_register_all)(void);

int _tmain(int argc, _TCHAR* argv[])
{
    const char * ffp = "f:\\Projects\\Temp\\testFFMPEG\\Debug\\avformat-54.dll";
    HINSTANCE hinstLib = LoadLibraryA(ffp);
    __avformat_open_input __avformat_open_input_proc  = (__avformat_open_input)GetProcAddress(hinstLib, "avformat_open_input");

    __av_register_all __av_register_all_proc = (__av_register_all)GetProcAddress(hinstLib, "av_register_all");
    __av_register_all_proc();

    ::AVFormatContext * ctx = NULL;
    int err = __avformat_open_input_proc(&ctx, "g:\\Media\\The Sneezing Baby Panda.flv", NULL, NULL);
    return 0;
  }

【讨论】:

  • 谢谢。截至目前,我收到avformat_open_inputunresolved external symbol 错误。您的代码是否也包含lib 文件?因为我试图完全使用共享构建的 ffmpeg DLL 来完成任务(也不介意知道如何使用 dev 构建。当我尝试使用 dev 构建时遇到了一些错误)跨度>
  • 通常使用静态库 (ffmpeg\lib\libavformat.dll.a) 来访问动态运行时库。如果由于某种原因不可能,请尝试使用 'GetProcAddress(hInstLibrary, "avformat_open_input")' 函数,如下所示msdn.microsoft.com/en-us/library/windows/desktop/…
  • 我得到的未解决的外部符号错误出现在我使用 GetProcAddress 的行中。我正在使用从code.google.com/p/msinttypes/downloads/list 下载的 inttypes.h 文件,因为 common.h 需要它。即使我包含库,我也会得到这个Error 1 error LNK2019: unresolved external symbol "void __cdecl av_register_all(void)" (?av_register_all@@YAXXZ) referenced in function _main F:\Projects\VisualStudio\ffmpegTestProgram\ffmpegTestProgram\main.obj
  • 试用了您的程序(删除stdafx 后,将_TCHAR 转换为char_tmain 转换为main)。它构建成功。非常感谢你! :) 我只是希望我能够使用 API 将 rgb 值放入 char 数组中,正如我最初想要的那样。
猜你喜欢
  • 1970-01-01
  • 2012-05-10
  • 2017-08-04
  • 2014-01-12
  • 2011-02-09
  • 1970-01-01
  • 2013-08-13
  • 2017-12-24
  • 2012-01-09
相关资源
最近更新 更多