自用简单操作备份
码率, 分辨率
b:v
视频码率;b:a
音频码率-vf scale=640:360
分辨率
ffmpeg -i input.mp4 -b:v 1M -b:a 192k output.avi
剪切(不重新压缩)
-c:v copy -c:a copy
帧率
-filter:v fps=30
剪辑视频
ffmpeg -f image2 -i /path/to/file/image%3d.jpg test.avi
If your files are named image0.jpg
, image1.jpg
, image2.jpg
, etc. then you'd use /path/to/file/image%d.jpg
.
剪切
ffmpeg -i in.mov -ss 200 -to 400 (200秒到400秒)
ffmpeg -i in.mov -ss 00:01:30 -to 00:02:12 (时间切割)
旋转
ffmpeg -i in.mov -vf "transpose=1" out.mov
- 0 = 90CounterCLockwise and Vertical Flip (default)
- 1 = 90Clockwise
- 2 = 90CounterClockwise
- 3 = 90Clockwise and Vertical Flip
- Use
-vf "transpose=2,transpose=2"
for 180 degrees.
倒放
-vf reverse -y reverse.mp4
补帧
ffmpeg \
-i input.mp4 \
-crf 10 -vf "minterpolate=fps=60:mi_mode=mci:mc_mode=aobmc:me_mode=bidir:vsbmc=1"
录制竖屏视频, 旋转:
# 2 = 90CounterClockwise
ffmpeg -i <src.mp4> -ss 00:00:02 -to 00:01:51 -vf "transpose=2" <out.mp4>
按8fps导出图片到out00001.png
:
ffmpeg -i <out.mp4> -vf fps=8 -start_number 00001 -q:v 1 out%05d.png
把图片转回视频:
ffmpeg -framerate 9 -i out%05d.png -vf "setpts=11/100*PTS" -c:v libx264 -pix_fmt yuv420p output.mp4
dir /b "D:\Andrew\Videos\hand_in_hand_pose\*.png" | ffmpeg -f image2pipe -framerate 1 -i - -ss 0:00 -i orig.mp4 -c:v libx264 -c:a copy -shortest -r 8 -pix_fmt yuv420p raw.mp4
parsing - How can I extract audio from video with ffmpeg? - Stack Overflow
提取mkv音频:
ffmpeg -i input-video.avi -vn -acodec copy output-audio.flac
按时间段批量提取音频 (去掉-c copy
来重新编码):
ffmpeg -i output.mp3 -c copy -f segment -segment_times 0,3472.683,7642.058 -segment_start_number 1 ch%d.flac
导出mkv的时间(chapters)到文本文档:
ffprobe -i "sth.mkv" -show_chapters > extracted_chapters.txt
使用ffmpeg, 视频转音频:
ffmpeg -i pt1.mkv pt1.aac