Created
May 21, 2018 19:07
-
-
Save nyanshiba/600a012c1d3c1a42bd1c0b7fd0c8542f to your computer and use it in GitHub Desktop.
はぁ…
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
@echo off | |
rem ====================環境変数設定==================== | |
rem youtube-dl.exeのパス | |
set "ytdl_path=C:\DTV\bin\youtube-dl.exe" | |
rem ffmpeg.exeがあるディレクトリのパス | |
set "ff_dir=C:\DTV\ffmpeg" | |
rem vlc.exeのパス | |
set vlc_path= | |
rem 出力フォルダのパス | |
set "out_dir=C:\Users\sbn\Desktop\youtube_dl" | |
rem ====================ユーザ選択==================== | |
set /p ask_exe=ffmpegかyoutube-dlか選択[m=ffmpeg(m3u8),t=ffmpeg(TwitCasting),Enter=youtube-dl]: | |
if "%ask_exe%" == "m" ( | |
call :ffmpeg_m3u8 | |
) else if "%ask_exe%" == "t" ( | |
call :ffmpeg_twitcas | |
) else if "%ask_exe%" == "" ( | |
call :youtubedl | |
) | |
pause | |
exit | |
rem ====================ffmpegサブルーチン==================== | |
rem ----------m3u8ストリーム録画---------- | |
:ffmpeg_m3u8 | |
call :mydateset | |
set /p url=m3u8のurlを入力: | |
"%ff_dir%\ffmpeg.exe" -y -i "%url%" -c copy -map p:0 "%out_dir%\%mydate%.ts" | |
exit /b | |
rem ----------ツイキャス録画---------- | |
:ffmpeg_twitcas | |
call :mydateset | |
set /p twitcas_id=ツイキャスIDを入力: | |
"%ff_dir%\ffmpeg.exe" -y -i "http://twitcasting.tv/%twitcas_id%/metastream.m3u8/?video=1" -c copy -map p:0 "%out_dir%\%mydate%_%twitcas_id::=_%.mp4" | |
exit /b | |
rem ----------ファイル名関数---------- | |
:mydateset | |
rem yyMMdd_Hmm | |
rem 自分用(17/08/30 (水) 17:35->170830_1735) | |
set mydate=%date:~0,2%%date:~3,2%%date:~6,2%_%time:~0,2%%time:~3,2% | |
rem 初期設定(2017/08/30 17:35 -> 170830_1735) | |
rem set mydate=%date:~2,2%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2% | |
rem スペースを0に置き換える | |
set mydate=%mydate: =0% | |
exit /b | |
rem ====================youtube-dl+ffmpegサブルーチン==================== | |
:youtubedl | |
rem ----------ログイン選択---------- | |
set /p url=urlを入力: | |
set /p ask_login=ログイン選択[n=ニコニコ動画,n2=ニコニコ動画,t=twitter,Enter=ログイン不要]: | |
if "%ask_login%" == "n" ( | |
set "arg_u=-u hoge -p hoge" | |
) else if "%ask_login%" == "n2" ( | |
set "arg_u=-u hoge -p hoge" | |
) else if "%ask_login%" == "t" ( | |
set "arg_u=-u hoge -p hoge" | |
) else if "%ask_login%" == "" ( | |
set arg_u= | |
) | |
rem ----------入力フォーマット---------- | |
set /p ask_infmt=入力フォーマット[o=bestaudio,a=m4a/bestaudio,v=bestvideo,h=mp4/bestvideo,22=format22(hd720p yt),al=ytlive音声コンテンツ(Enter+最後にffmpegで動画からaacを作成),Enter=best]: | |
if "%ask_infmt%" == "o" ( | |
set arg_f=-f bestaudio | |
) else if "%ask_infmt%" == "a" ( | |
set arg_f=-f m4a/bestaudio | |
) else if "%ask_infmt%" == "w" ( | |
rem set "arg_f=-f bestvideo^[height^<^=^?4320^]" | |
set "arg_f=-f bestvideo" | |
) else if "%ask_infmt%" == "22" ( | |
set arg_f=-f 22 | |
) else if "%ask_infmt%" == "al" ( | |
set ask_split=1 | |
) else if "%ask_infmt%" == "" ( | |
set arg_f= | |
) | |
rem ----------出力フォーマット---------- | |
set /p ask_outfmt=出力フォーマット[f=ffplay,v=vlc,Enter=DL]: | |
if "%ask_outfmt%" == "f" ( | |
set "arg_o=- | "%ff_dir%\ffplay.exe" -" | |
) else if "%ask_outfmt%" == "v" ( | |
set "arg_o=- | "%vlc_path%" -" | |
) else if "%ask_outfmt%" == "" ( | |
set arg_o="%out_dir%\%%(title)s-%%(id)s.%%(ext)s" | |
) | |
rem ----------エンコ---------- | |
rem "--no-part"でtempを作成しない(YouTubeLive、その他リアルタイムストリームに対応) | |
rem YouTubeLiveは放送が終われば強制終了しておk | |
"%ytdl_path%" --ffmpeg-location "%ff_dir%\ffmpeg.exe" %arg_u% %arg_f% --no-check-certificate --no-part "%url%" -o %arg_o% | |
rem 音声スプリット | |
if "%ask_sprit%" equ "1" ( | |
rem "%ff_dir%\ffmpeg.exe" -i %1 -vn -c:a copy "out.m4a" | |
) | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment