Javascript FFMPEG Project to Live Stream to Facebook Live Using PhantomJS in Browser Using HTML5

 

 

facebook-live-video

Stream a website with phantomjs to Facebook Live via ffmpeg (video) and collect Facebook reactions

Resources

Overview: https://developers.facebook.com/docs/videos/live-video API Doc: https://developers.facebook.com/docs/graph-api/reference/live-video/#Overview

If you need help with the setup or if you want to use it for commercial please text me office@pholly.at

Installation

I installed everything on Ubuntu 16.04, for other versions check docs how to install.

FFmpeg

NodeJS

Install latest NodeJS on your server – you can do it 😉

phantomjs

I used the self-contained binary. Check http://phantomjs.org/download.html

Usage

  1. Create Facebook App (if you dont already have one) >> FB App
  2. Get Facebook User Access Token with this app and your user >> Explorer Important: User needs publish_actions permission
  3. Go to your cli and type in:

It creates a Live Video (via FB API) and streams the index.html inside the /website folder. Modify this files for your needs. 😉

The video is set to privacy:SELF, only you can see it.

Check your Facebook wall. 😉

Configuration

Go to src/index.js and checkout the function start() there is another function call:

modify the options object to configure your stream see: https://developers.facebook.com/docs/graph-api/reference/live-video/#Overview for possible parameters.

Privacy parameter:

Customize your own settings. You can find privacy settings here: (search for privacy) https://developers.facebook.com/docs/graph-api/reference/v2.8/post


Modify the files in /website how you like. You can also stream another website by changing the url in the index.js file

Debug

If you have problems with your installation, check the stream.log:

If you just want to fake increase the reaction counter use :

It will increase the numbers every 2 sec by a random number.


If your phantomjs script stuck (sometimes it doesnt stop after a ctrl + c) use to kill every process:

FB API wrapper – /src/fb.js

I build a little wrapper for the FB API in /src/fb.js which is also available from the cli.

Todo

  •  keep ffmpeg stream at 30 fps
  •  configure streaming video with cli params, e.g. stringified JSON
  •  stop process after ~4h (max. fb live video length)
  •  kill phantomjs process properly after the stream ends or main process exits
  •  optimize quality (ffmpeg)

 

 

 

 

https://github.com/phips28/facebook-live-video

 

 

Leave a Reply