This script assumes FFmpeg and Livestreamer to be installed in %PATH% by default.
Creates the following folder structure
../record-twitch.ps1 (this file)
../recording/ (folder where the full stream file will be placed)
This script will by default re-emit the stream to udp://127.0.0.1:2000, you can open this stream with MPC-HC, VLC or any other media player that supports the format (mpegts over udp).
# Twitch recording script by EraYaN # 2016-04-04 # v1.05 param ( [string]$channel = "babymetalband", [string]$quality = "source", [string]$url = "https://www.twitch.tv/$channel", [string]$outputfile = "recording/twitch_${channel}_${quality}_$(get-date -f yyyyMMddTHHmmss)", [string]$livestreamer = "livestreamer", [string]$ffmpeg = "ffmpeg", [string]$player = "C:\Program Files\MPC-HC\mpc-hc64.exe", [int]$length = 0, [string]$muxer = "mp4", [string]$reemitporthost = "127.0.0.1", [string]$reemitprotocol = "udp", [int]$reemitport = 2000, [string]$reemituri = "${reemitprotocol}://${reemitporthost}:$reemitport", [string]$reemitformat = "mpegts", [switch]$skipdirectorycreation = $false ) if(!$skipdirectorycreation){ # New-Item live\ -type directory -force (For HLS re-emit) # New-Item live\chunks\ -type directory -force (For HLS re-emit Write-Host "Creating directories." $dir = New-Item recording\ -type directory -force if(!$dir.Exists){ Write-Error "Could not create directories." Exit } } Write-Host "Outputfile = $outputfile.$muxer (This will be a $muxer file)" Write-Host "Length = $length seconds" Write-Host "URL = $url" Write-Host -ForegroundColor Green "Starting Livestreamer to get JSON object." $streaminfo = &$livestreamer --json $url $quality | ConvertFrom-JSON $streamurl = $streaminfo."url" if(![string]::IsNullOrEmpty($streamurl)){ Write-Host -ForegroundColor Green "Starting FFmpeg recording." Write-Host "Don't forget to strip off the start of the file, if you started recording early." if ($length -gt 0){ Start-Process $ffmpeg -ArgumentList ("-i", $streamurl, "-bsf:a aac_adtstoasc -c copy -t", $length, "$outputfile.$muxer", '-c copy -t', $length, '-f', $reemitformat, $reemituri) Write-Host -ForegroundColor Green "Started FFmpeg for $length seconds, press q in the ffmpeg window to terminate early." } else { Start-Process $ffmpeg -ArgumentList ("-i", $streamurl, "-bsf:a aac_adtstoasc -c copy", "$outputfile.$muxer", '-c copy -f', $reemitformat, $reemituri) Write-Host -ForegroundColor Green "Started FFmpeg, press q in the ffmpeg window to terminate the recording." } Write-Host -ForegroundColor Green "Starting MPC-HC player." Start-Process $player udp://127.0.0.1:2000 } else { Write-Host -ForegroundColor Red "URL could not be retrieved." $streaminfo."error" }
Save this as a .ps1 file somewhere with enough space.
After you have finished recording (press q in the spawned ffmpeg window) use ffmpeg -i (put the recorded file here) -ss (put the amount of seconds or the minutes:seconds that need to be cut of the start here) output.mkv
record-twitch.bat [options]
-channel [channel]: Twitch channel name, default: "babymetalband"
-quality [quality]: Twitch stream quality (one of the names livestreamer uses: audio, high, low, medium, mobile (worst), source (best)), default: "source"
-url [uri]: Full url (Everything supported by livestreamer and ffmpeg COULD work), default: "https://www.twitch.tv/$channel"
-outputfile [path]: Stream recoridng output file, default: "recording/twitch-$channel-$quality-$(get-date -f yyyyMMddTHHmmss)"
-livestreamer [path]: Path to livestreamer executable, default: "livestreamer"
-ffmpeg [path]: Path to ffmpeg executable, default: "ffmpeg"
-player [path]: Path to player executable, default: "C:\Program Files\MPC-HC\mpc-hc64.exe"
-length [seconds]: Recording length, default: 0 (indefinite)
-muxer [fileextenstion]: The muxer file extension to be passed to ffmpeg, default: "mp4"
-reemitporthost [host]: The reemitted stream host, default: "127.0.0.1"
-reemitprotocol [protocol]: The reemitted stream protocol, default: "udp"
-reemitport [channel]: The reemitted stream port, default: 2000
-reemituri [uri]: The reemitted stream uri, default: "$[reemitprotocol]://$[reemitportip]:$reemitport"
-reemitformat [format]: The reemitted stream format (ffmpeg stream format type), default: "mpegts"
-skipdirectorycreation: Skip the creating of the recording directory
record-twitch.ps1 -length 3600 -channel totalbiscuitRecords 1 hour from the totalbiscuit channel to recording/twitch-$channel-$quality-$(get-date -f yyyyMMddTHHmmss).mp4 and restreams the stream for viewing.
More stream info here.
This script assumes FFmpeg to be installed in %PATH%.
Creates the following folder structure
../record-logirl.bat (this file)
../live/ (folder where the playlist file will reside)
../live/chunks/ (folder where all the stream chunks will be held)
../recording/ (folder where the full stream file will be placed)
If you install a webserver and have the root at /live/ you can access the stream via the url http://
This script will re-emit the stream to ..\live\logirl.m3u8 you can open this file with VLC or any other media player that supports the format or use a webserver to access it from other computers.
@ECHO OFF PowerShell.exe -Command "& '%~dpn0.ps1'" PAUSE
Save this as a .bat file somewhere with enough space.
After you finished recording (press q) use ffmpeg -i (put the recorded file here) -ss (put the amount of seconds or the minutes:seconds that need to be cut of the start here) output.mkv
record-logirl.bat [options]
-url <url> : The stream url if you omit this it default to the LoGiRL stream URL used 19-01-2015 23:31 GMT+1 (No idea if they change that thing)
-len <seconds> : The number of seconds you want to record, if you omit this it will default to 50000 seconds.
-out <outputfilepath> : The output *.* file, if you omit this it will default to recording/logirl_out-%RANDOM%.%muxer& (relative to the current directory, and windows cmd's %RANDOM% is not super random so it might overwrite a file.) PLease don't include a file extenstion.
-mux <ts>: The output muxer. FFmpeg supports lots of formats in that case this is the file extension. ts is recommended and default.
record-logirl.bat -len 3600 -out "E:\raw_record_dump\streamname"Records 1 hour from the default stream to E:\raw_record_dump\streamname.%muxer% and restream the stream for viewing.
More stream info here.
This script assumes FFmpeg and Livestreamer to be installed in %PATH%.
Creates the following folder structure
../record-nightofspica.bat (this file)
../live/ (folder where the playlist file will reside)
../live/chunks/ (folder where all the stream chunks will be held)
../recording/ (folder where the full stream file will be placed)
If you install a webserver and have the root at /live/ you can access the stream via the url http://
This script will re-emit the stream to ..\live\nightofspica.m3u8 you can open this file with VLC or any other media player that supports the format or use a webserver to access it from other computers.
@ECHO OFF REM make the following folder structure: REM ../record-nightofspica.bat REM ../live/ REM ../live/chunks/ REM ../recording/ REM Check directories if not exist "live\" mkdir live\ if not exist "live\chunks" mkdir live\chunks if not exist "recording\" mkdir recording\ REM defaults SET outputfile=recording/nightofspica_out-%RANDOM% SET length=50000 SET url=http://www.ustream.tv/channel/stolabo-tokyo SET muxer=mp4 :loop IF NOT "%1"=="" ( IF "%1"=="-out" ( SET outputfile=%2 SHIFT ) IF "%1"=="-mux" ( SET muxer=%2 SHIFT ) IF "%1"=="-len" ( SET length=%2 SHIFT ) IF "%1"=="-url" ( SET url=%2 SHIFT ) SHIFT GOTO :loop ) ECHO Outputfile = %outputfile%.%muxer% (This will be a %muxer% file) ECHO Length = %length% seconds ECHO URL = %url% ECHO Starting Livestreamer and FFmpeg... echo Don't forget to strip off the start of the file, if you started recording early. livestreamer.exe %url% best --stdout | ffmpeg -i - -t %length% -c copy %outputfile%.%muxer% -bsf:v h264_mp4toannexb -c copy -f hls -hls_flags delete_segments -hls_time 2 -hls_list_size 30 -hls_base_url chunks\ -hls_segment_filename live\chunks\nightofspica_chunk%%03d.ts live\nightofspica.m3u8 echo Done if NOT ["%errorlevel%"]==["0"] ( pause exit /b %errorlevel% )
Save this as a .bat file somewhere with enough space.
After you finished recording (press Ctrl+C) use ffmpeg -i (put the recorded file here) -ss (put the amount of seconds or the minutes:seconds that need to be cut of the start here) output.mkv
record-nightofspica.bat [options]
-url <url> : The stream url if you omit this it default to the LoGiRL stream URL used 19-01-2015 23:31 GMT+1 (No idea if they change that thing)
-len <seconds> : The number of seconds you want to record, if you omit this it will default to 50000 seconds. (untested)
-out <outputfilepath> : The output *.* file, if you omit this it will default to recording/nightofspica_out-%RANDOM%.%muxer& (relative to the current directory, and windows cmd's %RANDOM% is not super random so it might overwrite a file.) PLease don't include a file extenstion.
-mux <ts>: The output muxer. FFmpeg supports lots of formats in that case this is the file extension. ts is recommended and default.
record-nightofspica.bat -len 3600 -out "E:\raw_record_dump\streamname"Records 1 hour from the default stream to E:\raw_record_dump\streamname.%muxer% and restream the stream for viewing.
More stream info here.