美文网首页
Mac下编译FFmpeg

Mac下编译FFmpeg

作者: YYYYYoung | 来源:发表于2019-07-22 00:05 被阅读0次

    官方编译文档:

    https://trac.ffmpeg.org/wiki/CompilationGuide/macOS

    一、安装Homebrew

    
    /usr/bin/ruby-e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
    

    二、下载FFmpeg源码

    1、官网下载页面下载源码压缩包解压:http://ffmpeg.org/download.html
    2、通过Git下载

    git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
    

    三、通过Homebrew安装相关依赖库

    brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 x265 xvid nasm
    

    四、编译脚步

    在FFmpeg源码根目录创建编译脚步文件build4mac.sh,内容如下:

    function build_mac
    {
        echo "start build ffmpeg"
        
        ./configure \
            --prefix=/usr/local \
            --enable-gpl \
            --enable-nonfree \
            --enable-libass \
            --enable-libfdk-aac \
            --enable-libfreetype \
            --enable-libmp3lame \
            --enable-libopus \
            --enable-libtheora \
            --enable-libvorbis \
            --enable-libvpx \
            --enable-libx264 \
            --enable-libxvid \
            --enable-shared \
    #       --enable-static \    
            --enable-avdevice \
            --enable-libopus \
            --extra-ldflags=-L/usr/local/lib
    
        make clean
        make -j16 
        make install
    
        echo "build ffmpeg end!"
    }
    
    build_mac
    

    执行编译脚本

    sudo sh build4mac.sh
    

    五、完成编译

    可以看到在/usr/local/lib路径下面看到以下编译好的相关库文件


    image.png



    错误一:ERROR: libass not found using pkg-config

    一开始以为是libass没有安装

    brew install libass
    
    image.png

    可是提示已经安装了,后面才发现原来是pkg-config没有安装

    brew install pkg-config
    

    相关文章

      网友评论

          本文标题:Mac下编译FFmpeg

          本文链接:https://www.haomeiwen.com/subject/teublctx.html