ffmpeg学习

前言

最近开始入坑视频相关操作了,少不了神器ffmpeg。ffmpeg的好书一本《FFmpeg从入门到精通》。浅显易懂,1个多小时可以过一遍,当工具书翻翻还是不错的。

1 好用的命令

1)linux查看设备列表

$ ffmpeg -hide_banner -devices
Devices:
 D. = Demuxing supported
 .E = Muxing supported
 --
 DE fbdev           Linux framebuffer
 D  lavfi           Libavfilter virtual input device
 DE oss             OSS (Open Sound System) playback
 DE video4linux2,v4l2 Video4Linux2 output device
 D  x11grab         X11 screen capture, using XCB

可以看到这里有常见的v4l2同时支持封装与解封装

2)查看设备v4l2有哪些可用参数

$ ffmpeg -h demuxer=v4l2 
ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
Demuxer video4linux2,v4l2 [Video4Linux2 device grab]:
V4L2 indev AVOptions:
  -standard          <string>     .D....... set TV standard, used only by analog frame grabber
  -channel           <int>        .D....... set TV channel, used only by frame grabber (from -1 to INT_MAX) (default -1)
  -video_size        <image_size> .D....... set frame size
  -pixel_format      <string>     .D....... set preferred pixel format
  -input_format      <string>     .D....... set preferred pixel format (for raw video) or codec name
  -framerate         <string>     .D....... set frame rate
  -list_formats      <int>        .D....... list available formats and exit (from 0 to INT_MAX) (default 0)
     all                          .D....... show all available formats
     raw                          .D....... show only non-compressed formats
     compressed                   .D....... show only compressed formats
  -list_standards    <int>        .D....... list supported standards and exit (from 0 to 1) (default 0)
     all                          .D....... show all supported standards
  -timestamps        <int>        .D....... set type of timestamps for grabbed frames (from 0 to 2) (default default)
     default                      .D....... use timestamps from the kernel
     abs                          .D....... use absolute timestamps (wall clock)
     mono2abs                     .D....... force conversion from monotonic to absolute timestamps
  -ts                <int>        .D....... set type of timestamps for grabbed frames (from 0 to 2) (default default)
     default                      .D....... use timestamps from the kernel
     abs                          .D....... use absolute timestamps (wall clock)
     mono2abs                     .D....... force conversion from monotonic to absolute timestamps
  -use_libv4l2       <boolean>    .D....... use libv4l2 (v4l-utils) conversion functions (default false)

包含set的选项可设置,可以设置帧率,分辨率等。也可以用命令行配合选项比如list_formats查询相关信息

3)查看我的usb摄像头支持的色彩格式和分辨率

/$ ffmpeg -hide_banner -f v4l2 -list_formats all -i /dev/video0
[video4linux2,v4l2 @ 0x55638ed936c0] Compressed:       mjpeg :          Motion-JPEG : 1920x1080 1280x720 800x600 640x480 640x360 352x288 320x240 1920x1080
[video4linux2,v4l2 @ 0x55638ed936c0] Raw       :     yuyv422 :           YUYV 4:2:2 : 640x480 800x600 640x360 352x288 320x240 640x480

raw数据为yuyv格式,最大图像分辨率为800x600. 支持压缩格式MJPG,输出分辨率最大为1920x1080.

你可能感兴趣的:(音视频)