常见FFmpeg命令行全面分析

本文详细介绍了FFmpeg的命令行工具,包括ffmpeg、ffprobe和ffplay的使用。重点讲解了音频和视频的常见操作,如音频转码、剪切、拼接、混音等,以及视频剪切、转码、截图、添加水印等功能。此外,还展示了如何利用FFmpeg实现音频特效、视频降噪、3D VR视频转换等高级操作。适合对音视频处理感兴趣的开发者参考学习。

FFmpeg多媒体库支持的命令行调用分为三个模块:ffmpeg、ffprobe、ffplay。其中ffmpeg命令行常用于音视频剪切、转码、滤镜、拼接、混音、截图等;ffprobe用于检测多媒体流格式;ffplay用于播放视频。详情可查阅FFmpeg官方文档:ffmpeg Documentation

目录

一、ffmpeg命令行

1、命令行参数介绍

2、音频常见操作

2.1 音频转码

2.2 音频剪切

2.3 音频拼接

2.4 音频混音

2.5 空灵音效

2.6 惊悚音效

2.7 搞笑音效

2.8 静音检测

2.9 修改音量

2.10 抽取音频

2.11 音乐频谱波形图

3、视频常见操作

3.1 视频剪切

3.2 视频转码

3.3 视频截图

3.4 图片水印

3.5 GIF水印

3.6 去除水印

3.7 视频拼接

3.8 视频翻转

3.9 视频降噪

3.10 视频抽帧

3.11 播放速度

3.12 插入封面

3.13 旋转视频

3.14 黑白视频

3.15 转换3D的VR视频

二、ffplay命令行

三、ffprobe命令行


一、ffmpeg命令行

1、命令行参数介绍

Print help / information / capabilities:
--help topic        show help
-version            show version
-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
-sample_fmts        show available audio sample formats
-hwaccels           show available HW acceleration methods

Global options (affect whole program instead of just one file:
-v loglevel         set logging level
-y                  overwrite output files
-n                  never overwrite output files
-filter_threads     number of non-complex filter threads
-stats              print progress report during encoding
-vol volume         change audio volume (256=normal)

Per-file main options:
-f fmt              force format
-c codec            codec name
-codec codec        codec name
-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
-frames number      set the number of frames to output
-filter filter_graph  set stream filtergraph
-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.
-vf filter_graph    set video filters
-ab bitrate         audio bitrate (please use -b:a)
-b bitrate          video bitrate (please use -b:v)

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
-sn                 disable subtitle
-scodec codec       force subtitle codec ('copy' to copy stream)

命令行整体格式:以ffmpeg开头,参数之间用空格隔开,每个参数key以"-"开头,后面跟着参数value,输出文件放在命令行最后。

2、音频常见操作

2.1 音频转码

直接转码:

ffmpeg -i input.mp3 output.m4a

指定编码器、采样率、声道数转码:

ffmpeg -i input.mp3 -acodec aac -ac 2 -ar 44100 output.m4a

2.2 音频剪切

-ss 10指定从第10秒开始,-t 20代表剪切20秒

ffmpeg -i input.mp3 -ss 10 -t 20 c
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐福记456

您的鼓励和肯定是我创作动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值