zoukankan      html  css  js  c++  java
  • FFmpeg的安装使用(mac)

    先安装Homebrew (官方网址:https://brew.sh/)

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    安装FFmpeg

    brew install ffmpeg
    

    ffmpeg常用命令:

    将视频 MP4 转化为 GIF
    ffmpeg -i small.mp4 small.gif
    转化视频中的一部分为 GIF
    ffmpeg -t 3 -ss 00:00:02 -i small.webm small-clip.gif
    从视频中第二秒开始,截取时长为3秒的片段转化为 gif
    
    转化高质量 GIF
    默认转化是中等质量模式,若要转化出高质量的 gif,可以修改比特率
    
    ffmpeg -i small.mp4 -b 2048k small.gif
    视频属性调整
    缩放视频尺寸
    ffmpeg -i big.mov -vf scale=360:-1  small.mov
    注意 sacle 值必须是偶数,这里的 -1 表示保持长宽比,根据宽度值自适应高度。
    
    如果要求压缩出来的视频尺寸长宽都保持为偶数,可以使用 -2
    
    加倍速播放视频
    ffmpeg -i input.mov -filter:v "setpts=0.5*PTS" output.mov
    定义帧率 16fps:
    
    ffmpeg -i input.mov -r 16 -filter:v "setpts=0.125*PTS" -an output.mov
    慢倍速播放视频
    ffmpeg -i input.mov -filter:v "setpts=2.0*PTS" output.mov
    静音视频(移除视频中的音频)
    ffmpeg -i input.mov -an mute-output.mov
    -an 就是禁止音频输出
    
    将 GIF 转化为 MP4
    ffmpeg -f gif -i animation.gif animation.mp4
    也可以将 gif 转为其他视频格式
    
    ffmpeg -f gif -i animation.gif animation.mpeg
    
    ffmpeg -f gif -i animation.gif animation.webm
    获取 GIF 的第一帧图片
    使用 ImageMagick 可以方便第提取 gif 图片的第 N 帧图像。
    
    安装 ImageMagick
    
    brew install imagemagick
    提取第一帧
    
    convert 'animation.gif[0]' animation-first-frame.gif
    通过 [0] 就可以提取出 gif 的第一帧图像。
    
  • 相关阅读:
    Codeforces 451A Game With Sticks
    POJ 3624 Charm Bracelet
    POJ 2127 Greatest Common Increasing Subsequence
    POJ 1458 Common Subsequence
    HDU 1087 Super Jumping! Jumping! Jumping!
    HDU 1698
    HDU 1754
    POJ 1724
    POJ 1201
    CSUOJ 1256
  • 原文地址:https://www.cnblogs.com/smileyqp/p/12675359.html
Copyright © 2011-2022 走看看