Created
February 12, 2021 03:53
-
-
Save AJpon/93d5855759540972e54e48dfe0608a0c to your computer and use it in GitHub Desktop.
FFmpegを用いてHLS(HTTP Live Streaming)形式の動画をダウンロードするバッチファイル
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
@echo off | |
setlocal enabledelayedexpansion | |
set selfname=%~n0 | |
cd /d %~dp0 | |
@REM 引数による条件処理 | |
if "%1"=="" ( | |
call :usage | |
goto :success | |
) | |
if "%1"=="help" ( | |
call :usage | |
goto :success | |
) | |
if "%2"=="" ( | |
call :abort Parameter `op2` required. | |
goto :error | |
) | |
set FFMPEG_ARGS=-i "%1" -c copy "%2" | |
@REM ffmpeg.exeにパスが通っている場合はそちらを利用し、無ければ本ファイルが存在するディレクトリ以下にffmpeg.exeが存在するか検索をかける | |
where ffmpeg >nul 2>&1 | |
if %errorlevel% equ 0 ( | |
ffmpeg %FFMPEG_ARGS% | |
) else ( | |
where /r %~dp0 /f ffmpeg >nul 2>&1 | |
if !errorlevel! equ 0 ( | |
FOR /F "DELIMS=" %%A IN ('where /r %~dp0 /f ffmpeg') DO SET FFMPEG_PATH=%%A &goto :break | |
) else ( | |
echo ffmpeg.exe could not be found, please install FFmpeg on your system or place ffmpeg.exe under "%CD%" | |
goto :error | |
) | |
:break | |
!FFMPEG_PATH! %FFMPEG_ARGS% | |
) | |
pause | |
exit /B | |
@REM 関数代わりのアレコレ | |
:success | |
exit /B 0 | |
:error | |
pause | |
exit /B 1 | |
:usage | |
echo [Usage] | |
echo %selfname% : Show the usage. | |
echo %selfname% help : Show the usage. | |
echo %selfname% op1 op2 : For op1, specify the path or URL of the m3u8 playlist file. op2 specifies the path and file name for saving the file. | |
exit /B | |
:abort | |
echo (%selfname%) Error! %* | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment