FFMPEG命令行,FFMPEG参数使用详解
前言致敬师哥雷神,但师哥的FFMPEG参数的这篇文章,里面一些参数在FFMPEG的最新版已经都去掉了
文章链接https://blog.csdn.net/leixiaohua1020/article/details/12751349
同为广院的工科研究生,我写了这篇文章进行补充,针对于FFMEPG 4.2.1 以上版本
FFMPEG的命令行格式
在FFMPEG的官网http://ffmpeg.org/ffmpeg.html给出的命令行格式是这样的
————————————————
版权声明:本文为CSDN博主「Bug 挖掘机」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011035397/article/details/108952604
ffmpeg { -i input_url} ... { output_url} ...
ffmpeg [全局指令,可选] {[对输入媒体文件的操作,可选] -i 输入文件的路径} ...{[对输出文件的操作,可选] 输出文件的路径}
实例1 转码
将input.avi转码成output.ts,并设置视频的码率为64 kbps(64 kbit/s)
#实例1
ffmpeg -i input.avi -b:v 64k -bufsize 64k output.ts
ffmpeg -y -i input.avi -b:v 64k -bufsize 64k output.ts
ffmpeg -n -i input.avi -b:v 64k -bufsize 64k output.ts
#扩展1
可以同时编码为多种格式,并定义从输入流到输出流的映射:
在 64 kbits 时将 a.wav 转换为 a.mp2,在 128 kbits 时转换为 b.mp2。"-map: 索引"指定每个输出流使用哪个输入流,按输出流定义的顺序排列。
ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
参数详解
实例2 改变视频帧率强制修改输入文件的帧率为1 fps(仅对原始格式数据有效,如m2v视频数据,yuv原始视频文件,jpeg图片等格式),并把输出文件帧率调整到24fps
#实例2
ffmpeg -r 1 -i input.m2v -r 24 output.avi
#ffmpeg {对输入文件的操作} {对输出文件的操作}
ffmpeg -s 1920x1080 -pix_fmt yuv422p -i src01_1920x1080_422.yuv -s 1280x720 -pix_fmt yuv420p src01_1280x720.yuv
ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
参数详解
实例3
示例3-1:
截取一张352x240尺寸大小的,格式为jpg的图片:
ffmpeg -i test.asf -y -f image2 -t 0.001 -s 352x240 a.jpg
示例3-2:
把视频的前30帧转换成一个Animated Gif :
ffmpeg -i test.asf -vframes 30 -y -f gif a.gif
示例3-3:
在视频的第8.01秒处截取 352*240 的缩略图
ffmpeg -i test2.asf -y -f image2 -ss 08.010 -t 0.001 -s 352x240 b.jpg
FFMPEG参数大全
查询指令
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 loglevelset 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_threadsnumber of threads for -filter_complex
-stats print progress report during encoding
-max_error_rate maximum error rateratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-bits_per_raw_sample numberset 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
例子ffmpeg -sseof -10 -i input.mp4 output.mp4 #-10是指负值,负10秒
该获得一段不知道长度的视频的最后10秒,
请注意,在stream copy模式下(通过使用-c copy或等效模式),剪切将出现在最近的关键帧上,因此它可能会缩短您确切的所需时间.如果需要更高的准确性,则必须重新编码而不是流复制.
-seek_timestamp enable/disable seeking by timestamp with -ss
-timestamp time set the recording timestamp ('now' to set the current time)
-metadata string=stringadd 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_graphset stream filtergraph
-filter_script filenameread 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 numberset the number of bits per raw sample
-vn disable video
-vcodec codec force video codec ('copy' to copy stream)
-timecode hh:mm:ss[:;.]ffset 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
高级选项
-map
更多参数请查看
FFMPEG官方文档(英文)
http://ffmpeg.org/ffmpeg.html
FFMPEG官方文档(中文)
https://www.jianshu.com/p/da47b00c42ce
参考链接
https://blog.csdn.net/hemingwang0902/article/details/4382205
https://blog.csdn.net/xiaomucgwlmx/article/details/82852987
https://blog.csdn.net/leixiaohua1020/article/details/12751349
https://www.jianshu.com/p/049d03705a81
https://www.jianshu.com/p/124aee284a61
————————————————
版权声明:本文为CSDN博主「Bug 挖掘机」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011035397/article/details/108952604
页:
[1]