Created
January 12, 2023 05:15
-
-
Save jeremyrsellars/93a4db07098348c55eec6108a6028883 to your computer and use it in GitHub Desktop.
Clip YT audio
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
# Downloads the video and coverts to audio, then clips it from $start to $stop time and saves as $file | |
# The time formats must be "hh:mm:ss" and are relative to the beginning of the source video. | |
$youtubeUrl = "https://www.youtube.com/watch?v=T6SyM0Kw6GA" | |
$start = "00:00:36" | |
$stop = "00:04:55" | |
$file = "clip" | |
$youtube_id = [regex]::new("[^/=]+$").Match($youtubeUrl).Value | |
md $youtube_id -ErrorAction SilentlyContinue | |
cd $youtube_id | |
if(Test-Path "*$youtube_id.mp3") { | |
Echo "Already downloaded $youtube_id.mp3" | |
} else { | |
youtube-dl --extract-audio --audio-format mp3 --print-traffic --console-title --write-thumbnail $youtubeUrl | |
} | |
$whole = Get-ChildItem -Path "*$youtube_id.mp3" -Force -Recurse -File | Select-Object -First 1 | |
del "$file.mp3" -ErrorAction SilentlyContinue | |
ffmpeg -i $whole -ss $start -to $stop "$file.mp3" | |
dir "$file.mp3" | |
popd |
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
# Requires Homebrew | |
brew install ffmpeg | |
brew install youtube-dl |
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
# Requires chocolatey package manager https://chocolatey.org/install | |
choco install ffmpeg | |
choco install youtube-dl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment