Last active
February 7, 2024 16:11
-
-
Save erickyun/e1de5337793ec55c7fdf83a3ad5f6997 to your computer and use it in GitHub Desktop.
Download only part of a youtube video
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
@setlocal | |
@echo off | |
set /p "URL=Enter URL here: " | |
set /p "START_TIME=Enter START_TIME here: " | |
set /p "END_TIME=Enter END_TIME here: " | |
set /p "END_FILENAME=Enter END_FILENAME here: " | |
set "VIDEO_URL= " | |
set "AUDIO_URL= " | |
FOR /F "usebackq delims=" %%i IN (`yt-dlp -g -f bv+ba -- "%URL%"`) do ( | |
set "line=%%i" | |
call :part_seturls line | |
) | |
ffmpeg -ss "%START_TIME%" -i "%VIDEO_URL%" -to "%END_TIME%" -ss "%START_TIME%" -i "%AUDIO_URL%" -to "%END_TIME%" -map 0 -map 1 -c copy -shortest -y "Downloads\%END_FILENAME%" | |
ECHO. | |
ECHO Done! | |
PAUSE | |
EXIT | |
:part_seturls | |
call set "current_url=%%%~1%%" | |
if ["%VIDEO_URL:~0,1%"]==[" "] ( | |
set "VIDEO_URL=%current_url%" | |
) else if ["%AUDIO_URL:~0,1%"]==[" "] ( | |
set "AUDIO_URL=%current_url%" | |
) | |
exit /b | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment