Last active
May 10, 2022 07:43
-
-
Save dardo82/f6f47270039703d265e9ba32f2bc848d to your computer and use it in GitHub Desktop.
Split videos at silence
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
BEGIN{ printf( "%s\n\n", ";FFMETADATA1"); t=0} | |
/duration/{ printf( "%s\n%s%d\n%s%.0f\n%s%.0f\n\n", "[CHAPTER]", "TIMEBASE=1/", 10^6, "START=", t*10^6, "END=", $5*10^6); t=$5} | |
END{ printf( "%s\n%s%d\n%s%.0f\n%s%.0f\n\n", "[CHAPTER]", "TIMEBASE=1/", 10^6, "START=", t*10^6, "END=", d*10^6)} |
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
BEGIN { printf( "%s\n\n", ";FFMETADATA1"); t=0} | |
{ printf( "%s\n%s%d\n%s%.0f\n%s%.0f\n\n", "[CHAPTER]", "TIMEBASE=1/", 1, "START=", t, "END=", $1); getline; t=$1} | |
END { printf( "%s\n%s%d\n%s%.0f\n%s%.0f\n\n", "[CHAPTER]", "TIMEBASE=1/", 1, "START=", t, "END=", s)} |
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/sh | |
# DownLoad and Split YouTube videos at silence. | |
SHOW="$1"; DATE="$2"; D="$3"; N="$4" | |
ID=$(yt-dlp --get-id "ytsearch: $SHOW $DATE") | |
MP4="$ID.mp4"; FFMD="$ID.ffmd" | |
L="${LANG%.*}"; SRT="$ID.${L%_*}.srt" | |
AWK="${0%/*}/ffprobe2ffmd.awk" | |
yt-dlp --id -f "135+140" "$ID" | |
S=$(ffprobe -of "default=nw=1:nk=1" \ | |
-show_entries "format=duration" "$MP4") | |
ffprobe -of "default=nw=1:nk=1" -f lavfi \ | |
-i "amovie=$MP4, silencedetect=d=$D:n=-${N}dB" \ | |
-show_entries "tags=lavfi.silence_end" \ | |
| awk -v s="$S" -f "$AWK"> "$FFMD" | |
mpv --chapters-file="$FFMD" "$MP4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment