Skip to content

Instantly share code, notes, and snippets.

@dardo82
Last active August 22, 2017 06:27
Show Gist options
  • Save dardo82/06d64f21a5be36e7cc20230c912133af to your computer and use it in GitHub Desktop.
Save dardo82/06d64f21a5be36e7cc20230c912133af to your computer and use it in GitHub Desktop.
Edit at black frame
#!/bin/sh
TS="$1";BN="${TS%.*}";ED="$BN-edit";LOG="${TS%/*}/ffmpeg.log";VF="blackdetect"
ffmpeg -i $TS -vf $VF=d=0.04 -f rawvideo -y /dev/null 2>&1 | tr \\r \\n > $LOG
eval $(awk -F ':| ' 'BEGIN {be=0.00} /black/ {print "ffmpeg -i $TS -ss "be" -to "$5" $BN-"NR".ts;"; be=$7}' $LOG)
for FILE in $BN-*;do ffprobe $FILE 2>&1 | grep -q " 00:0" && rm -fv $FILE;done
cat $BN-* > $ED.ts; ffmpeg -i $ED.ts $ED.mp4; rm -fv $BN-*.ts $LOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment