Created
March 23, 2024 05:25
-
-
Save MasterGeekMX/2e80d32487abd056f8b1417c5c5a973b to your computer and use it in GitHub Desktop.
Script para hacer gifs nopor #GraciasTaringa
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
#!/bin/bash | |
# Para que esta cosa funque, necesitan tener instalados FFMPEG y GifSicle | |
# Además, los videos deben estar en MP4 y tener una carpeta llamada "Gifs para taringa" al lado del script | |
# Primero checamos que tengamos todos los parámetros | |
if [[ -z $1 ]] | |
then | |
echo "no me diste el video, troesma" | |
exit 1 | |
fi | |
if [[ -z $2 ]] | |
then | |
echo "faltó el tiempo inicial, lince" | |
exit 2 | |
fi | |
if [[ -z $3 ]] | |
then | |
echo "faltó el tiempo final, maquinola" | |
exit 3 | |
fi | |
# Guardamos los parámetros en variables más amigables | |
video="$1" | |
inicio="$2" | |
fin="$3" | |
# Generamos el nombre de archivo del GIF a crear | |
gif="${video/mp4/gif}" | |
# Primero generemos el GIF recortado, con 10 FPS y a 500px de ancho | |
ffmpeg -i "$video" -ss $inicio -to $fin -r 10 -vf scale=500:-1 "gifs para taringa/$gif" | |
# Obtengamos la resolución del GIF para generar el fotograma negro | |
resolucion=$(gifsicle -I "gifs para taringa/$gif" | grep screen | cut -f 5 -d ' ') | |
# Generamos el fotograma en negro | |
convert -size $resolucion xc:black /tmp/negro.gif | |
# Le pegeamos el fotograma negro al GIF | |
gifsicle -b "gifs para taringa/$gif" --insert-before "#0" /tmp/negro.gif | |
# Optimizamos el GIF para que pese menos | |
gifsicle -b "gifs para taringa/$gif" -O3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment