FFmpeg 使用

ffmpeg来处理多种媒体文件,对帧进行操作的时候非常的复杂,下面介绍下使用FFmpeg对视频文件的操作。

1,安装

windows安装ffmpeg:

下载ffmpeg文件解压文件到c盘
配置环境变量C:\ffmpeg\bin

2、修改python文件subprocess.py
shell=False 改为true

pip install ffmpeg-python

centos安装ffmpeg

sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
sudo yum install ffmpeg ffmpeg-devel -y
pip3 install ffmpeg-python

应用

#读取视频信息
    info = ffmpeg.probe("./test.mp4")
    #截图操作
    times = [1,10]
    for time in times:
        input_file = './test.mp4'
        output_file = './image-' + str(time) + '.jpg'
        out, err = (
            ffmpeg
                .input(input_file, ss=time)
                .output(output_file, vframes='1', f='image2')
                .run(quiet=False, overwrite_output=True)
        )
        if out == b'':
            print('do nothing')
        # 视频转换
        os.system('ffmpeg -i a.mp4 -ss 5 -t 10 b.avi ')
        # 视频截取转换gif
        os.system('ffmpeg -ss 00:00:10 -t 3  -i test.mp4 test.gif')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值