FFmpeg运用实践活动之指令查看

0. 序言

FFmpeg 中常见的专用工具有三个,分别是多媒体系统编码解码专用工具ffmpeg、多媒体系统评析专用工具ffprobe和多多媒体播放器ffplay。文中详细介绍的命令全是与编码解码专用工具 ffmpeg 有关的。

学好查看内嵌文本文档可以处理大家碰到的许多 基本参数难题,还可以防止由于在网上各种各样版本号不一样、品质良莠不齐的回答而疑惑。

1. ffmpeg 协助信息内容

ffmpeg cmd命令英语的语法文件格式以下

ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...

ffmpeg cmd运用中,最基本的实际操作便是查看一些例如版本号、适用的编码方法/转码软件/ps滤镜等信息内容。

最先我们要学好应用的是最为基本上的一个指令 -help,拥有它大家就可以更开心地学习培训与之有关的各种各样作用了。

实行 ffmpeg -h 后,在终端设备会打印出出与当今应用版本号有关的协助信息内容。一般在 Linux 系统软件下应用时可以用以下所显示的cmd命令,运用管路再加上 less 后能够应用 /match_template 来迅速配对精准定位到自身关注的一部分。

~$ ffmpeg -h full | less
ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth
--enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme
--enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus
--enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr
--enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq
--enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm
--enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
...

除开以上最基本上的操作方法外,应用 -h type=name 主要参数能够用于查询特定名字的编/视频解码器、重复使用/解复用器、ps滤镜等的详细资料,十分好用。例如下边的实例中查询 H.264(AVC) 伺服电机的配备主要参数。

~$ ffmpeg -h encoder=h264 | less
...
Encoder libx264 [libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:
    General capabilities: delay threads
    Threading capabilities: auto
    Supported pixel formats: yuv420p yuvj421080 yuv422p yuvj422p yuv444p yuvj444p nv12 nv16 nv21
libx264 AVOptions:
...

ffmpeg -h 輸出信息内容中能够见到,ffmpeg 普遍指令大约分成六类,分别是

  • ffmpeg 记录查询一部分
  • 全局性配备主要参数一部分
  • 文档关键配备主要参数一部分
  • 视頻配备主要参数一部分
  • 声频配备主要参数一部分
  • 外挂字幕配备主要参数一部分

2. ffmpeg 记录查询命令

能够根据本小标题的主要参数来查看 ffmpeg 适用的封裝或是编码解码文件格式等。

-L                  表明ffmpeg现阶段所适用的License协议书
-version            表明版本信息
-buildconf          表明编译程序配备
-formats            表明可以用的文件格式
-muxers             表明可以用的复用器
-demuxers           表明可以用的解复用器
-devices            表明可以用的机器设备
-codecs             表明可以用的转码软件,包含伺服电机和视频解码器
-decoders           表明可以用的视频解码器
-encoders           表明可以用的伺服电机
-bsfs               表明可以用的比特流ps滤镜
-protocols          表明可以用的协议书
-filters            表明可以用的ps滤镜
-pix_fmts           表明可以用的像素格式
-layouts            表明规范音道名字
-sample_fmts        表明可以用的声频取样文件格式
-colors             表明可以用的颜色名称
-sources device     列举输出设备的来源于
-sinks device       列举外部设备的信号接收器
-hwaccels           表明可以用的HW加快方式 

例如应用 -version 主要参数能够查询 ffmepg 的版本号,包含子控制模块如libavutil、libavcodec、libavformat、libavdevice、libavfilter、libavresample、libswscale、libswresample、libpostproc等的详尽版本信息。

应用 -formats 主要参数能够查询当今应用的 ffmpeg 是不是适用相匹配文档的视频文件格式。那样在我们应用 ffmpeg 转换格式时假如碰到出错提醒不兼容转化成相匹配的视频文件格式,就可以开展相对应的调节。

以下实例是应用 -devices 主要参数列举可以用机器设备的輸出結果。

~$ ffmpeg -devices
...
Devices:
 D. = Demuxing supported
 .E = Muxing supported
 --
 DE alsa            ALSA audio output
  E caca            caca (color ASCII art) output device
 DE fbdev           Linux framebuffer
 D  iec61883        libiec61883 (new DV1394) A/V input device
 D  jack            JACK Audio Connection Kit
 D  lavfi           Libavfilter virtual input device
 D  libcdio          
 D  libdc1394       dc1394 v.2 A/V grab
 D  openal          OpenAL audio capture device
  E opengl          OpenGL output
 DE oss             OSS (Open Sound System) playback
 DE pulse           Pulse audio output
  E sdl,sdl2        SDL2 output device
 DE sndio           sndio audio playback
  E v4l2            Video4Linux2 output device
 D  video4linux2,v4l2 Video4Linux2 device grab
 D  x11grab         X11 screen capture, using XCB
  E xv              XV (XVideo) output device

3. 全局性有关的配备选择项

Global options (affect whole program instead of just one file:
-loglevel loglevel  set logging level
-v loglevel         set logging level
-report             generate a report
-max_alloc bytes    set maximum size of a single allocated block
-y                  overwrite output files
-n                  never overwrite output files
-ignore_unknown     Ignore unknown stream types
-filter_threads     number of non-complex filter threads
-filter_complex_threads  number of threads for -filter_complex
-stats              print progress report during encoding
-max_error_rate ratio of errors (0.0: no errors, 1.0: 100% error  maximum error rate
-bits_per_raw_sample number  set the number of bits per raw sample
-vol volume         change audio volume (256=normal)

-v loglevel 用以设定日志輸出等级,不一样的级别輸出的信息内容相对密度和关键水平有所区别,一般设成 info 就能获得充足的信息内容用以调节。

-y 用以輸出时遮盖现有文档。

4. 单独文档有关的配备选择项

Per-file main options:
-f fmt              force format
-c codec            codec name
-codec codec        codec name
-pre preset         preset name
-map_metadata outfile[,metadata]:infile[,metadata]  set metadata information of outfile from infile
-t duration         record or transcode "duration" seconds of audio/video
-to time_stop       record or transcode stop time
-fs limit_size      set the limit file size in bytes
-ss time_off        set the start time offset
-sseof time_off     set the start time offset relative to EOF
-seek_timestamp     enable/disable seeking by timestamp with -ss
-timestamp time     set the recording timestamp ('now' to set the current time)
-metadata string=string  add metadata
-program title=string:st=number...  add program with specified streams
-target type        specify target file type ("vcd", "svcd", "dvd", "dv" or "dv50" with optional prefixes "pal-", "ntsc-" or "film-")
-apad               audio pad
-frames number      set the number of frames to output
-filter filter_graph  set stream filtergraph
-filter_script filename  read stream filtergraph description from a file
-reinit_filter      reinit filtergraph on input parameter changes
-discard            discard
-disposition        disposition

-f fmt 用以特定輸出或輸出文件的格式。

-frames number 用以设定輸出文档帧的总数。

5. 多媒体播放有关的配备选择项

Video options:
-vframes number     set the number of video frames to output
-r rate             set frame rate (Hz value, fraction or abbreviation)
-s size             set frame size (WxH or abbreviation)
-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-bits_per_raw_sample number  set the number of bits per raw sample
-vn                 disable video
-vcodec codec       force video codec ('copy' to copy stream)
-timecode hh:mm:ss[:;.]ff  set initial TimeCode value.
-pass n             select the pass number (1 to 3)
-vf filter_graph    set video filters
-ab bitrate         audio bitrate (please use -b:a)
-b bitrate          video bitrate (please use -b:v)
-dn                 disable data

-vframes number 用以设定輸出视頻帧的总数。

-r rate 用以设定輸出视頻的帧数。

-vn 常见于只保存声频数据信息的场所。

-vf filter_graph 用以配备有关的ps滤镜。

6. 多媒体系统声频有关的配备选择项

Audio options:
-aframes number     set the number of audio frames to output
-aq quality         set audio quality (codec-specific)
-ar rate            set audio sampling rate (in Hz)
-ac channels        set number of audio channels
-an                 disable audio
-acodec codec       force audio codec ('copy' to copy stream)
-vol volume         change audio volume (256=normal)
-af filter_graph    set audio filters

-ac channels 用以设定声频安全通道总数,单声道、环绕声等。

-an 常见于只保存视頻数据信息的场所。

7. 多媒体系统外挂字幕有关的配备选择项

Subtitle options:
-s size             set frame size (WxH or abbreviation)
-sn                 disable subtitle
-scodec codec       force subtitle codec ('copy' to copy stream)
-stag fourcc/tag    force subtitle tag/fourcc
-fix_sub_duration   fix subtitles duration
-canvas_size size   set canvas size (WxH or abbreviation)
-spre preset        set the subtitle options to the indicated preset

-sn 设定輸出結果中屏蔽掉外挂字幕信息内容,只保存声频或视頻。


参考文献

[1] ffmpeg Documentation http://ffmpeg.org/ffmpeg-all.html

[2] FFmpeg命令行工具-好用指令 https://www.jianshu.com/p/124aee284a61

[3] ffmpeg常用命令 #32 https://GitHub.com/gnipbao/iblog/issues/32

文中创作者 :phillee
发布日期 :2021年5月19日
文中连接https://www.cnblogs.com/phillee/p/14785534.html
版权声明 :随意转截-非商业-非衍化-维持落款(艺术创意共享资源3.0授权文件/CC BY-NC-SA 3.0)。转截请标明来源!
仅限于自己水准,假如文章内容和编码有描述不妥,还请鼎力相助。

感谢你们的适用

¥ 打赏主播

微信付款

评论(0条)

刀客源码 游客评论