简体   繁体   English

在Windows上仅使用DLL使用ffMPEG?

[英]Using ffMPEG on Windows with only the DLL's?

What I actually want is to store frames of a video into a char array , using ffMPEG. 我真正想要的是使用ffMPEG 将视频的帧存储到char数组中
Constraint is to use only MSVC. 约束是仅使用MSVC。 Not allowed to use the Windows building tweak due to maintainability issues. 由于可维护性问题,不允许使用Windows建筑调整

So considered using the shared build to accomplish the task. 因此考虑使用共享构建来完成任务。 It consists of only DLL's. 它仅包含DLL。 No lib files, so I tried loading one of the DLL's using HINSTANCE hInstLibrary = LoadLibrary("avcodec-54.dll"); 没有lib文件,因此我尝试使用HINSTANCE hInstLibrary = LoadLibrary("avcodec-54.dll");加载DLL之一HINSTANCE hInstLibrary = LoadLibrary("avcodec-54.dll"); and it works. 而且有效。 But I couldn't find the interfaces of this DLL published anywhere. 但是我找不到在任何地方发布的该DLL的接口。 Could anyone help with this? 有人可以帮忙吗? How do I know which functions of the DLL I can call and what parameters I can pass it so that I can get the video frames? 我如何知道我可以调用DLL的哪些功能以及可以传递哪些参数以便获取视频帧?

Use the public interface of ffmpeg from 使用ffmpeg的公共接口

ffmpegdir/include/libavcodec/
ffmpegdir/include/libavformat/
etc.

for example, to open a file for reading, use avformat_open_input from ffmpegdir/include/libavformat/avformat.h 例如,要打开文件进行读取,请使用ffmpegdir / include / libavformat / avformat.h中的avformat_open_input

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

You can get the latest builds of ffmpeg from http://ffmpeg.zeranoe.com/builds/ 您可以从http://ffmpeg.zeranoe.com/builds/获取最新版本的ffmpeg。

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

UPD: Here is a working example (no additional static linking) UPD:这是一个有效的示例(没有其他静态链接)

#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;
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM