Giter Site home page Giter Site logo

flaviolivolsi / facebook-live-video Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phips28/facebook-live-video

1.0 3.0 0.0 217 KB

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

License: MIT License

JavaScript 57.72% HTML 42.28%

facebook-live-video's Introduction

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 [email protected]

Installation

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

FFmpeg

sudo apt-get update
sudo apt-get 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

sudo apt-get update
sudo apt-get install build-essential g++ flex bison gperf ruby perl \
  libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \
  libpng-dev libjpeg-dev python libx11-dev libxext-dev
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar -xf phantomjs-2.1.1-linux-x86_64.tar.bz2
rm -rf phantomjs-2.1.1-linux-x86_64.tar.bz2
sudo cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/
rm -R phantomjs-2.1.1-linux-x86_64

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:
npm start [accessToken] [debug] [privacy]

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:

fb.startLiveVideo({
    accessToken,
    title: 'First test video - ' + new Date(),
    // privacy: "{'value':'FRIENDS'}"
})

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:

npm start [accessToken] false public
npm start [accessToken] false friends
npm start [accessToken] false friends_of_friends

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:

tail -f stream.log

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

npm start [accessToken] [debug]
=> npm start [accessToken] true

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:

pkill -f  phantomjs

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.

node src/fb.js [accessToken] [action] [postId]
node src/fb.js [accessToken] get 1234
node src/fb.js [accessToken] end 1234
node src/fb.js [accessToken] delete 1234
node src/fb.js [accessToken] get_all
# CAREFUL: deletes all videos! Only do this on a testaccount. I am not resposible for your deleted videos! # node src/fb.js [accessToken] delete_all

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)

Contribution

Please help me to improve this toolset for Facebook Live Videos. Feedback and PR's are very welcome! :)

Happy hacking ;)

Hey again Live Video ๐Ÿ˜Ž- yesterday I received a lot of messages how I stream the video and collect the reactions. It was a little bit hacky yesterday

facebook-live-video's People

Contributors

phips28 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.