多媒体科技视频编码音视频 ffmpeg

FFmpeg 编译支持AV1解码器dav1d

2019-03-27  本文已影响1人  smallest_one

目录

  1. 参考
  2. 编译dav1d
  3. 编译FFmpeg增加dav1d解码器支持

1. 参考

2. 编译dav1d

2.1 下载源码

git clone https://code.videolan.org/videolan/dav1d.git

2.2 编译环境配置

安装编译工具meson(版本>=0.47), Ninja, 对于x86*的设备还要安装nasm (版本>=2.13.02)

meson和Ninja的安装参见mesonbuild.com/Quick-guide

2.3 编译

  1. 执行meson build --buildtype release
  2. 执行ninja -C build

编译默认是生成动态库

root@smallest:/home/dav1d/build# ls src
25a6634@@dav1d_bitdepth_16@sta  25a6634@@dav1d@sha  libdav1d.so.1.0.1
25a6634@@dav1d_bitdepth_8@sta   libdav1d.so
25a6634@@dav1d_entrypoint@sta   libdav1d.so.1

root@smallest:/home/dav1d/include/dav1d# ls 
common.h  data.h  dav1d.h  headers.h  meson.build  picture.h  version.h.in

3. 编译FFmpeg增加dav1d解码器支持

3.1 编写dav1d.pc

FFmpeg的configure脚本会执行一个简单的程序来检测dav1d库是否存在以及版本是否满足要求:

enabled libdav1d          && require_pkg_config libdav1d "dav1d >= 0.2.1" "dav1d/dav1d.h" dav1d_version

其中使用了pkg-config来获取dav1d的头文件和库的路径。

pkg-config是linux下用来管理库/模块的所有编译相关信息的工具,参考
pkg-config简介

编写dav1d.pc如下

# dav1d pkg-config source file

prefix=/home/FFmpeg/thirdparty/dav1d
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name:dav1d 
Description: dav1d
Version: 1.0.1
Requires:
Conflicts:
Libs: -L${libdir} -ldav1d
Libs.private: 
Cflags: -I${includedir}

3.2 编译FFmpeg

./configure --prefix=../buildout --enable-shared --disable-static --enable-libdav1d
# 编译后检查一下config.h中DAV1D是否配置成功了,如`#define CONFIG_LIBDAV1D 1`。
make
make install

3.3 使用dav1d解码器

https://code.videolan.org/videolan/dav1d-test-data.git 中有一些IVF封装格式的AV1视频测试数据

使用ffprobe查看IVF文件的信息,ffprobe 00001148.ivf的输出信息:

[libdav1d @ 0x1992040] libdav1d 0.2.1-10-g3f2bb0d
Input #0, ivf, from '00001148.ivf':
  Duration: 00:00:00.10, start: 0.000000, bitrate: 23685 kb/s
    Stream #0:0: Video: av1 (Main) (AV01 / 0x31305641), yuv420p(tv), 3840x2160, 30 tbr, 30 tbn, 30 tbc
[libdav1d @ 0x1997280] libdav1d 0.2.1-10-g3f2bb0d

把IVF视频文件解码为yuv文件,ffmpeg -i 00001148.ivf -f rawvideo 00001148_yuv420p的输出信息:

[libdav1d @ 0x10bf900] libdav1d 0.2.1-10-g3f2bb0d
Input #0, ivf, from '00001148.ivf':
  Duration: 00:00:00.10, start: 0.000000, bitrate: 23685 kb/s
    Stream #0:0: Video: av1 (Main) (AV01 / 0x31305641), yuv420p(tv), 3840x2160, 30 tbr, 30 tbn, 30 tbc
[libdav1d @ 0x10c0540] libdav1d 0.2.1-10-g3f2bb0d
Stream mapping:
  Stream #0:0 -> #0:0 (av1 (libdav1d) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to '00001148_yuv420p':
  Metadata:
    encoder         : Lavf58.26.101
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 3840x2160, q=2-31, 2985984 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.47.105 rawvideo
frame=    3 fps=0.0 q=-0.0 Lsize=   36450kB time=00:00:00.10 bitrate=2985984.0kbits/s speed=0.21x    
video:36450kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
上一篇下一篇

猜你喜欢

热点阅读