#!/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