#win
可以直接下载
#linux
apt install ffmpeg -y
pip install ffmpeg-python
ffmpeg.run(stream_spec, cmd="/xxx/xx/ffmpeg", capture_stdout=False, capture_stderr=False, input=None, quiet=False, overwirte_output=False)
https://github.com/kkroening/ffmpeg-python
https://python-ffmpeg.readthedocs.io/en/stable/api/
https://www.jianshu.com/p/38b28bb3df79
#查看支持的 filter
./ffmpeg.exe -filters
#查看详细的参数
./ffmpeg.exe -h filter=fade
实例
获取视频信息(宽高)
probe = ffmpeg.probe(args.in_filename)
video_stream = next((stream for stream in probe['streams'] if stream['codec_type'] == 'video'), None)
width = int(video_stream['width'])
height = int(video_stream['height'])
video = ffmpeg.input('Pencil.mp4', ss=4)
video = video.filter('scale', 500, -1)
video= ffmpeg.output(video,'output.png', vframes=1)
ffmpeg.run(video)
#水平翻转视频
video = ffmpeg.input('Pencil.mp4')
video = ffmpeg.hflip(video)
video = ffmpeg.output(video, 'horizontal.mp4')
ffmpeg.run(video)
#垂直翻转视频
video = ffmpeg.input('Pencil.mp4')
video = ffmpeg.vflip(video)
video = ffmpeg.output(video, 'vertical.mp4')
ffmpeg.run(video)