Skip to content

Instantly share code, notes, and snippets.

@akatopo
Created December 30, 2024 19:07
Show Gist options
  • Save akatopo/dc7cdb54695876c25ce8339a5ae583d5 to your computer and use it in GitHub Desktop.
Save akatopo/dc7cdb54695876c25ce8339a5ae583d5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://unix.stackexchange.com/questions/230481/how-to-download-portion-of-video-with-youtube-dl-command
# https://stackoverflow.com/questions/23842261/alternative-to-readarray-because-it-does-not-work-on-mac-os-x
# Arguments: URL, Time stamp -5 seconds, length of clip, video file name
# ex. ./clip-youtube.sh "https://www.youtube.com/watch?v=aqz-KE-bpKQ" 3:05 11 squashed.mp4
while IFS=\= read url; do
urls+=($url)
done <<< "$(yt-dlp --youtube-skip-dash-manifest -g "$1")"
ffmpeg -ss $2 -i "${urls[0]}" -ss $2 -i "${urls[1]}" -ss 5 -map 0:v -map 1:a -c:v libx264 -c:a aac -t $3 $4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment