# updated for current versions
# yt-dlp version 2024.10.22 and
# ffmpeg #version 7.1
# Prereqs use PS or CMD to Install.
# winget yt-dlp
# winget ffmpeg
# Define URL and time ranges.
$URL = "https://www.youtube.com/watch?v=05j8Ai9riEM&list=PPSV"
$from = "00:00:00"
$duration = "00:02:14"
# Download and merge video and audio into 'full_video.mkv'.
yt-dlp -f bestvideo+bestaudio --merge-output-format mkv -o
"full_video.mkv" $URL
# Use FFmpeg to extract the specific portion of the video.
ffmpeg -i "full_video.mkv" -ss $from -t $duration -c copy output.mkv