Skip to content

tezheng/awesome-ffmpeg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 

Repository files navigation

Awesome FFMPEG

Useful commands for FFMPEG used to convert video and audio files. Feel free to contribute with a PR!

Summary

⚠️ In this document, user vars will be marked with a $. $FILE for your input or output file, $INPUT for your input file, $OUTPUT for your output file, etc

Links

⬆️ Go to top

Installation

Integration

Packages

Video commands

⬆️ Go to top

Convert video for the web

Where $WITH is the desired video width.

VP9 (.webm)

ffmpeg -i $INPUT -vcodec libvpx -acodec libvorbis -ac 2 -b:a 96k -ar 44100 -vf scale=$WIDTH:-1 -map 0 $OUTPUT.webm

H264 (.mp4)

ffmpeg -i $INPUT -vcodec libx264 -acodec libfdk_aac -ac 2 -ar 48000 -b:a 96k -vf scale=$WIDTH:-1 -map 0 $OUTPUT.mp4

Vorbis (.ogv)

ffmpeg -i $INPUT -vcodec libtheora -acodec libvorbis -b:a 96k -vf scale=$WIDTH:-1 -map 0 $OUTPUT.ogv

Video to GIF

ffmpeg -i $INPUT $OUTPUT.gif

Cut a video without re-encoding (fast)

Where $START and $END are the timecodes in format HH:MM:SS.

ffmpeg -i $INPUT -ss $START -to $END -c copy $OUTPUT
# Ex: ffmpeg -i video.mp4 -ss 00:00:00 -to 00:01:30 -c copy cut.mp4

Extract images from a video every X seconds

Where $RATE is desired images per second: 0.5 for 1 image every 2 seconds, 0.1 for 1 image every 10 seconds, etc).

ffmepg -i $INPUT -r $RATE -f image2 $OUTPUT_%05d.jpg
# Ex: ffmepg -i awesome_goal.mp4 -r 0.1 -f image2 goal_%05d.jpg

Loop a video into a longest one

Where $ITERATION is the desired video loops.

ffmpeg -stream_loop $ITERATION -i $INPUT -c copy $OUTPUT

Rip a DVD to a MP4

Where $PATH is your DVD path containing .VOB files. $QUALITY is the desired video quality (0 is lossless, 51 is highly compressed, 23-28 is nice).

cat $PATH/VTS_0_*.VOB | ffmpeg -i - -c:v libx264 -crf $QUALITY $OUTPUT.mp4

Audio commands

⬆️ Go to top

Extract audio from a video in MP3

Where $BITRATE is the desired audio bitrate (96, 128, 192, 256, 320).

ffmpeg -i $INPUT -vn -ar 44100 -ac 2 -ab $BITRATE -f mp3 $OUTPUT.mp3
# Ex: ffmpeg -i i_love_rock_n_roll.mp4 -vn -ar 44100 -ac 2 -ab 192 -f mp3 i_love_rock_n_roll.mp3

Miscellaneous

⬆️ Go to top

Get file infos

ffmpeg -i $FILE

Get file infos in JSON format

ffprobe -loglevel quiet -show_format -show_streams -print_format json $FILE

Codec guides

⬆️ Go to top

Video

Audio

Miscellaneous

Blog posts

⬆️ Go to top

About

Useful commands for FFPMEG

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published