Last active
May 18, 2021 12:52
-
-
Save diegodorado/baafd4f56fce7ec8398155bbeefbd01f to your computer and use it in GitHub Desktop.
ffmpeg, mogrify, montage and convert ( imagemagick tools)
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
#bulk convert with ffmpeg, cmd works, powershell doesnt | |
for %i in (*.*); do ffmpeg -i %i %~ni.mp4 | |
#extract a video part | |
ffmpeg -i original.avi -an -ss 17 -t 5 cutted.avi | |
# -i, is the input file: original.avi | |
# -an, to not copy the audio (it was giving me troubles and i dont need it now) | |
# -ss, where to start: at 17 seconds | |
# -t, duration: 5 seconds | |
#for more precision | |
ffmpeg -an -ss 00:00:17.2 -t 00:00:04.3 -i original.avi cutted.avi | |
# or set end time instead of t | |
ffmpeg -i input.mp4 -c copy -ss 00:04:25.000 -to 00:09:25.000 output.mp4 | |
#to crop a video | |
ffmpeg -i cutted.avi -vf crop=387:220:20:32 cropped.avi | |
#-vf crop=width:height:x:y | |
#to extract jpgs from video | |
mkdir frames | |
ffmpeg -i cropped.avi -f image2 frames/image-%03d.jpg | |
#create video from images, asuming images numbered 00001.jpg - 09999.jpg or something | |
ffmpeg -r 30 -f image2 -i %05d.jpg -vcodec libx264 video.mp4 | |
#to batch resize images | |
cp -R frames frames_resized | |
cd frames_resized | |
mogrify -resize 50% *.jpg | |
#to create a sprite sheet | |
montage -background transparent -tile 7x20 -geometry +0+0 frames_resized/*.jpg sprite.jpg | |
#to make a color (and similar) transparent | |
convert sprite.png -channel rgba -alpha set -fuzz 7% -fill none -opaque "#0c7ed4" sprite.png | |
# gif from video (full guide at https://github.com/cyburgee/ffmpeg-guide) | |
ffmpeg -ss 382.0 -t 3 -i viu.mp4 -filter_complex "[0:v] fps=10,scale=w=640:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" live-emojing.gif | |
# batch transcode for davinci resolve | |
for f in *.mov; do ffmpeg -i $f -vcodec dnxhd -acodec pcm_s16le "transcoded/$f" ;done; | |
# or | |
ffmpeg -i $f -c:v prores -profile:v 2 -c:a pcm_s16le "transcoded/$f" | |
for i in *.mp4; do ffmpeg -i "$i" -c:v prores -profile:v 3 -c:a pcm_s16le "${i%.*}.mov"; done | |
# get audio as mp3 | |
ffmpeg -i bluedot-outrun.mp4 -codec:a libmp3lame -qscale:a 2 output.mp3 | |
# convert video for IG | |
# https://medium.com/abraia/basic-video-editing-for-social-media-with-ffmpeg-commands-1e873801659 | |
ffmpeg -i trailer_1800p.mov -c:v libx264 -crf 20 -preset slow -profile:v high -level 4.0 -color_primaries 1 -color_trc 1 -colorspace 1 -movflags +faststart -c:a aac -b:a 128k video.mp4 | |
#encode for youtube | |
ffmpeg -i input.mov -c:v libx264 -preset slow -crf 18 -c:a aac -b:a 192k -pix_fmt yuv420p output.mkv |
Px format
-pix_fmt yuv420p
convert video for IG + Px format
ffmpeg -i input.mxf -c:v libx264 -crf 20 -preset slow -profile:v high -pix_fmt yuv420p -level 4.0 -color_primaries 1 -color_trc 1 -colorspace 1 -movflags +faststart -c:a aac -b:a 128k output.mp4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Para normalizar el audio y convertir video. All in one