Record, convert and stream audio and video with FFmpeg
I'm getting old and I need to write everything. Welcome to my memento for FFmpeg !
Converting video formats to another one, generating thumbnails, merging sounds; everything is there !
Converting video formats to another one, generating thumbnails, merging sounds; everything is there !
FFmpeg is a free and open-source software project consisting of a suite of libraries and programs for handling video, audio, and other multimedia files and streams. It can be downloaded here. Please refer to the official documentation if you need any help to install FFmpeg.
Get file Information from a media file
ffprobe video.avi
Get file Information to JSON file
ffprobe -v quiet -print_format json -show_format -show_streams output.mp4 > output.json
Convert a video to X images
ffmpeg -i video.mpg image-%d.jpg
Extract a sound from a video and convert it as MP3
ffmpeg -i video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output.mp3
Convert AVI to MPEG
ffmpeg -i video.avi output.mpg
Convert AVI to animated GIF
ffmpeg -i video.avi output.gif
Convert AVI to FLV
ffmpeg -i video.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output.flv
Extract 23 seconds of audio from the 8th second
ffmpeg -i audio.mp3 -ss 08 -t 23 output.mp3
Remove the 2nd audio track
ffmpeg -i video.avi -i -map 0:0 -map 0:1 -map 0:3 -codec copy output.avi
Replace an audio track
ffmpeg -i video.avi -i audio.mp3 -codec copy output.avi
Add an audio track
ffmpeg -i video.avi -i audio.mp3 -map 0 -map 1 -codec copy output.avi
Add multiple audio tracks
ffmpeg -i video.avi -i track1.mp3 -i track2.mp3 -i track3.mp3 -map 0 -map 1 -map 2 -map 3 -codec copy output.avi
Specify the language of the 3rd audio track as German
ffmpeg -i video.mov -metadata:s:a:2 language=ger -map 0 -codec copy output.mov
Add an audio track between the 1st and te 2nd
ffmpeg -i video.avi -i audio.mp3 -map 0:1 -map 1 -map 0:2 -codec copy output.avi
Convert a multitrack video to MPEG
ffmpeg -i video.avi -map 0 output.mpeg
Convert a multitrack video and keep the 1st and the 3rd audio tracks
ffmpeg -i video.avi -map 0:0 -map 0:2 output.mpeg
Merge a subtitle ASS file to a video
ffmpeg -i video.mp4 -vf ass=subtitles.ass output.mp4
Append an audio track to another one
ffmpeg -i "concat:son1.mp3|son2.mp3" output.mp3
Extract thumbnails every 5 minutes (300 seconds)
ffmpeg -i video.mp4 -vf fps=fps=1/300 %d.png
Multiply by 2 audio track and the video duration
ffmpeg -i video.mp4 -filter:a 'atempo=0.5' -filter:v 'setpts=2.0*PTS' output.mp4
Overlay an audio track to another one
ffmpeg -i track1.mp3 -i track2.mp3 -filter_complex "amerge,pan=stereo:c0<c0+c2:c1<c1+c3" -c:a libmp3lame -q:a 4 output.mp3
Lower the audio volume to 10%
ffmpeg -i track1.mp3 -af "volume=0.1" output.mp3
Convert a video to M3U8
ffmpeg -i video.mp4 -map 0 -bsf h264_mp4toannexb -c copy -f segment -segment_list output.m3u8 output-%03d.ts