录制抖音直播视频批处理
Posted nlsoft
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了录制抖音直播视频批处理相关的知识,希望对你有一定的参考价值。
@echo off chcp 936 1>nul 2>nul set url=%~1 if NOT DEFINED url ( echo input URL exit /b ) :start set tmp=%random%_%random%_%random% set tmpfn=%tmp%.txt wget %url% -O %tmp%.html 1>nul 2>nul iconv -c -f utf-8 -t gb2312 %tmp%.html|sed s/,/, /g>%tmpfn% del /Q %tmp%.html set roomid=0 FOR /F %%i IN (‘cat %tmpfn%^|grep -Eoi ""room_id_str":"[0-9]{19}""^|grep -Eoi "[0-9]{19}"‘) DO ( set roomid=%%i ) set userid=0 FOR /F %%i IN (‘cat %tmpfn%^|grep -Eoi ""display_id":(.*?),"‘) DO ( set userid=%%i goto next ) :next set userid=%userid:display_id=% set userid=%userid:enable_ichat_img=% set userid=%userid:"=% set userid=%userid::=% set userid=%userid:,=% set userid=%userid: =% echo userID = %userid% set city=0 FOR /F %%i IN (‘cat %tmpfn%^|grep -Eoi ""city":(.{3,20}),"‘) DO ( set city=%%i goto next2 ) :next2 set city=%city:city=% set city=%city:comment_restrict=% set city=%city:"=% set city=%city::=% set city=%city:,=% set city=%city: =% echo city = %city% set nickname=0 FOR /F %%i IN (‘cat %tmpfn%^|grep -Eoi ""nickname":(.*?),"‘) DO ( set nickname=%%i goto next3 ) :next3 set nickname=%nickname:nickname=% set nickname=%nickname:own_room=% set nickname=%nickname:"=% set nickname=%nickname::=% set nickname=%nickname:,=% set nickname=%nickname: =% echo nickname = %nickname% del /Q %tmpfn% if "%roomid%"=="0" ( echo can‘t find room id goto end ) echo roomID = %roomid% set tmpfn=%random%_%random%_%random%.txt set getinfourl="https://webcast-hl.amemv.com/webcast/room/reflow/info/?room_id=%roomid%&live_id=1" wget %getinfourl% -O %tmpfn% 1>nul 2>nul set rtmp=0 set hls=0 FOR /F %%i IN (‘cat %tmpfn%^|grep -Eoi ""rtmp_pull_url":(.*?).flv"^|grep -Eoi "http://(.*?).flv" ‘) DO ( set rtmp=%%i ) FOR /F %%i IN (‘cat %tmpfn%^|grep -Eoi ""hls_pull_url":(.*?).m3u8...hls"^|grep -Eoi "http://(.*?).m3u8" ‘) DO ( set hls=%%i ) del /Q %tmpfn% if "%rtmp%"=="0" ( echo can‘t find rtmp url goto end ) if "%hls%"=="0" ( echo can‘t find hls url goto end ) echo %rtmp% echo %hls% wget "%hls%" --connect-timeout=3 --timeout=3 --waitretry=3 --tries=6 -O nul 1>nul 2>nul if %ERRORLEVEL% NEQ 0 ( echo Not find m3u8. title DONE %nickname% goto stop ) set t=%time::=.% set t=%t: =0% set t=%t:.=-% set t=%t:~0,8% set t=%t:-=% set d=%date:-=% set savefn=%userid%_%nickname%_%city%_%roomid% call :replaceAsterisks %savefn% set savefn=%replaceAsterisks% set savefn=%savefn:?=% set savefn=%savefn: =% set logfn="_%savefn%_play.cmd" set logfn2="_%savefn%_recordRTMP.cmd" set savefn=%savefn%_%d%-%t% md "%savefn%" 1>nul 2>nul cd "%savefn%" set savefnrtmp="_%savefn%.flv" set savefn="_%savefn%.m3u8" echo :: inURL = %url%>%logfn% echo :: userID = %userid%>>%logfn% echo :: city = %city%>>%logfn% echo :: roomID = %roomid%>>%logfn% echo :: nickname = %nickname%>>%logfn% echo ffplay %rtmp% -vf scale=-1:1024>>%logfn% echo.>>%logfn% echo :: %hls%>>%logfn% echo ffmpeg -hide_banner -wt "R %nickname%" -v info -i "%rtmp%" -c copy %savefnrtmp%>>%logfn2% echo %savefn% title R %nickname% :: ffmpeg -hide_banner -wt "R %nickname%" -v info -i "%rtmp%" -c copy %savefn% hlslivedl -i "%hls%" -o %savefn% title DONE %nickname% cd .. :stop choice.exe /c qc /n /t 32 /d c /m "Wait for 32 seconds Press Q to stop" if %errorlevel%==1 goto end goto start exit /b :end exit /b :replaceAsterisks for /f "tokens=1-3,* delims=*" %%a in ("%~1") do (set replaceAsterisks=%%a%%b%%c%%d) exit /b