add split feature for SNS

This commit is contained in:
CoolnsX
2021-08-27 19:13:23 +05:30
parent 6669adb3b8
commit ceb4f1194c
2 changed files with 20 additions and 4 deletions

20
youtube
View File

@@ -1,5 +1,8 @@
#!/bin/sh
# script for downloading youtube videos and split it into pieces..
# defining shell colors for distinction
c_red="\033[1;31m"
c_green="\033[1;32m"
c_yellow="\033[1;33m"
@@ -8,7 +11,7 @@ c_magenta="\033[1;35m"
c_cyan="\033[1;36m"
c_reset="\033[0m"
#function to download full video
full_video()
{
video=$1
@@ -16,6 +19,7 @@ full_video()
}
# function to download part of a video and also split it for SNS...
part_video()
{
video=$1
@@ -23,8 +27,18 @@ part_video()
read start
printf "${c_yellow}Enter Upto Seconds:${c_cyan}"
read dur
ffmpeg -i $(youtube-dl -f best --get-url "$video") -ss $start -t $dur $HOME/Videos/$(date +%s).mp4
}
printf "Do you want to split video for SNS?? (y or n) :"
read x
if [ $x == 'n' ]; then
ffmpeg -i $(youtube-dl -f best --get-url "$video") -ss $start -t $dur $HOME/Videos/$(date +%T_%F).mp4
else
out=$(date +%T_%F)
ffmpeg -i $(youtube-dl -f best --get-url "$video") -map 0 -codec copy -f segment -segment_time 30 -ss $start -t $dur $HOME/Videos/${out}_%03d.mp4
fi
}
#program starts from here..
printf "${c_blue}Input Youtube link :${c_magenta}"
read x