Skip to content

Instantly share code, notes, and snippets.

@tom-huntington
Last active January 22, 2024 05:17
Show Gist options
  • Save tom-huntington/22c22fe89e703c48594f6e2724dfe459 to your computer and use it in GitHub Desktop.
Save tom-huntington/22c22fe89e703c48594f6e2724dfe459 to your computer and use it in GitHub Desktop.
Download a portion of a youtube live stream
#!/bin/bash
#Arguments: URL, Starting Timestamp -5 seconds, Ending Timestamp, video file name
set -x;
readarray -t urls <<< "$(yt-dlp -f bestvideo[ext=mp4][vcodec^=avc1]+140 --youtube-skip-dash-manifest -g "$1")"
ffmpeg -ss $2 -to $3 -i "${urls[0]}" -ss $2 -to $3 -i "${urls[1]}" -ss 10 -map 0:v -map 1:a -c:v copy -c:a copy "${4}.mp4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment