Created
July 7, 2020 10:57
-
-
Save namieluss/6a5dc9edec17f0cbcd88524a42ee7ea2 to your computer and use it in GitHub Desktop.
A simple script to download and clip out youtube videos with youtube-dl and ffmpeg.
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/bash | |
# to run and extract clip | |
# ./youtube-clip.sh UF8uR6Z6KLc --trim 00:03:32 00:05:32 | |
# youtube video id | |
vid="$1"; | |
echo "[youtube-dl] download video from youtube in .mp4 format..."; | |
youtube-dl --format mp4 $vid -o '%(title)s.%(ext)s'; | |
if [ "$2" == --trim ] | |
then | |
# from which point to which point you want to trim | |
# start e.g. 00:03:32 | |
# end e.g. 00:05:32 | |
start="$3"; | |
end="$4"; | |
# get the name of the video file | |
file_name=`youtube-dl --get-filename -o '%(title)s' $vid`; | |
# file extension | |
ext="mp4"; | |
# path to working directory | |
path=`pwd`; | |
# video clip name and path to store location | |
clip="$path/${file_name}_clip.${ext}"; | |
echo "[ffmpeg] cutting out the section file you need"; | |
ffmpeg -i "$path/$file_name.$ext" -ss $start -to $end "$clip"; | |
fi | |
echo "done..."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment