Stream to Instagram w/ OBS & re-stream Automatically (IGLive-PHP)

Stream to Instagram w/ OBS & re-stream Automatically (IGLive-PHP)

Subscribers:
373
Published on ● Video Link: https://www.youtube.com/watch?v=HrE-Jg4ScIw



Duration: 28:30
4,925 views
30


Links to all files that I used here in this google drive folder:
https://drive.google.com/drive/folders/1bPyOXXDNTSv1NpIr_HnzhmowlyvlBKhN?usp=sharing

Discussion Notes:

1. Delete code that makes you have to press “Enter” on the keyboard when running the golive.php.
A. Delete this section:
$pauseH = fopen("php://stdin", "r");
$pauseR = fgets($pauseH);
fclose($pauseH);


2. Add in a new section of code (or whatever its called) to makes a new service.json file for OBS so that we can rewrite over the streamkey information each time.
A. Where you deleted that section of code in Part 1, add this instead. (Replace “<Accountname>” with your windows account folder. If the service.Json is located somewhere else, then use that location in the code below. Make sure to put “\\” instead of just one “\” for the file path:
$fp = fopen('C:\\Users\\<Accountname>\\AppData\\Roaming\\obs-studio\\basic\\profiles\\Untitled\\service.json', 'w');
fwrite($fp,
"{
\"settings\": {
\"key\": \"$streamKey\",
\"server\": \"rtmp://live-upload.instagram.com:80/rtmp/\"
},
\"type\": \"rtmp_custom\"
}");
fclose($fp);


3. Create a new batch script to run the golive.php as well as OBS (you can name this whatever)
A. Go into notepad or whatever source code editor you like and put this in there. (Replace “<Pathlocation>” with the folder location of where your golive.php script is located.) (NOTE: If you are using the 32 bit version of OBS then your path location will be different than people who use OBS’s 64 bit version...i.e OBS64.exe. Make sure to select the right location and the right process name as it probably wont be called OBS64.exe; it will probably be called “OBS.exe” or something like that.

@if (@CodeSection == @Batch) @then
@echo on
cd C:\<Pathlocation>
start PHP golive.php -i
set SendKeys=CScript //nologo //E:JScript "%~F0"
%SendKeys% "echo off{ENTER}"
Taskkill /f /IM obs64.exe
Timeout /t 13
cd C:\Program Files\obs-studio\bin\64bit
start "C:\Program Files\obs-studio\bin\64bit" obs64.exe --startstreaming
goto :EOF
@end

B. Save it as whatever you like to name it (IGLIVE.bat if you like) but make sure it has .bat as its ending extension so windows knows it’s a batch file.


4. Create a new batch script to kill any and all php.exe (you can name this whatever)
A. Go into Notepad or whatever and create this file:
@echo on
taskkill /F /IM php.exe
@end

B. Save it as whatever you like to name it (kill php.bat if you like) but make sure it has .bat as its ending extension so windows knows it’s a batch file.


5. Use task scheduler (or cron, or gnome scheduler, or automator with ical) to schedule out your kill php script and your new start php script. You want the kill php script to run 8 seconds before your start php script.


Programs:
IGLive-PHP: https://github.com/JRoy/InstagramLive-PHP
Notepad++: https://notepad-plus-plus.org/
OBS: https://obsproject.com/
Task scheduler (It comes with windows): https://docs.microsoft.com/en-us/windows/desktop/taskschd/task-scheduler-start-page


Alternate programs:
Cron (cli tool for task scheduling on linux): https://askubuntu.com/questions/378929/linux-alternative-to-windows-task-scheduler-or-another-way-of-doing-it
Gnome-scheduler (GUI version of Cron): https://askubuntu.com/questions/378929/linux-alternative-to-windows-task-scheduler-or-another-way-of-doing-it
Automator with ical (task scheduler for mac): https://support.apple.com/guide/automator/welcome/mac







Tags:
OBS
instagram
streaming
restream
Instagramlive-php
instagramlive
Open source broadcast software
streamlabs
nginx
tutorial
how-to
php
scripting
automation
streamkey