从 MP4 中提取 M4A
ffmpeg -i input.mp4 -vn -c:a copy output.m4a
无损切割音频
ss
: 起始秒t
: 持续秒数
ffmpeg -ss 5990 -i in.aac -t 181 -c copy out.m4a
输出 YUV4MPEG2
ffmpeg -y -i input.mp4 -pix_fmt yuv420p output.y4m
视频转图片序列
ffmpeg -i input.mp4 -vf fps=30/1.001 %0d.jpg # 29.97fps 的视频,每帧都取
ffmpeg -i input.mp4 -vf fps=1/60 %0d.png # 每 60 帧抽取一幅图片
Opus 转 CAF 封装
ffmpeg -i input.opus -c:a copy output.caf
局域网直播本地视频设备
Server
ffmpeg -re -f 捕获驱动 -video_size 640x480 -r 30 -i 设备 -acodec none -b:v 1M -fflags nobuffer -f mpegts udp://239.255.1.2:1234
^分辨率 ^帧率 ^无音频 ^视频码率 ^视频编码
macOS 可能需要去掉
-re
选项
可以加入
-vcodec libx264 -tune zerolatency
提高低码率高分辨率下的画质,但也会增加延迟
捕获驱动根据系统有所不同:
- macOS/iOS/iPadOS:
avfoundation
- Linux:
video4linux2
- Windows:
dshow
视频设备可以用以下命令查看:
- macOS/iOS/iPadOS:
ffmpeg -f avfoundation -list_devices true -i ""
- Linux:
ls -l /dev | grep video
- Windows:
ffmpeg -f dshow -list_devices true-i dummy
Client
ffplay -fflags nobuffer -flags low_delay -sync ext udp://239.255.1.2:1234