在學習一下ffmpeg濾鏡的使用,無奈濾鏡種類繁多,並且每一個濾鏡其命令行支持的參數也是各種各樣,當然網上也可以找到很多關於常用濾鏡的參數的解釋,既然支持這些參數,那麼源碼中肯定是有對這些參數進行唯一的解析的,我想肯定有一個官方的解釋的,那麼怎麼查看這些濾鏡的參數說明呢?
命令行如下:
#ffmpeg -h filter=XXX 列出xxx濾鏡的help說明
比如: 下面對所有支持的選項,都有解釋說明。
(使用之前,可以使用 ffmpeg -filters 列出所有支持的濾鏡,這個-filters 選項,同樣可以追溯到 ffmpeg --help中看到 關於ffmpeg -filters的解釋。只是想說明,這些參數用法解釋等等都有原始的出處,並且更加全面)
#ffmpeg -h filter=drawtext
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
configuration: --enable-libfreetype
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
Filter drawtext
Draw text on top of video frames using libfreetype library.
Inputs:
#0: default (video)
Outputs:
#0: default (video)
drawtext AVOptions:
fontfile <string> ..FV..... set font file
text <string> ..FV..... set text
textfile <string> ..FV..... set text file
fontcolor <color> ..FV..... set foreground color (default "black")
fontcolor_expr <string> ..FV..... set foreground color expression (default "")
boxcolor <color> ..FV..... set box color (default "white")
bordercolor <color> ..FV..... set border color (default "black")
shadowcolor <color> ..FV..... set shadow color (default "black")
box <boolean> ..FV..... set box (default false)
boxborderw <int> ..FV..... set box border width (from INT_MIN to INT_MAX)
。。。。。篇幅所限,就不全部粘貼了,還有一大串參數
常用:
-formats show available formats
-muxers show available muxers
-demuxers show available demuxers
-devices show available devices
-codecs show available codecs
-decoders show available decoders
-encoders show available encoders
顯示一個 解碼器的參數說明: #ffmpeg -h decoder=h264
顯示一個 編碼器的參數說明: #ffmpeg -h encoder=libx264 (前提是要enable了x264哦)
顯示一個 解複用器參數說明: #ffmpeg -h demuxer=mp4
顯示一個 複用器的參數說明: #ffmpeg -h muxer=mp4
=============================一個簡單的分割線=======================================
下面開始從源碼層面解釋,可以在ffmpeg源碼中(我這裏是4.1版本)看到:
libavfiler目錄下面都是 vf_** 和av_** 顧名思義就是 video filter 和 audio filter,其中還有一個文件 filter_list.c, 此文件在 cofigure的時候,根據具體配置生成, 其內容就是一個全局數組,保存所有的濾鏡AVFilter。
每一個 AVFilter,都有它的 description 和內部的 AVOption, 就是對應源碼中就有對這些參數的解釋:
這個options在ffmpeg 的命令解釋到-h時會調用,輸出具體的help信息: