ffmpeg - 将 ffmpeg 编译为独立的二进制文件

标签 ffmpeg compilation

我正在尝试将 ffmpeg 编译为独立的二进制文件(因为我想在 AWS lambda 中使用它)

我可以在我正在编译的服务器上正常工作,但如果我复制二进制文件并从另一台服务器运行它,我会得到:

./ffmpeg:加载共享库时出错:libvdpau.so.1:无法打开共享对象文件:没有这样的文件或目录

所以听起来有些东西没有进入二进制文件。根据我的阅读,我必须使用标记 --disable-shared--enable-static 编译 ffmpeg,我已经完成了:

PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="$HOME/ffmpeg_build" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --bindir="$HOME/bin" \
  --disable-shared \
  --enable-static \
  --enable-gpl \
  --enable-libass \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libvpx \
  --enable-libx264
PATH="$HOME/bin:$PATH" make
make install
make distclean
hash -r

有什么我想念的吗?

最佳答案

尽管我没有成功地将所有内容编译成一个二进制文件,但我已经能够通过以下方式将依赖项上传到 AWS lambda:

复制文件夹中的所有依赖

我写了一个 python 脚本来做到这一点。该脚本依赖于 lld 来列出依赖项。

#!/usr/bin/env python
import subprocess
import os
from shutil import copyfile

def copyLibraries(bin, destination):
  if not os.path.exists(destination):
    os.makedirs(destination)

  output = subprocess.Popen(["ldd", bin], stdout=subprocess.PIPE).communicate()[0]
  for l in output.split('\n'):
    if len(l.split("=> ")) > 1:
      lib_location = l.split("=> ")[1].split(" ")[0].strip()
      if lib_location != "":
        real_location = os.path.realpath(lib_location)

        lib_name = real_location.split('/')[-1]

        copyfile(real_location, destination + lib_name)

        if os.path.islink(lib_location):
          link_name = lib_location.split('/')[-1]
          if link_name != lib_name:
            os.symlink(real_location, destination + link_name)

copyLibraries("/home/ubuntu/bin/ffmpeg", "/home/ubuntu/libs/")

AWS lambda

  • 在 lambda 压缩代码中包含 ffmpeg 二进制文件和 libs 文件夹。
  • 在 lambda 代码中,包含相应的路径。在 node.js 中,可以这样做:

.

process.env['PATH'] = process.env['PATH'] +
  ':' +    process.env['LAMBDA_TASK_ROOT'] +
  ':' + process.env['LAMBDA_TASK_ROOT'] + '/bin' +
  ':' + process.env['LAMBDA_TASK_ROOT'] + '/lib';

关于ffmpeg - 将 ffmpeg 编译为独立的二进制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39982511/

相关文章:

c++ - 一个简单的 C++ 程序的汇编输出

ubuntu - 如何使用 ffmpeg 通过 netcat 流式传输 x11?

stream - FFserver:使用 HTTP 身份验证进行保护? ( Apache ?)

linux - 使用交叉淡入淡出和纯剪切将视频与 ffmpeg 组合

PHPMotion - 如果我只是在.flv 中上传,是否需要 ffmpeg 等?

c - 某些C表达式在其语法中允许,而在实践中编译时不允许,这是否正常?

java - 重新编译JD-GUI从jar中反编译出来的java文件

php - 如何从php压缩mp3文件

ANT - 由于找不到符号,javac 编译失败

c++ - GCC 模板问题