FFmpeg一款开源的视频压缩工具最新版(带简单教程附干货)

关于软件

FFmpeg是领先的多媒体框架,可进行解码,编码,转码,多路复用,多路复用,流,过滤和播放。所有版本至少需要Windows 7或Mac OS X 10.10。每晚的git版本被许可为GPL 3.0,而发布版本被许可为GPL 3.0和LGPL 3.0。可以使用“所有版本”链接找到LGPL 3.0发布版本。

国内很多知名的软件如暴风影音、QQ影音、KMP、GOM Player、PotPlayer(2010)、KMPlayer等等均采用的是FFmpeg内核,自己做了点小优化和皮子。FFmpeg是一套领先的音视频多媒体处理开源框架,采用LGPL或GPL许可证。它提供了对音视频的采集、编码、解码、转码、音视频分离、合并、流化、过滤器等丰富的功能,包含了非常先进的音频/视频编解码库libavcodec,具有非常高的可移植性和编解码质量,是一个多媒体处理神器。同时FFmpeg也提供了命令包,可以在Windows、Linux等平台上使用,很多人觉得FFmpeg用起来难,其实只要我们安装好了FFmpeg命令工具后,就可以在Windows上快速实现视频格式转换、视频压缩以及视频与图片之间的相互转换了。

官方网址:https://www.ffmpeg.org/

官方论坛:https://ffmpeg.zeranoe.com/forum/

《FFmpeg一款开源的视频压缩工具最新版(带简单教程附干货)》

 

软件特点

优点:绿色、小巧、命令行工具、免费、开源、支持多线程(很吃CPU)、支持多系统

缺点:命令行用起来有点不方便、不适合新手

软件下载

下载地址:https://ffmpeg.zeranoe.com/builds/

《FFmpeg一款开源的视频压缩工具最新版(带简单教程附干货)》

注意选择好系统,点击选择下载即可。地址不可以下载了可以留言。

源码下载(开源):https://www.ffmpeg.org/download.html

安装及命令

下载好程序文件解压,进入bin目录,那3个文件就是程序文件了,例如我:打开CMD进入/bin文件夹

《FFmpeg一款开源的视频压缩工具最新版(带简单教程附干货)》

直接输入ffmpeg.exe,有下图提示,表示运行正常。

注意,想经常使用的话,最好能够能把你的程序文件夹路径添加到系统变量里面,这样就可以像CMD一样去使用它了,由于我个人喜欢绿色的,并且不常用所以我就无所谓了

D:\Users\shikey\Downloads\Compressed\ffmpeg-20200312-675bb1f-win64-static\bin>ffmpeg.exe

《FFmpeg一款开源的视频压缩工具最新版(带简单教程附干货)》

输入ffmpeg.exe –h可查看所有命令

D:\Users\shikey\Downloads\Compressed\ffmpeg-20200312-675bb1f-win64-static\bin>ffmpeg.exe -h
ffmpeg version git-2020-03-12-675bb1f Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig
  libavutil      56. 42.100 / 56. 42.100
  libavcodec     58. 75.100 / 58. 75.100
  libavformat    58. 41.100 / 58. 41.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 77.100 /  7. 77.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Getting help:
    -h      -- print basic options
    -h long -- print more options
    -h full -- print all options (including all format and codec specific options, very long)
    -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol
    See man ffmpeg for detailed description of the options.

Print help / information / capabilities:
-L                  show license
-h topic            show help
-? topic            show help
-help topic         show help
--help topic        show help
-version            show version
-buildconf          show build configuration
-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
-bsfs               show available bit stream filters
-protocols          show available protocols
-filters            show available filters
-pix_fmts           show available pixel formats
-layouts            show standard channel layouts
-sample_fmts        show available audio sample formats
-colors             show available color names
-sources device     list sources of the input device
-sinks device       list sinks of the output device
-hwaccels           show available HW acceleration methods

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 maximum error rate  ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-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
-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

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

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

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

详细中文的,机器翻译的,可以对照来

超快速音频和视频编码器
用法:ffmpeg [选项] [[infile选项] -i infile] ... {[outfile选项] outfile} ...

获得帮助:     -h-打印基本选项     -h long-打印更多选项     -h full-打印所有选项(包括所有格式和编解码器特定的选项,很长)     -h type = name-打印命名的解码器/编码器/解复用器/复用器/过滤器/ bsf /协议的所有选项     有关选项的详细说明,请参见man ffmpeg。

打印帮助/信息/功能:
-L演出许可证
-h主题显示帮助
-?主题显示帮助
-help主题显示帮助
--help主题显示帮助
版本显示版本
-buildconf显示构建配置
-formats显示可用格式
-muxers显示可用的muxers
-demuxers显示可用的多路分解器
-devices显示可用设备
-codecs显示可用的编解码器
-decoders显示可用的解码器
-encoders显示可用的编码器
-bsfs显示可用的位流过滤器
-协议显示可用协议
-filters显示可用的过滤器
-pix_fmts显示可用的像素格式
-layouts显示标准频道布局
-sample_fmts显示可用的音频样本格式
-colors显示可用的颜色名称
-sources设备列出输入设备的来源
-sinks输出设备的设备列表接收器
-hwaccels显示可用的硬件加速方法

全局选项(影响整个程序,而不只是一个文件):
-loglevel loglevel设置日志记录级别
-v loglevel设置日志记录级别
-report生成报告
-max_alloc字节设置单个分配块的最大大小
-y覆盖输出文件
-n从不覆盖输出文件
-ignore_unknown忽略未知的流类型
-filter_threads非复杂过滤器线程数
-filter_complex_threads -filter_complex的线程数
-stats在编码期间打印进度报告
-max_error_rate错误的最大错误率(0.0:无错误,1.0100%错误),ffmpeg高于该比率则返回错误而不是成功。
-bits_per_raw_sample number设置每个原始样本的位数
-vol音量更改音频音量(256 =正常)

每个文件的主要选项:
-f fmt强制格式
-c编解码器编解码器名称
-codec编解码器编解码器名称
-pre预设预设名称
-map_metadata outfile [,metadata]:infile [,metadata]设置infile中outfile的元数据信息
-t持续时间记录或对音频/视频的“持续时间”秒进行代码转换
-to time_stop记录或转码停止时间
-fs limit_size设置限制文件大小(以字节为单位)
-ss time_off设置开始时间偏移
-sseof time_off设置相对于EOF的开始时间偏移
-seek_timestamp使用-ss按时间戳启用/禁用查找
-timestamp time设置记录时间戳(“ now”设置当前时间)
-metadata string =字符串添加元数据
-program title = string:st = number ...添加具有指定流的程序
-target type指定目标文件类型(“ vcd”,“ svcd”,“ dvd”,“ dv”或“ dv50”,带有可选的前缀“ pal-”,“ ntsc-”或“ film-”)
-apad音频垫
-frames number设置要输出的帧数
-filter filter_graph设置流filtergraph
-filter_script filename从文件中读取流filtergraph描述
-reinit_filter在输入参数更改时重新初始化过滤器图

简单教程

原谅我也是一边捣鼓,一边学习的哈,主要的目的在于测试,没有去网上找教程,可能写的比较乱

申明一下以下ffmpeg命令,在没有添加系统变量的情况下,一定要写全地址和文件名ffmpeg.exe,官方文档亦是如此

用法(未添加系统变量):ffmpeg.exe [options] [[infile options] i infile]… {[outfile options] outfile}

用法(添加系统变量):ffmpeg [options] [[infile options] i infile]… {[outfile options] outfile}

全局设置、单个视频设置、单个音频设置,我这里拿视频来说,这里可以对照上面的来说,我仔细瞅了一下,命令有重复的,所以按照我写的顺序来写。

[options]

可以指Perfile main options、Video options、Audio options

Perfile main options ,影响全局的哈,不是针对一个文件,可以不申明

-y覆盖输出文件
-n从不覆盖输出文件
-ignore_unknown忽略未知的流类型
-filter_threads非复杂过滤器线程数
-filter_complex_threads -filter_complex的线程数
-stats在编码期间打印进度报告
-max_error_rate错误的最大错误率(0.0:无错误,1.0100%错误),ffmpeg高于该比率则返回错误而不是成功。
-bits_per_raw_sample number设置每个原始样本的位数
-vol音量更改音频音量(256 =正常)

[[infile options]

单文件属性,可以指音频和视频具体可以参考上面一节

-f fmt强制格式
-c编解码器编解码器名称
-codec编解码器编解码器名称
-pre预设预设名称
-map_metadata outfile [,metadata]:infile [,metadata]设置infile中outfile的元数据信息
-t持续时间记录或对音频/视频的“持续时间”秒进行代码转换
-to time_stop记录或转码停止时间
-fs limit_size设置限制文件大小(以字节为单位)
-ss time_off设置开始时间偏移
-sseof time_off设置相对于EOF的开始时间偏移
-seek_timestamp使用-ss按时间戳启用/禁用查找
-timestamp time设置记录时间戳(“ now”设置当前时间)
-metadata string =字符串添加元数据
-program title = string:st = number ...添加具有指定流的程序
-target type指定目标文件类型(“ vcd”,“ svcd”,“ dvd”,“ dv”或“ dv50”,带有可选的前缀“ pal-”,“ ntsc-”或“ film-”)
-apad音频垫
-frames number设置要输出的帧数
-filter filter_graph设置流filtergraph
-filter_script filename从文件中读取流filtergraph描述
-reinit_filter在输入参数更改时重新初始化过滤器图

常见命令

# 去掉视频中的音频
ffmpeg -i input.mp4 -vcodec copy -an output.mp4
// -an: 去掉音频;-vcodec:视频选项,一般后面加copy表示拷贝

# 提取视频中的音频
ffmpeg -i input.mp4 -acodec copy -vn output.mp3
// -vn: 去掉视频;-acodec: 音频选项, 一般后面加copy表示拷贝

# 音视频合成
ffmpeg -y –i input.mp4 –i input.mp3 –vcodec copy –acodec copy output.mp4
// -y 覆盖输出文件

#剪切视频
ffmpeg -ss 0:1:30 -t 0:0:20 -i input.mp4 -vcodec copy -acodec copy output.mp4
// -ss 开始时间; -t 持续时间

#视频截图
ffmpeg –i test.mp4 –f image2 -t 0.001 -s 320x240 image-%3d.jpg
// -s 设置分辨率; -f 强迫采用格式fmt;

# 视频分解为图片
ffmpeg –i test.mp4 –r 1 –f image2 image-%3d.jpg
// -r 指定截屏频率

# 将图片合成视频
ffmpeg -f image2 -i image%d.jpg output.mp4

#视频拼接
ffmpeg -f concat -i filelist.txt -c copy output.mp4

#将视频转为gif
ffmpeg -i input.mp4 -ss 0:0:30 -t 10 -s 320x240 -pix_fmt rgb24 output.gif
// -pix_fmt 指定编码

#将视频前30帧转为gif
ffmpeg -i input.mp4 -vframes 30 -f gif output.gif

#旋转视频
ffmpeg -i input.mp4 -vf rotate=PI/2 output.mp4

#缩放视频
ffmpeg -i input.mp4 -vf scale=iw/2:-1 output.mp4
// iw 是输入的宽度, iw/2就是一半;-1 为保持宽高比

#视频变速
ffmpeg -i input.mp4 -filter:v setpts=0.5*PTS output.mp4

#音频变速
ffmpeg -i input.mp3 -filter:a atempo=2.0 output.mp3

#音视频同时变速,但是音视频为互倒关系
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4


# 视频添加水印
ffmpeg -i input.mp4 -i logo.jpg -filter_complex [0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out] -map [out] -map 0:a -codec:a copy output.mp4
// main_w-overlay_w-10 视频的宽度-水印的宽度-水印边距;

# 截取视频局部
ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4

# 截取部分视频,从[80,60]的位置开始,截取宽200,高100的视频
ffmpeg -i in.mp4 -filter:v "crop=80:60:200:100" -c:a copy out.mp4

# 截取右下角的四分之一
ffmpeg -i in.mp4 -filter:v "crop=in_w/2:in_h/2:in_w/2:in_h/2" -c:a copy out.mp4

# 截去底部40像素高度
ffmpeg -i in.mp4 -filter:v "crop=in_w:in_h-40" -c:a copy out.mp4

实例操作

我也操作了好几次才搞明白,辛亏电脑配置搞,搞错了很卡的,切记。

我主要参考官方文档来的哈,官方文档实际上比百度、谷歌出来的要更加准确易懂

格式互转

#全部不什么设置,直接将3344.MP4文件转化成3344.flv格式视频
#mp4转flv
ffmpeg.exe -i 3344.mp4 3344.flv
#倒过来也可以转
#其他格式也可以转
ffmpeg -i input.mp4 output.webm
#理论上是支持大部分的decoders支持了MPEG4、H.264、H.265(HEVC)、MP3等格式,文件后缀我不列举了,越写越觉得这东西太他妈的复杂了,不适合我这样的大老粗使用
#将视频的前30帧转化为gif动画
ffmpeg -i input_video.mp4 -vframes 30 -y -f gif output.gif

例如我把我的文件Carlson2020.mp4转换成Carlson2020.flv

#以下为实际操作文件,视频尺寸不变,2分钟的文件,转换过程大概就是几秒钟,我的cpu是I5-9400,2.6主频睿频3.9左右,带集显,这东西还是需要集显的啊,独显用处不大。
ffmpeg.exe -i Carlson2020.mp4 Carlson2020.flv ffmpeg version git-2020-03-12-675bb1f Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9.2.1 (GCC) 20200122 configuration: --enable-gpl --enable-version3 --enable-sdl2 libavutil 56. 42.100 / 56. 42.100 libavcodec 58. 75.100 / 58. 75.100 libavformat 58. 41.100 / 58. 41.100 libavdevice 58. 9.103 / 58. 9.103 libavfilter 7. 77.100 / 7. 77.100 libswscale 5. 6.101 / 5. 6.101 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Carlson2020.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2020-03-13T17:39:43.000000Z Duration: 00:02:19.97, start: 0.000000, bitrate: 667 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709), 1280x720 [SAR 1:1 DAR 16:9], 536 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default) Metadata: creation_time : 2020-03-13T17:39:43.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 03/13/2020. Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: creation_time : 2020-03-13T17:39:43.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 03/13/2020. Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> flv1 (flv)) Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame)) Press [q] to stop, [?] for help Output #0, flv, to 'Carlson2020.flv': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 encoder : Lavf58.41.100 Stream #0:0(und): Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 1k tbn, 30 tbc (default) Metadata: creation_time : 2020-03-13T17:39:43.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 03/13/2020. encoder : Lavc58.75.100 flv Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A Stream #0:1(eng): Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp (default) Metadata: creation_time : 2020-03-13T17:39:43.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 03/13/2020. encoder : Lavc58.75.100 libmp3lame frame= 4199 fps=433 q=31.0 Lsize= 25167kB time=00:02:19.99 bitrate=1472.7kbits/s speed=14.4x video:22829kB audio:2188kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.598556%
转换前视频信息

《FFmpeg一款开源的视频压缩工具最新版(带简单教程附干货)》

转换后视频信息

《FFmpeg一款开源的视频压缩工具最新版(带简单教程附干货)》

对比可以看出基本上视频信息是保持一样的,但是转换后文件大小扩大了将近一倍,也可能是我的格式选的不好吧。我有试了一下转成AVI格式的。结果依然是一样哈,不知道是解码或者编码器不行还是怎么的。只有在转换MOV的时候小了一下,所以对格式要求高的小伙伴并且对文件大小无所谓的,可以试用这个简单命令,需求高的,不推荐。

格式互换高级

#要将输出文件的视频比特率设置为64 kbit / s,请执行以下操作
ffmpeg -i input.avi -b:v 64k -bufsize 64k output.avi
#要将输出文件的帧速率强制为24 fps,请执行以下操作:
ffmpeg -i input.avi -r 24 output.avi
#要将输入文件的帧速率(仅对原始格式有效)强制为1 fps,将输出文件的帧速率强制为24 fps,请执行以下操作:
ffmpeg -r 1 -i input.m2v -r 24 output.avi
#自动流选择
ffmpeg -i A.avi -i B.mp4 out1.mkv out2.wav -map 1:a -c:a copy out3.mov

文件压缩

码率压缩已经在上面的命令里面给出了。实际上还可以在视频尺寸上进一步压缩。

#更改分辨率
ffmpeg -i input.mp4 -filter:v scale=1280:720 -c:a copy output.mp4
# or
ffmpeg -i input.mp4 -s 1280x720 -c:a copy output.mp4
#更改尺寸宽高比
ffmpeg -i input.mp4 -aspect 16:9 output.mp4
#常见的宽高比:16:94:316:105:4
以上代码不是官方给的,后续再测试

剪辑和裁剪视频

ffmpeg -i a.mov -ss 00:00:21 -t 00:00:10 -acodec aac -vcodec h264 -strict -2 out.mp4
#其中 -ss 00:00:21 表示开始剪辑的位置(时间点),-t 00:00:10 表示剪辑的长度,即 10 秒钟

ffmpeg -i a.mov -strict -2 -vf crop=1080:1080:0:420 out.mp4
#将竖向的视频 1080 x 1920,保留中间 1080×1080 部分,其中的 crop=1080:1080:0:420 才裁剪参数,
#具体含义是 crop=width:height:x:y,其中 width 和 height 表示裁剪后的尺寸,x:y 表示裁剪区域的左上角坐标。
#比如当前这个示例,我们只需要保留竖向视频的中间部分,所以 x 不用偏移,故传入0,而 y 则需要向下偏移:(19201080) / 2 = 420

文件合并

#文件最好转换成一样的格式,推荐无损的ts再进行合并。实际上IDM有此功能
ffmpeg -i 1.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb 1.ts
ffmpeg -i 2.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb 2.ts
ffmpeg -i "concat:1.ts|2.ts" -acodec copy -vcodec copy -absf aac_adtstoasc output.mp4

点评一下

性能实测

D:\ffmpeg\bin>ffmpeg.exe -i shikey.com-无心法师3-E01.ts shikey.com-无心法师3-E01.MP4
ffmpeg version git-2020-03-12-675bb1f Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 42.100 / 56. 42.100
  libavcodec     58. 75.100 / 58. 75.100
  libavformat    58. 41.100 / 58. 41.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 77.100 /  7. 77.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mpegts, from 'shikey.com-无心法师3-E01.ts':
  Duration: 00:39:26.39, start: 1.400000, bitrate: 1228 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1080x608, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 68 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0000025239930780] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0000025239930780] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0000025239930780] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=9 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'shikey.com-无心法师3-E01.MP4':
  Metadata:
    encoder         : Lavf58.41.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1080x608, q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.75.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.75.100 aac
frame=59159 fps=179 q=-1.0 Lsize=  359280kB time=00:39:26.41 bitrate=1243.7kbits/s dup=3 drop=0 speed=7.15x
video:320241kB audio:37021kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.565001%
[libx264 @ 0000025239930780] frame I:448   Avg QP:18.45  size: 49589
[libx264 @ 0000025239930780] frame P:23807 Avg QP:22.19  size:  9654
[libx264 @ 0000025239930780] frame B:34904 Avg QP:25.30  size:  2174
[libx264 @ 0000025239930780] consecutive B-frames:  7.1% 38.5% 12.1% 42.2%
[libx264 @ 0000025239930780] mb I  I16..4: 13.1% 57.4% 29.5%
[libx264 @ 0000025239930780] mb P  I16..4:  4.0% 11.1%  0.9%  P16..4: 34.0% 10.1%  4.4%  0.0%  0.0%    skip:35.5%
[libx264 @ 0000025239930780] mb B  I16..4:  0.5%  1.2%  0.1%  B16..8: 22.8%  2.9%  0.4%  direct: 1.2%  skip:70.8%  L0:42.4% L1:51.6% BI: 6.0%
[libx264 @ 0000025239930780] 8x8 transform intra:67.7% inter:74.2%
[libx264 @ 0000025239930780] coded y,uvDC,uvAC intra: 42.4% 58.5% 17.6% inter: 7.5% 10.6% 0.6%
[libx264 @ 0000025239930780] i16 v,h,dc,p: 34% 27% 12% 27%
[libx264 @ 0000025239930780] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 20% 21%  4%  5%  6%  5%  5%  4%
[libx264 @ 0000025239930780] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 20% 12%  6%  8%  8%  7%  6%  5%
[libx264 @ 0000025239930780] i8c dc,h,v,p: 50% 20% 23%  7%
[libx264 @ 0000025239930780] Weighted P-Frames: Y:1.9% UV:1.2%
[libx264 @ 0000025239930780] ref P L0: 68.5% 10.8% 17.1%  3.6%  0.0%
[libx264 @ 0000025239930780] ref B L0: 88.9%  9.5%  1.6%
[libx264 @ 0000025239930780] ref B L1: 98.6%  1.4%
[libx264 @ 0000025239930780] kb/s:1108.63
[aac @ 000002523992ce40] Qavg: 438.340

《FFmpeg一款开源的视频压缩工具最新版(带简单教程附干货)》

基本上可以把CPU跑满,文件轻便小巧。

ffmpeg在处理文件的速度确实也相对比较快,功能非常强大,开发及使用文档非常全面,但是还是看不懂。

对于相对专业的人员、开发者、重度强迫症、极度洁癖、视频站长等非常合适,毕竟转换文件写几个命令就可以很轻松的跑起来,不过前期要求多学习、需要多看文档,但是对于我这样的人还是不合适的。

最后附上我以前写的一篇文章,这个就相对简单很多,并且偶尔用用的话也够了

高清视频无损压缩教程https://shikey.com/2019/11/21/hd-non-destructive-video-compression-tutorial.html

官方的使用文档,强烈建议想学的看看

云盘下载

FFmpeg从入门到精通()

云盘下载

发表回复