文章

AI - media-ffmpeg-使用

AI - media-ffmpeg-使用

media-ffmpeg-使用

因为项目需要用到对媒体处理(其实最好的方式是购买在线服务,但是所有资源又需要使用云厂商的oss资源,干脆暂时由服务器资源来支撑,然后增加异步队列来完成对资源的利用和成本的控制)。

有关在线实时STT(Sound To Text)

这个是采买几家服务,然后用来线路自动切换,但是不同服务商对音频的格式支持方式也不一定全部相同,所以我们再二次对音频统一化处理后,到不同服务商处理前按照格式的要求再一次转换即可。

有关视频自定义水印

有的服务商支持水印,但是功能上可以进行选择有水印和无水印,或者自动控制水印(事实上每次第三方API请求次数都是一次费用成本)。

安装ffmpeg

ubuntu

  • 直接apt命令行安装

    1
    2
    3
    4
    5
    
    #安装
    apt-get install ffmpeg
    #安装后的版本
    ffmpeg -version
    #out: ffmpeg version 5.1.8-0+deb12u1
    
  • 指定版本安装

    为何要指定版本安装? https://pkg.go.dev/github.com/filipenevs/go-videowatermark#section-readme

    如果想使用github.com/filipenevs/go-videowatermark 则对版本有限制。

    ⚠️ Compatibility Notice

    This package has been tested and confirmed to work with FFmpeg v6.1.1. It may be compatible with newer versions, but extensive testing has not yet been conducted. If you encounter any issues with newer FFmpeg versions, please open an issue on the repository.

    高版本不知道可能发生的情况,建议单元测试。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
    sudo apt update
    sudo apt install build-essential yasm libx264-dev libx265-dev libvpx-dev libfdk-aac-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libass-dev libwebp-dev libsoxr-dev libxvidcore-dev libx264-164 libx265-175 libvpx6 libmp3lame0 libopus0 libtheora0 libvorbis0a libass9 libwebp7 libsoxr0 libxvidcore4v5 nasm
      
    # 下载源码
    wget http://ffmpeg.org/releases/ffmpeg-8.0.1.tar.xz
    tar xvf ffmpeg-8.0.1.tar.xz
    cd ffmpeg-8.0.1
      
    # 配置设置
    ./configure --prefix=/usr/local --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-nonfree
    make
    sudo make install
      
    ##
    ffmpeg -version
    
本文由作者按照 CC BY 4.0 进行授权