Created by CyanHall.com
on 11/11/2020
, Last updated: 04/30/2021.
πΒ Β Star me if itβs helpful. FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video.
πΒ Β Star me if itβs helpful. 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`
3. Conver flv video to mp4
ffmpeg -i input.flv -y -codec copy output.mp4
5. Change bitrate, frame rate, resolution
ffmpeg -i input.mp4 -b 4000k -r 30 βs 1280*720 -y output.mp4
7. 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
9. 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"
11. Get video duration
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
2. Common filters
* 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. 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
10. 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
More