Live Streaming App in React [Completed]
Credits
This Live Streaming App was made while learning from this below tutorial.
That being said, lot of Styling is either mine or from Foundation Framework. Moreover all the codes in the source code (Logic and/or Styling) has been written with with my preferred coding style.
Installation
- Install Node (&
npm
that comes with it) - Clone this repo.
- Install Open Broadcaster Software aka OBS for your operating system.
Usage
Backend - API Server
- Open New Terminal Window & Please
cd
intobackend/api-server
folder and then runnpm install
- Run
npm start
to run this on your local server. This opens port3005
. - Open http://localhost:3005/streams to view the fake api resource powered by
json-server
. We are using this API Server for interacting with our Frontend.
Backend - RTMP Server
- Open New Terminal Window & Please
cd
intobackend/rtmp-server
folder and then runnpm install
- Run
npm start
to run this on your local server. This opens port1935
for rtmp and port8000
for http.
Frontend - Client Server
- Open New Terminal Window & Please
cd
intofrontend/client-server
folder and then runnpm install
- Create an account at Google Cloud if you don't have it already.
- Visit this link and create a new project.
- Create a new Credential by visiting this link
- Copy the ClientID for that Credential given by them and update it here.
- Rename the
auth-config-sample
folder toauth-config
. Theauth-config
is intentionally gitignored so that your (or my) private google credential for this project don't get hacked. Please don't remove the folder from your gitignore. - Run
npm start
to run this on your local server. This opens port3000
. - Open http://localhost:3000 to view the frontend part of the app within the browser.
- Open New Terminal Window & Run
npm run build
if you want to build the frontend up for deployment. The folder for the deployment lives in/frontend/client-server/build/
folder. We recommend it to serve it with a static server.
Streaming through OBS
- Open OBS. For Live ScreenShare Recording, in the scenes sub window, click on "+" icon and create a new scene. After that on sources sub window, click on "+" icon multiple times and add "Audio Input Capture" & "Display Capture" respectively. For other types of streaming, consult Mr. Google!
- Click on "Settings => Stream". Choose Streaming Type as custom streaming server. Set URL as
rtmp://localhost/live
. - For stream key, enter the stream id of the stream you want to play. For example, for URL
http://localhost:3000/streams/8
the stream id would be 8. Please insert that ID. Click Ok and then start streaming. Stream should be available athttp://localhost:3000/streams/:id
where id is your stream id and url to browse the same.