Skip to content

Instantly share code, notes, and snippets.

@Canx
Created October 15, 2018 13:19
Show Gist options
  • Save Canx/2b8b46271fc8a75414d0b0d0628c373d to your computer and use it in GitHub Desktop.
Save Canx/2b8b46271fc8a75414d0b0d0628c373d to your computer and use it in GitHub Desktop.
#!/bin/bash
# Grabar archivo a la vez que hacemos multicast y grabar audio también!!!
filename="salida"
URL="udp://239.0.0.1:1234/"
rm -rf "{$filename}.mp4"
titulo=$(zenity --entry --title="Grabación" --text="Introduce el titulo del video (se empezará a grabar a continuación:")
now=$(date +"%m_%d_%Y")
ffmpeg -f x11grab -s 1920x1080 -framerate 10 -i :0.0 -f pulse -i default -acodec libmp3lame -tune zerolatency -c:v libx264 -x264-params keyint=5:min_keyint=2 -pix_fmt yuv420p -s 1280x800 -threads 0 -f tee -map 0:v -map 1:a "${filename}.mp4|[f=mpegts]${URL}"
# Aquí tenemos que recortar los últimos 5 segundos y añadir la cabecera y el final.
duration=$(ffmpeg -i "${filename}.mp4" 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,//)
length=$(echo "$duration" | awk '{ split($1, A, ":"); print 3600*A[1] + 60*A[2] + A[3] }' )
trim_start=0
trim_end=$(echo "$length" - 5 - "$trim_start" | bc)
ffmpeg -ss "$trim_start" -i "$f" -c copy -map 0 -t "$trim_end" "${filename}-trimmed.mp4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment