FFmpeg指令(./ffmpeg -h long)
1 指令选项
本文使用指令:ffmpeg -h long
Hyper fast Audio and Video encoder
用法: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
1.1 获得帮助:
-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/protocolSee man ffmpeg for detailed description of the options.
1.2 打印帮助/信息/功能:
-L show license显示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显示可用的文件格式,封装(Muxer)、解封装(Demuxer)
-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
-dispositions show available stream dispositions
-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
1.3 全局选项:
影响整个程序而不仅仅是一个文件
-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 decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-vol volume change audio volume (256=normal)
1.4 高级全局选项:
-cpuflags flags force specific cpu flags
-cpucount count force specific cpu count
-hide_banner hide_banner do not show program banner
-copy_unknown Copy unknown stream types
-recast_media allow recasting stream type in order to force a decoder of different media type
-benchmark add timings for benchmarking
-benchmark_all add timings for each task
-progress url write program-readable progress information
-stdin enable or disable interaction on standard input
-timelimit limit set max runtime in seconds in CPU user time
-dump dump each input packet
-hex when dumping packets, also dump the payload
-vsync video sync method
-frame_drop_threshold frame drop threshold
-async audio sync method
-adrift_threshold threshold audio drift threshold
-copyts copy timestamps
-start_at_zero shift input timestamps to start at 0 when using copyts
-copytb mode copy input stream time base when stream copying
-dts_delta_threshold threshold timestamp discontinuity delta threshold
-dts_error_threshold threshold timestamp error delta threshold
-xerror error exit on error
-abort_on flags abort on the specified condition flags
-filter_complex graph_description create a complex filtergraph
-lavfi graph_description create a complex filtergraph
-filter_complex_script filename read complex filtergraph description from a file
-auto_conversion_filters enable automatic conversion filters globally
-stats_period time set the period at which ffmpeg updates stats and -progress output
-debug_ts print timestamp debugging info
-psnr calculate PSNR of compressed frames
-vstats dump video coding statistics to file
-vstats_file file dump video coding statistics to file
-vstats_version Version of the vstats format to use.
-qphist show QP histogram
-sdp_file file specify a file in which to print sdp information
-init_hw_device args initialise hardware device
-filter_hw_device device set hardware device used when filtering
1.5 Per-file main options:
-f fmt 强制格式
-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 音视频持续播放时间
-to time_stop 设置截取停止时间
-fs limit_size set the limit file size in bytes
-ss time_off 设置截取开始时间
-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
1.6 Advanced per-file options:
-map [-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]] set input stream mapping
-map_channel file.stream.channel[:syncfile.syncstream] map an audio channel from one stream to another
-map_chapters input_file_index set chapters mapping
-accurate_seek enable/disable accurate seeking with -ss
-itsoffset time_off set the input ts offset
-itsscale scale set the input ts scale
-dframes number set the number of data frames to output
-re read input at native frame rate; equivalent to -readrate 1
-readrate speed read input at specified rate
-shortest finish encoding within shortest input
-bitexact bitexact mode
-copyinkf copy initial non-keyframes
-copypriorss copy or discard frames before start time
-tag fourcc/tag force codec tag/fourcc
-q q use fixed quality scale (VBR)
-qscale q use fixed quality scale (VBR)
-profile profile set profile
-attach filename add an attachment to the output file
-dump_attachment filename extract an attachment into a file
-stream_loop loop count set number of times input stream shall be looped
-thread_queue_size set the maximum number of queued packets from the demuxer
-find_stream_info read and decode the streams to fill missing information with heuristics
-bits_per_raw_sample number set the number of bits per raw sample
-autorotate automatically insert correct rotate filters
-autoscale automatically insert a scale filter at the end of the filter graph
-muxdelay seconds set the maximum demux-decode delay
-muxpreload seconds set the initial demux-decode delay
-time_base ratio set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)
-enc_time_base ratio set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). two special values are defined - 0 = use frame rate (video) or sample rate (audio),-1 = match source time base
-bsf bitstream_filters A comma-separated list of bitstream filters
-fpre filename set options from indicated preset file
-max_muxing_queue_size packets maximum number of packets that can be buffered while waiting for all streams to initialize
-muxing_queue_data_threshold bytes set the threshold after which max_muxing_queue_size is taken into account
-dcodec codec force data codec ('copy' to copy stream)
1.7 Video options:
-vframes number set the number of video frames to output
-r rate set frame rate (Hz value, fraction or abbreviation)
-fpsmax rate set max 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)
-vn 禁用视频
-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
1.8 Advanced Video options:
-pix_fmt format set pixel format
-rc_override override rate control override for specific intervals
-passlogfile prefix select two pass log file name prefix
-psnr calculate PSNR of compressed frames
-vstats dump video coding statistics to file
-vstats_file file dump video coding statistics to file
-vstats_version Version of the vstats format to use.
-intra_matrix matrix specify intra matrix coeffs
-inter_matrix matrix specify inter matrix coeffs
-chroma_intra_matrix matrix specify intra matrix coeffs
-top top=1/bottom=0/auto=-1 field first
-vtag fourcc/tag force video tag/fourcc
-qphist show QP histogram
-force_fps force the selected framerate, disable the best supported framerate selection
-streamid streamIndex:value set the value of an outfile streamid
-force_key_frames timestamps force key frames at specified timestamps
-hwaccel hwaccel name use HW accelerated decoding
-hwaccel_device devicename select a device for HW acceleration
-hwaccel_output_format format select output format used with HW accelerated decoding
-vbsf video bitstream_filters deprecated
-vpre preset set the video options to the indicated preset
1.9 音频选项:
-aframes number set the number of audio frames to output
-aq quality set audio quality (codec-specific)
-ar rate 设置音频采样率(Hz)
-ac channels 设置音频通道数
-an 禁用音频
-acodec codec force audio codec ('copy' to copy stream)
-vol volume change audio volume (256=normal)
-af filter_graph set audio filters
1.10 Advanced Audio options:
-atag fourcc/tag force audio tag/fourcc
-sample_fmt format 设置sample格式
-channel_layout layout set channel layout
-guess_layout_max set the maximum number of channels to try to guess the channel layout
-absf audio bitstream_filters deprecated
-apre preset set the audio options to the indicated preset
1.11 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
2 常用命令
2.1 截取音视频片段
ffmpeg -i avfile.mp4 -ss 00:00:00 -t 00:01:00 avfile_out.mp4
实验结果:视频效果变差ffmpeg -i afile.mp4 -ss 00:01:03 -t 00:00:39 -y afile_out.mp4
ffmpeg -i afile.mp4 -ss 00:01:03 -to 00:01:42 -y afile_out.mp4-ss:设置截取开始时间
-t: 音视频持续播放时间
2.2 从视频提取音频
ffmpeg -i avfile.mp4 -vn afile.mp3
3.3 提取PCM
ffmpeg -i test.mp3 -ar 48000 -ac 2 -f s16le 48000_2_s16le.pcm
ffmpeg -i test.mp3 -ar 48000 -ac 2 -sample_fmt s16 out_s16.wav
ffmpeg -i test.mp3 -ar 48000 -ac -codec:a pcm_s16le out2_s16le.wav
ffmpeg -i test.mp3 -ar 48000 -ac 2 -f f32le 48000_2_f32le.pcm
ffmpeg -i test.mp4 -t 10 -vn -ar 48000 -ac 2 -f f32le 48000_2_f32le_2.pcmmp4转pcm
ffmpeg -i afile.mp4 -ar 44100 -ac 2 -f s16le 44100_2_s16le.pcm -y
ffmpeg -i afile.mp4 -ar 44100 -ac 2 -f s16be 44100_2_s16be.pcm -y
3.4 查看封装器的参数支持
使用命令:./ffmpeg.exe -h muxer=wav
$ ./ffmpeg.exe -h muxer=wav
........................................
Muxer wav [WAV / WAVE (Waveform Audio)]:Common extensions: wav.Mime type: audio/x-wav.Default audio codec: pcm_s16le.
WAV muxer AVOptions:-write_bext <boolean> E.......... Write BEXT chunk. (default false)-write_peak <int> E.......... Write Peak Envelope chunk. (from 0 to 2) (default off)off 0 E.......... Do not write peak chunk.on 1 E.......... Append peak chunk after wav data.only 2 E.......... Write only peak chunk, omit wav data.-rf64 <int> E.......... Use RF64 header rather than RIFF for large files. (from -1 to 1) (default never)auto -1 E.......... Write RF64 header if file grows large enough.always 1 E.......... Always write RF64 header regardless of file size.never 0 E.......... Never write RF64 header regardless of file size.-peak_block_size <int> E.......... Number of audio samples used to generate each peak frame. (from 0 to 65536) (default 256)-peak_format <int> E.......... The format of the peak envelope data (1: uint8, 2: uint16). (from 1 to 2) (default 2)-peak_ppv <int> E.......... Number of peak points per peak value (1 or 2). (from 1 to 2) (default 2)
3.5 查看解封装器的参数支持
使用命令:./ffmpeg.exe -h demuxer=wav
$ ./ffmpeg.exe -h demuxer=wav
..........................................
Demuxer wav [WAV / WAVE (Waveform Audio)]:
WAV demuxer AVOptions:-ignore_length <boolean> .D......... Ignore length (default false)-max_size <int> .D......... max size of single packet (from 1024 to 4.1943e+06) (default 4096)
3.6 查看编码器的参数支持
使用命令:./ffmpeg.exe -h encoder=aac
$ ./ffmpeg.exe -h encoder=aac
..........................................
Encoder aac [AAC (Advanced Audio Coding)]:General capabilities: delay smallThreading capabilities: noneSupported sample rates: 96000 88200 64000 48000 44100 32000 24000 22050 16000 12000 11025 8000 7350Supported sample formats: fltp
AAC encoder AVOptions:-aac_coder <int> E...A...... Coding algorithm (from 0 to 2) (default fast)anmr 0 E...A...... ANMR methodtwoloop 1 E...A...... Two loop searching methodfast 2 E...A...... Default fast search-aac_ms <boolean> E...A...... Force M/S stereo coding (default auto)-aac_is <boolean> E...A...... Intensity stereo coding (default true)-aac_pns <boolean> E...A...... Perceptual noise substitution (default true)-aac_tns <boolean> E...A...... Temporal noise shaping (default true)-aac_ltp <boolean> E...A...... Long term prediction (default false)-aac_pred <boolean> E...A...... AAC-Main prediction (default false)-aac_pce <boolean> E...A...... Forces the use of PCEs (default false)
3.7 查看解码器的参数支持
使用命令:./ffmpeg.exe -h decoder=aac
$ ./ffmpeg.exe -h decoder=aac
..........................................
Decoder aac [AAC (Advanced Audio Coding)]:General capabilities: dr1 chconfThreading capabilities: noneSupported sample formats: fltpSupported channel layouts: mono stereo 3.0 4.0 5.0 5.1 7.1(wide)
AAC decoder AVOptions:-dual_mono_mode <int> .D..A...... Select the channel to decode for dual mono (from -1 to 2) (default auto)auto -1 .D..A...... autoselectionmain 1 .D..A...... Select Main/Left channelsub 2 .D..A...... Select Sub/Right channelboth 0 .D..A...... Select both channels
3.7 查看滤镜的参数支持
使用命令:./ffmpeg.exe -h filter=colorkey
$ ./ffmpeg.exe -h filter=colorkey
.................................
Filter colorkeyTurns a certain color into transparency. Operates on RGB colors.slice threading supportedInputs:#0: default (video)Outputs:#0: default (video)
colorkey AVOptions:color <color> ..FV.....T. set the colorkey key color (default "black")similarity <float> ..FV.....T. set the colorkey similarity value (from 0.01 to 1) (default 0.01)blend <float> ..FV.....T. set the colorkey key blend value (from 0 to 1) (default 0)This filter has support for timeline through the 'enable' option.
2.X 杂项
open_output_file --> new_audio_stream --> new_output_stream --> choose_encoder --> avcodec_find_encoder
./configure --list-decoders
大段数据格式
ffmpeg -i test.mp3 -f s16be -ar 16000 -ac 1 -acodec pcm_s16be pcm16k.pcm
小端数据格式
ffmpeg -i test.mp3 -f s16le -ar 16000 -ac 1 -acodec pcm_s16le pcm16k.pcm
说明:
-acodec pcm_s16be:输出pcm格式,采用signed 16编码,字节序为大尾端(小尾端为le);
-ar 16000: 采样率为16000
-ac 1: 声道数为1
1.pcm转mp3
ffmpeg -f s16le -ar 48000 -ac 1 -i test.pcm -ar 8000 -y test_8k.mp3
2.pcm重采样
ffmpeg -f s16le -ar 48000 -ac 1 -i test.pcm -f s16le -ar 8000 -y test_8k.pcm
4、WAV转PCM
ffmpeg -i afile.wav -ac 2 -f s16le -ar 44100 -y afile_2ac_16b_44k1.pcm
ffmpeg -i afile.wav -f s16be -ar 44100 -ac 2 -y afile_2ac_16b_44k1.pcm
.pcm转mp3
ffmpeg -f s16le -ar 48000 -ac 1 -i test.pcm -ar 8000 -y test_8k.mp3
2.pcm重采样
ffmpeg -f s16le -ar 48000 -ac 1 -i test.pcm -f s16le -ar 8000 -y test_8k.pcm
3.mp3转pcm
ffmpeg -i test.mp3 -f s16le -y test_8k.pcm
X 参考文献
FFmpeg音频提取并截取片段
https://blog.csdn.net/u012725623/article/details/104008912
https://blog.csdn.net/vc66vcc/article/details/82145577
https://blog.csdn.net/zhuxian2009/article/details/105287681
FFmpeg指令(./ffmpeg -h long)相关推荐
- ffmpeg遇到inttypes.h和UINT64_C
ffmpeg遇到inttypes.h和UINT64_C 转载 2014年01月20日 17:26:33 3452 编译过程: 错误一:无法打开包括文件:"inttypes.h": ...
- 【Android FFMPEG 开发】Android 中执行 FFMPEG 指令 ( 集成 FFmpegAndroid 框架 )
文章目录 一.推荐开源项目 二.Android 中执行 FFMPEG 指令 1.导入依赖 2.Java 代码编写 3.使用时的代码示例 三.博客资源 一.推荐开源项目 最近需要在 Android 中进 ...
- 使用ffmpeg指令转换出yuv视频文件
播放器播放的都是经过解码后的视频,也就是yuv格式的视频文件,因此在学习的过程中需要准备一下yuv格式的视频做实验素材,这里演示如何在电脑中使用ffmpeg指令将一个视频文件转换为.yuv格式. 1. ...
- 【FFmpeg】FFmpeg常用基本命令
1.分离视频音频流 ffmpeg -i input_file -vcodec copy -an output_file_video //分离视频流 ffmpeg -i input_file -acod ...
- 【FFmpeg】ffmpeg 命令查询二 ( 比特流过滤器 | 可用协议 | 过滤器 | 像素格式 | 标准声道布局 | 音频采样格式 | 颜色名称 )
FFmpeg 系列文章目录 [FFmpeg]Windows 搭建 FFmpeg 命令行运行环境 [FFmpeg]FFmpeg 相关术语简介 ( 容器 | 媒体流 | 数据帧 | 数据包 | 编解码器 ...
- 【FFmpeg】FFmpeg 帮助文档使用
FFmpeg 系列文章目录 [FFmpeg]Windows 搭建 FFmpeg 命令行运行环境 [FFmpeg]FFmpeg 相关术语简介 [FFmpeg]FFmpeg 相关术语简介 二 文章目录 F ...
- 【FFmpeg】FFmpeg 相关术语简介 ( 容器 | 媒体流 | 数据帧 | 数据包 | 编解码器 | 复用 | 解复用 )
文章目录 一.FFmpeg 简介 二.FFmpeg 相关术语 1.容器 2.媒体流 3.数据帧 4.数据包 5.编解码器 6.复用 7.解复用 博客资源 一.FFmpeg 简介 FFmpeg 是 &q ...
- 【FFmpeg】FFmpeg常用基本命令(转载)
转自:http://www.cnblogs.com/dwdxdy/p/3240167.html 1.分离视频音频流 ffmpeg -i input_file -vcodec copy -an outp ...
- 【初学ffmpeg】ffmpeg获取视频信息
===================================================== 相关代码可以参考我的: [初学ffmpeg]ffmpeg解码保存为yuv ========= ...
- 六、FFmpeg使用---ffmpeg依赖x264库
上篇文章五.FFmpeg使用---x264编译_[零声教育]音视频开发进阶的博客-CSDN博客粗略的讲了一下如何编译X264,和之前FFmpeg的编译方式差不多,就是脚本有点差异. 接下来讲一 ...
最新文章
- 245热图展示微生物组的物种和功能丰度或有无、距离矩阵
- python学习干货教程(10):列表
- MATLAB与C#混合编程
- iOS10 UI教程视图和子视图的可见性
- JVM对象分配回收算法
- 并发队列-无界阻塞优先级队列
- 多元线性回归matlab代码例题_多元线性回归matlab程序
- m3u8在线播放工具 以及 开源播放方案
- ycl-django网站搭建(持续更新中)
- 智慧社区安防核心硬件:无障碍人脸识别终端
- Python3.6:根据m3u8下载mp4视频
- groupByKey与reduceByKey区别
- Day3--搭建微信公众号管理系统
- Ansj中文分词说明
- 遥感图像彩色合成|以Landsat8数据为例
- 关于订单支付成功后一些逻辑的处理
- Redmi11T Pro +值不值得买 Redmi11T Pro +配置如何
- html语言全拼,html标签全拼意思是什么
- 「Arm Arch」 微架构
- idea如何更改编辑器字体大小和框字体大小
热门文章
- 5种方案实现订单30分钟未支付,则自动取消
- 【手把手带你搞定】第一个C语言猜数字游戏(超详细教程,不仅学如何写代码,更学方法思路!)
- 魔兽世界3.35+mysql_新魔兽世界3.35兔子王版本商业 一键启动服务端
- 互联网金融指导意见落地 行业发展开始步入正轨
- 置信传播算法(Belief Propagation)简介
- 美团大众点评合并:背后技术力量的对比回顾【转载+整理】
- 计算机平面设计主要学什么 - 兔课网,兔课网:初学平面要怎么样构图?
- 无线wifi盒子用不用拉网线?
- adb shell dumpsys activity activities调用信息分析
- DGZX1564 - 水塔水位