Last active
August 29, 2021 13:06
-
-
Save andresaquino/384dcb258297b307ae2e19c3b047ea28 to your computer and use it in GitHub Desktop.
My ffmpeg favourite commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Reduce size | |
ffmpeg -i <video.mp4> -vcodec h264 -acodec aac <video-output.mp4> | |
# Extract a audio fragment from another audio | |
ffmpeg -ss 00:00:30 -t 00:02:58 -i <input.mp3> -acodec copy <ouput.mp3> | |
# Extract audio from a video | |
ffmpeg -i <video.avi> -f mp3 <audio.mp3> | |
# Creating a single image video | |
ffmpeg -loop 1 -i <image.png> -i <sound.mp3> -shortest <video.mp4> | |
# Creating a single image video to publish in fb or twitter. | |
# If you want visualize your mp4 in OS X : -pix_fmt yuv420p | |
# Perform scale using x264 : -vcodec libx264 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" | |
ffmpeg -loop 1 -y -i <image.jpg> -i <video.mov> -f mp4 -vcodec libx264 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -acodec aac -pix_fmt yuv420p -shortest <video.mp4> | |
# Play music from youtube using youtube-dl | |
wget -q -O - `youtube-dl -b -g $url`| ffmpeg -i - -f mp3 -vn -acodec libmp3lame -| mpg123 - | |
# .mov to mp4 | |
ffmpeg -i <video-in.mov> -qscale <0..30:quality> <video-out.mp4> | |
# .mov to .gif | |
ffmpeg -i <video-in.mov> -s 600x400 -pix_fmt rgb8 -r 10 -f gif - | gifsicle --optimize=3 --delay=6 > <video-in.gif> | |
# .git to mp4 | |
ffmpeg -i <video-in.gif> -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" <video-out.mp4> | |
# .gif to mp4 with audio .mp3 | |
ffmpeg -ignore_loop 0 -i <video-in.gif> -i <audio-in.mp3> -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -t <video-in-time-secs> <video-out.mp4> | |
# .mp4 to .gif | |
ffmpeg -i <video.mp4> -filter_complex 'fps=10,scale=320:-1:flags=lanczos,split [o1] [o2];[o1] palettegen [p]; [o2] fifo [o3];[o3] [p] paletteuse' <video.gif> | |
# .mp4 rotate | |
ffmpeg -i <video.mp4> -c copy -metadata:s:v:0 rotate=(45,90,180,270) <video-output.mp4> | |
# resize video dimensions | |
ffmpeg -i <video-original.mp4> -vf scale=X:Y <video-output.mp4> | |
# resize video dimensions (keeping aspect ratio) | |
ffmpeg -i <video-original.mp4> -vf scale=X:-1 <video-output.mp4> | |
ffmpeg -i <video-original.mp4> -vf scale=-1:Y <video-output.mp4> | |
# Resize (keep quality) | |
ffmpeg -i <video-input>_1920x1080.mp4 -vcodec libx264 -vf scale=1280:720 -r 60000/1001 -preset slow -crf 18 <video-output>_1280x720.mp4 | |
ffmpeg -i <video-input>_1920x1080.mp4 -vcodec libx264 -vf scale=896:432 -r 60000/1001 -preset slow -crf 18 <video-output>_896x432.mp4 | |
# Cut | |
ffmpeg -i <video-input> -ss 00:00:00.0 -to HH:MM:SS.MCRSEG <video-output> | |
# Crop crop=SizeX:SizeY:StartX:StartY" | |
ffmpeg -i <video-input> -filter:v "crop=1280:1030:0:0" <video-output> | |
# Usando youtube-dl | |
# Listando formatos disponibles | |
youtube-dl -F https://www.youtube.com/watch?v=ID | |
# Descargar video en formato webm | |
youtube-dl -f 251 https://www.youtube.com/watch?v=ID | |
# Convertir webm to mp3 | |
ffmpeg -i <file.webm> -vn -ab 128k -ar 44100 -y <file.mp3> | |
# Reducir tamaño video | |
ffmpeg -i <video.mp4> -vcodec libx264 -crf 28 -preset faster -tune <video-small.mp4> | |
# MP4 to Windows Media (wmv) | |
ffmpeg -i <file.mp4> -qscale 2 -vcodec msmpeg4 -acodec wmav2 <output.wmv> | |
ffmpeg -i <file.mp4> -q:a 2 -q:v 2 -vcodec msmpeg4 -acodec wmav2 <output.wmv> | |
# Documentation | |
# https://trac.ffmpeg.org/wiki |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment