Cyan Hall C H
Created by CyanHall.com. Last updated: 12/03/2020 👉   FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video.

1. Frequent Options

    -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. Common filters

    * scale
* overlay
* crop
* trim
* rotate
  

3. Conver flv video to mp4

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

4. Change bitrate, frame rate, resolution

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

5. Cut video

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

6. Add logo image

    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
  

7. Delay video/audio stream

    # 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"
  

8. Use gl-transitions in ffmpeg (Mac OS)

    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
  

9. Get video duration

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