https://ffmpeg.xianwaizhiyin.net

我是这么用FFmpeg的:
查看文件信息
1 | ffmpeg -i "/Volumes/Disk/movie.mp4" |
1080P的批量压缩
1 | for i in /Volumes/Disk/*.*; do ffmpeg -hwaccel videotoolbox -i "$i" -c:v h264_videotoolbox -b:v 3M -c:a copy "${i%.*}-HL.MP4"; done |
批量把/Volumes/Disk/目录下的所有视频文件用GPU压缩成码率是3M的MP4文件
4K的批量压缩
1 | for i in /Volumes/Disk/*.*; do ffmpeg -hwaccel videotoolbox -i "$i" -c:v h264_videotoolbox -b:v 12M -c:a copy "${i%.*}-HL.MP4"; done |
1920X1080的码率在3M左右,按这个尺寸,3840X2160的码率应该是3M的4倍,就是12M左右
视频合并
批量合并视频 ffmpeg 需要知道被合并视频的位置和顺序。
因此我们建立一个 file.txt 文件来告诉它。文件内部格式如下:
1 | file 'path/to/file001.ts' |
1 | ffmpeg -f concat -safe 0 -i file.txt -c copy output.mp4 |
MacOS的FFmpeg的安装
1 | brew install ffmpeg --HEAD --with-fdk-aac --with-sdl2 --with-freetype --with-libass --with-libbluray --with-libvorbis --with-libvpx --with-opus --with-webp --with-x265 -location |


