CyanHall.com 创建于 2020-11-11, 上次更新:2021-04-30。
👉  github shields 如果有用请点赞。
FFmpeg 是一个音视频全方位的处理工具。

1. 常用选项

    -i # specify input file
-y # override output file with same name
-protocol_whitelist file,http,https,tcp,tls # access allowed protocols
-loglevel panic # log filter, panic/error/info
-stats # show stats data

-codec copy # keep origin codec
-vcodec copy # keep origin video codec
-vcodec libx264 # specify video codec
-acodec copy # keep origin audio codec
-acodec libfaac # specify audio codec

-max_muxing_queue_size 1024 # Fix error: `Too many packets buffered for output stream 0:1`
  

2. 通用过滤器

    * scale
* overlay
* crop
* trim
* rotate
  

3. 把 `flv` 转换为 `mp4`

    ffmpeg -i input.flv -y -codec copy output.mp4
  

4. Download m3u8 video

    ffmpeg -i "https://xxx.m3u8" -y -codec copy output.mp4
  

5. 修改比率(bitrate), 帧率(frame rate), 分辨率

    ffmpeg -i input.mp4 -b 4000k -r 30 –s 1280*720 -y output.mp4
  

6. Change audio sample rate

    ffmpeg -i test.mp3 -ar 16000 test.16k.mp3
  

7. 剪切视频

    ffmpeg -ss 00:07:00 -i input.mp4 -to 00:08:00 -c copy output.mp4
# Read more: https://trac.ffmpeg.org/wiki/Seeking
  

8. 加图像水印

    ffmpeg -i input.mp4 -i logo.png -filter_complex overlay output.mp4 # top-left corner
ffmpeg -i input.mp4 -i logo.png -filter_complex overlay=W-w output.mp4 # top-right corner
# overlay=0:H-h # left bottom corner
# overlay=W-w:H-h # right bottom corner
  

9. 延迟音频/视频的播放

    # make video delayed
ffmpeg.exe -i "input.mp4" -itsoffset 1.5 -i "input.mp4" -map 1:v -map 0:a -c copy "make-video-delayed.mp4"

# make audio delayed
ffmpeg -i "input.mp4" -itsoffset 1.5 -i "input.mp4" -map 0:v -map 1:a -c copy "make-audio-delayed.mp4"
  

10. 在 MacOS 安装 gl-transitions

    brew install glew glfw
brew install yasm
git clone http://source.ffmpeg.org/git/ffmpeg.git
git clone [email protected]:gl-transitions/gl-transitions.git
git clone [email protected]:transitive-bullshit/ffmpeg-gl-transition.git
cd ffmpeg
cp ../ffmpeg-gl-transition/vf_gltransition.c libavfilter/
git apply ../ffmpeg-gl-transition/ffmpeg.diff

./configure --enable-libx264 --enable-gpl --enable-opengl             --enable-filter=gltransition --extra-libs='-lGLEW -lglfw'
make

# check gltransition available
./ffmpeg -v 0 -filters | grep gltransition
  

11. Get video duration

    ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
  

1. 常用选项

    -i # specify input file
-y # override output file with same name
-protocol_whitelist file,http,https,tcp,tls # access allowed protocols
-loglevel panic # log filter, panic/error/info
-stats # show stats data

-codec copy # keep origin codec
-vcodec copy # keep origin video codec
-vcodec libx264 # specify video codec
-acodec copy # keep origin audio codec
-acodec libfaac # specify audio codec

-max_muxing_queue_size 1024 # Fix error: `Too many packets buffered for output stream 0:1`
  

3. 把 `flv` 转换为 `mp4`

    ffmpeg -i input.flv -y -codec copy output.mp4
  

5. 修改比率(bitrate), 帧率(frame rate), 分辨率

    ffmpeg -i input.mp4 -b 4000k -r 30 –s 1280*720 -y output.mp4
  

7. 剪切视频

    ffmpeg -ss 00:07:00 -i input.mp4 -to 00:08:00 -c copy output.mp4
# Read more: https://trac.ffmpeg.org/wiki/Seeking
  

9. 延迟音频/视频的播放

    # make video delayed
ffmpeg.exe -i "input.mp4" -itsoffset 1.5 -i "input.mp4" -map 1:v -map 0:a -c copy "make-video-delayed.mp4"

# make audio delayed
ffmpeg -i "input.mp4" -itsoffset 1.5 -i "input.mp4" -map 0:v -map 1:a -c copy "make-audio-delayed.mp4"
  

11. Get video duration

    ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
  

2. 通用过滤器

    * scale
* overlay
* crop
* trim
* rotate
  

4. Download m3u8 video

    ffmpeg -i "https://xxx.m3u8" -y -codec copy output.mp4
  

6. Change audio sample rate

    ffmpeg -i test.mp3 -ar 16000 test.16k.mp3
  

8. 加图像水印

    ffmpeg -i input.mp4 -i logo.png -filter_complex overlay output.mp4 # top-left corner
ffmpeg -i input.mp4 -i logo.png -filter_complex overlay=W-w output.mp4 # top-right corner
# overlay=0:H-h # left bottom corner
# overlay=W-w:H-h # right bottom corner
  

10. 在 MacOS 安装 gl-transitions

    brew install glew glfw
brew install yasm
git clone http://source.ffmpeg.org/git/ffmpeg.git
git clone [email protected]:gl-transitions/gl-transitions.git
git clone [email protected]:transitive-bullshit/ffmpeg-gl-transition.git
cd ffmpeg
cp ../ffmpeg-gl-transition/vf_gltransition.c libavfilter/
git apply ../ffmpeg-gl-transition/ffmpeg.diff

./configure --enable-libx264 --enable-gpl --enable-opengl             --enable-filter=gltransition --extra-libs='-lGLEW -lglfw'
make

# check gltransition available
./ffmpeg -v 0 -filters | grep gltransition
  


Maitained by Cyanhall.com, Copy Rights @ CC BY-NC-SA 4.0     ExcelRoadMap