1)常用命令

1、最简单转换命令

ffmpeg -i input.mp4 output.mkv

2、更加精准的控制转换命令

ffmpeg -i input.mp4 -c:v vp9 -c:a libvorbis output.mkv

(-c:v  控制视频格式, -c:a  控制音频格式)

3、调节比特率

ffmpeg -i  GVG-981.mp4 -c:v libx264 -b:v 2M -maxrate 2M -bufsize 1M GVG-981-out.mp4

ffmpeg -i input.webm -c:a copy -c:v vp9 -b:v 1M output.mkv

(-b:v 1M 代表着视频的比特率变成1Mb

This will copy the audio (-c:a copy) from input.webm and convert the video to a VP9 codec (-c:v vp9) with a bit rate of 1M/s (-b:v), all bundled up in a Matroska container (output.mkv).)

4、调节帧率

ffmpeg -i 002.mp4 -filter:v fps=fps=29.97  002-out.mp4

ffmpeg -i input.webm -c:a copy -c:v vp9 -r 30 output.mkv

(This creates a new Matroska with the audio stream copied over and the video stream's frame rate forced to 30 frames per second, instead of using the frame rate from the input (-r 30).)

5、调节视频尺寸(分辨率)

ffmpeg -i  FC2PPV-402422-1.mp4 -c:a copy -s 854x480 FC2PPV-402422-1-out.mp4

ffmpeg -i input.mkv -c:a copy -s 1280x720 output.mkv

(声音原封不动拷贝过去,视频编码格式不变,只是尺寸调整到1280x720)

6、截取部分视频(时长)

ffmpeg -i input.mkv -c:a  copy  -c:v copy  -ss 00:01:00  -t 10  output.mkv

(音视频格式不变, 从00:01:00开始拷贝10s过去)

7、 提取关键帧

ffmpeg -skip_frame nokey -i 480P_2000K_204282351.mp4 -vsync 0 -r 30 -f image2 480P_2000K_204282351\%02d.png

8、对视频进行帧提取

ffmpeg -i .\input.mp4 -vf 'select=gte(n\,1),setpts=PTS-STARTPTS' 'input/%05d.png'

ffmpeg -i .\input.mp4 -vf 'select=gte(n\,1),setpts=0.5*PTS' 'input/%05d.png'

ffmpeg -i .\input.mp4 -vf 'select=between(n\,{START_FRAME}\,{END_FRAME}),setpts=0.5*PTS' 'input/%05d.png'

setpts的具体参数含义如下:

  • Start counting PTS from zero

    setpts=PTS-STARTPTS
    
  • Apply fast motion effect:
    setpts=0.5*PTS
    
  • Apply slow motion effect:
    setpts=2.0*PTS
    
  • Set fixed rate of 25 frames per second:
    setpts=N/(25*TB)
    
  • Set fixed rate 25 fps with some jitter:
    setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))'
    
  • Apply an offset of 10 seconds to the input PTS:
    setpts=PTS+10/TB
    
  • Generate timestamps from a "live source" and rebase onto the current timebase:
    setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
    
  • Generate timestamps by counting samples:
    asetpts=N/SR/TB

9、从png序列生成视频文件

ffmpeg -y -r {TARGET_FPS} -f image2 -pattern_type glob -i '*.png' '/content/gdrive/My Drive/{OUTPUT_FILE_PATH}'

2)命令基本语法

注意:这里面的非方括号部分(蓝字)都是必须得有的。

全局选项:

Global options (affect whole program instead of just one file:
-loglevel loglevel  set libav* logging level
-v loglevel         set libav* logging level
-report             generate a report
-max_alloc bytes    set maximum size of a single allocated block
-y                  overwrite output files
-n                  do not overwrite output files
-stats              print progress report during encoding
-bits_per_raw_sample number  set the number of bits per raw sample
-vol volume         change audio volume (256=normal)

输入输出选项:

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
-timestamp time     set the recording timestamp ('now' to set the current time)
-metadata string=string  add metadata
-target type        specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", ...)
-frames number      set the number of frames to record
-filter filter_graph  set stream filtergraph
-reinit_filter      reinit filtergraph on input parameter changes

Video options:
-vframes number     set the number of video frames to record
-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
-b bitrate          video bitrate (please use -b:v)
-dn                 disable data

Audio options:
-aframes number     set the number of audio frames to record
-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

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

3)ffmpeg背后的多媒体基础知识

看这里

ffmpeg命令基本语法和常见命令相关推荐

  1. linux命令的含义,Linux常见命令及含义

    1.查看目录结构 ls(list) :列出 ll :列出当前目录下的文件信息 ls -al :列出当前目录下的文件信息(包括隐藏文件,特殊目录) ll /bin/ :列出根目录下bin目录下的文件信息 ...

  2. centos6查看java命令_centos6.5下常见命令和操作

    本章内容概览: 1.linux系统下配置ip地址 2.linux系统下安装jdk并配置环境变量 3.linux系统下安装tomcat并配置环境变量 4.linux系统下安装ssh远程登陆工具并实现免密 ...

  3. centos命令失效_CentOS 7 常见命令、问题及解决方式

    1. CentOS minimal新安装: 使用 ip addr 即查看网卡分配情况. 在虚拟机中以最小化方式安装CentOS 7,后无法上网,因为CentOS 7默认网卡未激活. 而且在sbin目录 ...

  4. docker pull的镜像放在哪里_Docker 安装ELK及Docker常见命令

    最近搭建基于Spring Cloud的微服务框架,日志系统当然最佳选择就是ELK.看着MAC 那紧巴巴的配置,又不想热情退去而留下一堆软件,果断选择Docker安装来节省那可怜的资源.当然这只是鹏哥的 ...

  5. mysql数据库入门教程(2):常见命令大全,语法规范

    1常见命令 前提是先登录客户端 1查询 创建 删除 -数据库 查询数据库 SHOW DATABASES [LIKE '数据库名']: 不区分大小写 :代表要执行以上语句 语法说明: LIKE是可选项, ...

  6. 04-mysql常见命令,语法规范,

    P12012_MySQL基础_MySQL常见命令介绍 >显示所有数据库 test为测试数据库 >切换使用数据库 >查询另一个库中的所有表 >查看当前选中的数据库 >创建数 ...

  7. Memcache 安装和常见命令

    memcached常见命令 1.安装libevent  wget https://github.com/downloads/libevent/libevent/libevent-1.4.10-stab ...

  8. Linux vi 编辑器常见命令的使用

    Linux vi 编辑器常见命令的使用 Linux下的文本编辑器有很多种,vi 是最常用的,也是各版本Linux的标配.注意,vi 仅仅是一个文本编辑器,可以给字符着色,可以自动补全,但是不像 Win ...

  9. linux将字符串转小写_小猿圈总结Linux常见命令(一)

    科技发展的今天,互联网不断的发达,很多人学习Linux云计算的时候回因为记不住一些命令从而去找度娘,有时候因为因为找不到linux的命令而烦恼,下面是小猿圈linux讲师给大家总结的linux常见命令 ...

  10. 分布式文档存储独角兽MongoDB——MongoDB常见命令(2)

    分布式文档存储独角兽MongoDB 二.MongoDB常见命令 1.1 MongoDB的基本操作 查看数据库 show dbs; 切换数据库 如果没有对应的数据库则创建 use 数据库名; 切换库,如 ...

最新文章

  1. java 实体类包含list 怎么取值_2019 最新 500 道 Java 面试题
  2. 实现库函数strcpy
  3. 运行npm update等命令出错后如何分析问题根源
  4. JAVA中protected的作用
  5. OpenXml开发-向Excel2007文档中添加数据
  6. L2-012 关于堆的判断(模拟堆+字符串处理)
  7. javascript常用函数集
  8. php怎么写脚本,PHP脚本来写Daemon程序_php
  9. still a week before on board
  10. Arcgis学习视频
  11. k均值聚类算法考试例题_k均值算法(k均值聚类算法计算题)
  12. 防灾科技学院考研计算机,防灾科技学院考研难吗
  13. LR(1)分析法的总控的实现(C++实现)
  14. Chrome浏览器添加信任站点
  15. VC++6.0显示此程序存在兼容问题解决办法
  16. android 地球坐标 火星坐标系,Android LBS地图开发:地球地理GPS坐标系经纬度偏移偏差...
  17. nginx 前端小图标配置
  18. 对象不支持attachEvent
  19. Java图形化界面编程超详细知识点(9)——Swing_树
  20. 不规则四边形填充平面 - Townscaper 网格生成算法复现

热门文章

  1. 思科ASA防火墙升级为云端防火墙
  2. mysql损坏打不开_mac系统上 MySQL Workbench意外退出,再也打不开
  3. Express框架学习笔记-模板引擎
  4. 如何在游标里控制条件_如何在冰冻条件下保护控制球阀?
  5. tp3.2 隐藏index.php,thinkphp3.2.3隐藏index.php入口文件
  6. php 变量 unset,在PHP中unset变量
  7. oracle分区实战,Oracle分区实战分享
  8. MySQL(5)-----DQL语句的基本查询与高级查询
  9. React ~ 生命周期
  10. spring-cloud-sleuth 和 分布式链路跟踪系统