FFDec - Decoding using FFmpeg in Delphi 

uses FFDecImport;


  decoder : HFFDecoder;
  info : AVInfo;
  packet : PAVPacket;
  buffer : array [0..10000000] of Byte;
  size : Integer;
  decoder := ffOpenFile('x:\xxx.avi', @info);
  packet := ffCreateAVPacket(True);
    while ffRead(decoder, packet,
      if packet.stream_index
        = info.audioStreamIndex then
        if ffDecode(decoder, packet,
          @(buffer[0]), Length(buffer), size) then
        // Play the decoded audio samples ...
      else if packet.stream_index
        = info.videoStreamIndex then
        if ffDecode(decoder, packet,
          @(buffer[0]), Length(buffer), size) then
        // Show the decoded
        // picture (BGR24 format) ...
FFmpeg is a very powerful library for video/audio encoding/decoding. But unfortunately it is very difficult to use in non-C/C++ developments. So I wrote this library a year ago to simplify it for other programming languages - especially for Delphi (I think it would work in Free Pascal too).

The FFDec library consists of only ONE single DLL, which may be released as two versions (see below), and a Pascal header file, which loads the DLL dynamically. You can simply include the header and compile your code.

You can find the official site of FFDec on SF.net:

The FFDec library wraps the original FFmpeg-APIs almost directly. The usage of FFDec functions is very similar to the libAV* functions. So you'd better get some FFmpeg knowledge before you work with FFDec. I'm sorry that I cannot provide a detailed documentation currently. However, I prefer you to read the DLL source code (it's short and simple) to get ideas of how it works.

The library is released under GPL or LGPL license depending on the embedded FFmpeg version. Both versions can be called in the same way, but the LGPL version may support less formats.


FFmpeg 是一个非常强大的视频/音频编码解码库。但是很可惜,人们很难将其应用到非 C/C++ 的工程中。因此我一年前将其重新封装为一个库并希望这一工作能够简化其在视频解码方面的应用——尤其是在 Delphi (或 Free Pascal) 中的应用。

FFDec 库由一个 DLL (有可能按照授权方式不同分为两个版本) 和一个负责动态装载 DLL 的 Pascal 头文件组成。用户可以直接将其加入到自己的工程中进行编译。

您可以访问在 SF.net 上 FFDec 的官方主页来取得最新的信息:

FFDec 几乎是直接对 FFmpeg 的原生 API 进行了转换封装。FFDec 的库函数在应用上也与 libAV* 函数十分接近。因此在使用 FFDec 之前,您有必要先了解一下 FFmpeg 的原理。此外抱歉的是,我近期内恐怕无法提供详细的 FFDec 的文档。不过您可以通过查看 DLL 源代码(它比你想象的要简单)以取得对 FFDec 工作原理的认知。

依照集成的 FFmpeg 库的版本授权不同,FFDec 库分为 GPL 和 LGPL 版本。两个版本都可以按照统一的接口调用,只是 LGPL 版本所支持的文件格式要少一些。

[ 查看全文 ] ( 3 评论 / 20219 次浏览 )   |  永久链接  |   ( 3 / 4029 )