将ffmpeg编译为独立二进制文件 [英] Compile ffmpeg as stand alone binary

查看:426
本文介绍了将ffmpeg编译为独立二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



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



所以听起来好像没有把它变成二进制文件。从我读过的,我必须使用标志 - disable-shared - 启用静态,我已经做了:

  PATH =$ HOME / bin:$ PATHPKG_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:$ PATHmake
make install
make distclean
hash -r

有没有我缺少的东西?

解决方案

- enable-静态 - disable-共享的仅影响 libav * 二进制文件。它不会阻止链接器使用必要的共享对象文件。



对于纯静态库,这将是棘手和混乱。您必须构建您需要的每个静态lib,然后尝试添加其他ldflags进行配置。



另一个选择是将这些lib / elfs /二进制文件打包成一个大的工具。其中一些列在这里:将共享库包装入精灵


I'm trying to compile ffmpeg as a standalone binary (because I want to use it in AWS lambda)

I can get things to work fine on the server where I'm compiling, but if I copy the binary and run it from another server, I get:

./ffmpeg: error while loading shared libraries: libvdpau.so.1: cannot open shared object file: No such file or directory

So it sounds like something didn't made it into the binary. From what I've read, I've to compile ffmpeg with the flags --disable-shared and --enable-static, which I've done:

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

Is there something I'm missing?

解决方案

--enable-static and --disable-shared only affect libav* binaries. It doesn't prevent linker to use necessary shared object files.

For a pure static lib, this is going to be tricky and mess. You have to build every static lib you need, then try to add additional ldflags to configure.

Another alternative is some tools packing those libs/elfs/binaries into a big one. Some of them are listed here: Pack shared libraries into the elf

这篇关于将ffmpeg编译为独立二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆