English 中文(简体)
仅靠双双双轨制击
原标题:Compile ffmpeg as stand alone binary

I m 试图将ffmpeg作为独立的双手(因为我想在AWS lambda中使用)

在Im编辑的服务器上,我可以做一些事情,但是,如果我复制本并从另一个服务器操作,我会:

/ffmpeg:在装上共享图书馆时的错误:libvdpau.so.1:不能开立共同的物体档案: 无此类档案或目录

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

是否有人失踪?

最佳回答

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

纯粹的静态平衡,就会是trick和肉。 你们必须建设你们所需要的每一个静态平衡,然后努力在大战中增加新的ld。

另一种选择是将这些校准/参考/组合整理成大的工具。 其中一部分列于以下网站:。 包裹共用图书馆进入代号

问题回答

尽管我成功地用双双手汇编了所有材料,但我还是能够把依赖物上载到AWS lambda:

copy all dependencies in a folder

我写了一幅大写的文字来做。 文字依据<代码>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( 
 ):
    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

  • include the ffmpeg binary as well as the libs folder in the lambda zipped code。
  • in the lambda code, include the corresponding paths。 In node。js this can be done as:

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

添加<条码>-extra-ldexeflags=“-static”,以获得独立的条码。

如果您在开发机上有Nix,你可以使用以下一种指令:

nix-build  <nixpkgs>  -A pkgsStatic.ffmpeg-full
# this might take a while, since you re compiling **everything** required by ffmpeg
# once this is done, check that the file is what you need
file ./result/bin/ffmpeg

如果你处于ARM64-030,需要静态AMD64,则情况有所不同。 Denis Gosnell s blog for more details.





相关问题
java in-memory on-the-fly class compilation (and loading)

I want to revisit an old question of mine about in-memory "compilation" of classes. Since about 1/2 a year have passed since I asked (and was somewhat answered), I d like to re-raise the issue and see ...

(c)make - resursive compile

Let s assume I have directories like: dir1 main.cpp dir2 abc.cpp dir3 def.cpp dir4 ghi.cpp jkl.cpp And let s assume that main.cpp ...

How to link to a static library in C?

I use code::blocks to compile my static library. The output result is a libstatic.a file. Now, how do I link to my library to use functions that were compiled? (I tried to use #include "libstatic.a"...

Statically linking Winsock?

I m using Winsock 1.1 in my project. I include wsock32.lib in "Additional Dependencies". I m looking at the DLL project using depends.exe and notice that the DLL depends on wsock32.dll. How can I ...

热门标签