Giter VIP home page Giter VIP logo

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 ;)

facebook-live-video's People

Contributors

flaviolivolsi avatar phips28 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facebook-live-video's Issues

Not staying at 30fps

I noticed that the "keep ffmpeg stream at 30 fps" issue was marked as done in the readme, but I am seeing the same behavior where it starts at 30 and then drops down.

FWIW, I also noticed that if I include more images in the web site, it drops down much lower, to around 2 or 3 fps.

What was the fix for that? Is it in the master branch? Are you really able to hold steady at 30 fps?

Privacy issue

Line 41 of index.js includes access permissions for 2 FB profile IDs, one of which links back to the authors account. Haven't looked into it enough but this seems like if nothing is provided it will by default allow access from the author of the repos account in some way?

The live video has ended.

I just tried this. Very cool!

I am running into an issue where on starting the live stream, what I see in my feed is "This live video has ended." I tried it on a $5/mo Digital Ocean droplet, and thought maybe the server was too wimpy to keep up, so upped it to a $20/mo server but am seeing the same thing.

However when I ctrl-c to kill the node process, and refresh my feed, I'll be able to playback the historical live video that has previously said it had "ended."

A snapshot of what I see in the stream.log looks like this:

Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 10 fps, 1k tbn, 10 tbc
Metadata:
encoder : Lavc56.60.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
frame= 1905 fps=8.3 q=25.0 size= 695kB time=00:03:05.60 bitrate= 30.7kbits/s

Any idea what could cause this?

Facebook post now showing

Hey

I can't really figure out what's wrong.
I'm using npm start [token] false friends.

Seems like everything's right.
It outputs facebook video object & phantomjs's command with ffmpeg.
But.. I cannot see any new posts on my wall.

Any idea?

The Video not collect all Reactions

As you know we have more than the "public result" from every post..
some time you see the Reactions = 500
but we have more than that.. We have 200 too from share ..
you can found that from "Publishing Tools" Tab in Facebook.
can we collect this numbers too ?

Thank you

Low FPS

What server is needed to run this setup?
I'm currently running it on an Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz but I'm only getting around 15fps.

I even tried http://www.initializr.com/try as a target which is basically empty.
There it starts at 150 FPS and goes down to 15 after ~20 seconds.

Is there anything I could do to keep it at 30 fps?

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.