Created
April 29, 2019 14:35
-
-
Save banteg/5d613ed8eacb174ad200884331568c34 to your computer and use it in GitHub Desktop.
download fragment of a youtube video without downloading the whole thing
This file contains hidden or 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/bash | |
NAME=yt-seek | |
if [ "$#" -ne 3 ]; then | |
echo "Usage: $NAME <url> <start> <duration>" | |
exit 1 | |
fi | |
URL=$1 | |
START=$2 | |
DURATION=$3 | |
AV=($(youtube-dl -g $URL)) | |
if [ "${#AV[@]}" -ne 2 ]; then | |
echo "Could not extract streams" | |
exit 1 | |
fi | |
AUDIO=${AV[0]} | |
VIDEO=${AV[1]} | |
ffmpeg -ss $START -i $VIDEO \ | |
-ss $START -i $AUDIO \ | |
-t $DURATION -c copy out.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment