Last active
September 11, 2020 19:48
-
-
Save F1LT3R/503fdcabb4bdd909506de7b7df8f9ac2 to your computer and use it in GitHub Desktop.
Split long YouTube Videos into 5min MP3 Segments
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 | |
# USAGE: ytm3 https://www.youtube.com/watch\?v\=rQLBitV69Cc | |
# DESCRIPION: Download Audio from YouTube videos, Convert to split MP3s (5 Min) | |
# PURPOSE: Studying w/ iPod shuffle | |
# PRE-REQS: Node.js, YTDL, FFMPEG | |
# Author: F1LT3R.io | |
for URL in $@ | |
do | |
# Sanitized video title | |
TITLE=$(ytdl -i $URL | awk 'FNR ==1 { for (i=2; i<=NF-1; i++) printf("%s-",$i); printf("%s",$NF) }END{ print"" }') | |
TITLE_ESC=$(printf '%q' "$TITLE") | |
FILENAME_MP4="$TITLE_ESC.mp4" | |
FILENAME_MP3="$TITLE_ESC.mp3" | |
# Download MP4 Audio | |
ytdl -q 140 $URL -o $FILENAME_MP4 | |
# Convert MP4 to MP3 | |
ffmpeg -i $FILENAME_MP4 $FILENAME_MP3 | |
# Split MP3 to 5min Segments | |
ffmpeg -i $FILENAME_MP3 -f segment -segment_time 300 -c copy "$TITLE_ESC-%03d.mp3" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment