Skip to main content

Easy streaming using FFmpeg to YouTube Live, Periscope, Facebook Live.

Project description

.. image:: https://travis-ci.org/scivision/ffmpeg-youtube-live.svg?branch=master
:target: https://travis-ci.org/scivision/ffmpeg-youtube-live

.. image:: https://coveralls.io/repos/github/scivision/ffmpeg-youtube-live/badge.svg?branch=master
:target: https://coveralls.io/github/scivision/ffmpeg-youtube-live?branch=master

.. image:: https://img.shields.io/pypi/pyversions/youtubeliveffmpeg.svg
:target: https://pypi.python.org/pypi/youtubeliveffmpeg
:alt: Python versions (PyPI)

.. image:: https://img.shields.io/pypi/format/youtubeliveffmpeg.svg
:target: https://pypi.python.org/pypi/youtubeliveffmpeg
:alt: Distribution format (PyPI)

.. image:: https://api.codeclimate.com/v1/badges/b6557d474ec050e74629/maintainability
:target: https://codeclimate.com/github/scivision/ffmpeg-youtube-live/maintainability
:alt: Maintainability

========================
YouTube Live via FFmpeg
========================

FFmpeg can easily be used to stream to YouTube Live for streaming broadcasts.
These Python scripts compute the optimal parameters.
Should work on any OS (Mac, Linux, Windows).

:Linux: requires X11, not Wayland (choose at login)
:FFmpeg: >= 3.0 required
:Python: >= 3.6 required


.. contents::

Install
=======
::

python -m pip install -e .


Usage
=====

Specify your video/audio device if desired at the top of the script.
Find device names with commands like:

* Windows: ``ffmpeg -list_devices true -f dshow -i dummy``
* Mac: ``ffmpeg -f avfoundation -list_devices true -i ""``
* Linux: ``v4l2-ctl --list-devices``

I will describe usage for each of YouTube Live, Facebook Live, and Periscope.

YouTube Live
------------

1. `configure <https://www.youtube.com/live_dashboard>`_ YouTube Live.
2. Run Python script and chosen input will stream on YouTube Live.


Webcam
~~~~~~
Audio is included::

python Webcam2YouTubeLive.py


Screen Share
~~~~~~~~~~~~
Audio is included::

python Screenshare2YouTubeLive.py

-fps set frames/second
-res set resolution XxY of your screen
-o set origin (upper left)


several video files
~~~~~~~~~~~~~~~~~~~
Glob list of video files to stream::

python FileGlob2YouTubeLive.py path pattern

-loop optionally loop endlessly the globbed file list


stream all videos in directory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Example: all AVI videos in directory ``~/Videos``::

python FileGlob2YouTubeLive.py ~/Videos "*.avi"

stream endlessly looping videos
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Example: all AVI videos in ``~/Videos`` are endlessly looped::

python FileGlob2YouTubeLive.py ~/Videos "*.avi" -loop


stream all audio files in directory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Glob list of video files to stream.
Must include a static image (could be your logo)::

python FileGlob2YouTubeLive.py path pattern -i image

path path to where video files are
pattern e.g. "*.avi" pattern matching video files
-i filename of image to use as stream background

Example: stream all .mp3 audio under ``~/Library`` directory::

python FileGlob2YouTubeLive.py ~/Library "*.mp3" -i mylogo.jpg


Loop single video endlessly
~~~~~~~~~~~~~~~~~~~~~~~~~~~
::

FileLoop2YouTubeLive.py videofile


Screen capture to disk
----------------------
This is NOT streaming.
This script saves your screen capture to a file on your disk::

python ScreenCapture2disk.py myvid.avi


Facebook Live
-------------

1. configure your Facebook Live stream, get stream ID from `https://www.facebook.com/live/create <https://www.facebook.com/live/create>`_
2. Run Python script for Facebook with chosen input

::

python Screenshare2FacebookLive.py


Periscope
---------

1. create a new stream by EITHER:

* from phone Periscope app, go to Profile -> Settings -> Periscope Producer and see your Stream Key. The "checking source" button will go to "preview stream" once you do step #2.
* from computer web browser, go to `https://www.periscope.tv/account/producer <https://www.periscope.tv/account/producer>`_ and Create New Source.
2. Run Python script for Periscope with chosen input

::

python Screenshare2Periscope.py


I prefer using the Phone method as then the phone is a "second screen" where I can see if the stream is lagging, and if I "leave broadcast" and come back in, I can comment from my phone etc.

Notes
=====

* FFmpeg Ubuntu `PPA <https://launchpad.net/~mc3man/+archive/ubuntu/trusty-media>`_
* `Reference webpage <https://www.scivision.co/youtube-live-ffmpeg-livestream/>`_
* `Test videos for looping/globbing <http://www.divx.com/en/devices/profiles/video>`_

FFmpeg References
-----------------

* `streaming <https://trac.ffmpeg.org/wiki/EncodingForStreamingSites>`_
* `webcam <https://trac.ffmpeg.org/wiki/Capture/Webcam>`_

Windows
~~~~~~~
* `DirectShow <https://trac.ffmpeg.org/wiki/DirectShow>`_ device selection
* DirectShow `examples <https://ffmpeg.org/ffmpeg-devices.html#Examples-4>`_

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyLivestream-1.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyLivestream-1.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file PyLivestream-1.1.0.tar.gz.

File metadata

  • Download URL: PyLivestream-1.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyLivestream-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e1e733fbd53bc1eebc37d7e8d73b0e120b3e712113522c7fe41d5a982f18fef6
MD5 e981b6a332d143c79a288a9089e994aa
BLAKE2b-256 04d807ddeb61a679c37128270d8f3888284df9ebc509a88d69c58a87b4e4b715

See more details on using hashes here.

File details

Details for the file PyLivestream-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for PyLivestream-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b724e3b10fa49f595d09ba7eb256dae58baedfc5f1416b5b0e82529014081c9
MD5 2e01de565fbb6413715088a15c085674
BLAKE2b-256 4aef86ea66680af3dcca1c2f60958a3cfcf1948ebcde331035b2c2329796c9ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page