Skip to content

Commit

Permalink
refacor Loop OOP
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jan 30, 2018
1 parent 940514e commit e4d2dbe
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 45 deletions.
22 changes: 22 additions & 0 deletions FileLoop.py
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""
LIVE STREAM using FFMPEG -- Looping input file endlessly
https://www.scivision.co/youtube-live-ffmpeg-livestream/
https://support.google.com/youtube/answer/2853702
"""
import PyLivestream

if __name__ == '__main__':
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)

from argparse import ArgumentParser
p = ArgumentParser()
p.add_argument('ini',help='*.ini file with stream parameters')
p.add_argument('site',help='site to stream to [youtube,periscope,facebook]')
p.add_argument('infn',help='file to stream, looping endlessly.')
p = p.parse_args()


PyLivestream.Loop(p.ini,p.site,p.infn)
27 changes: 0 additions & 27 deletions FileLoop2YouTubeLive.py

This file was deleted.

19 changes: 17 additions & 2 deletions PyLivestream/__init__.py
Expand Up @@ -187,8 +187,8 @@ def webcam(self) -> list:


def filein(self) -> list:
"""audio file input, streaming audio with static image"""
fn = Path(self.audiofn).expanduser()
"""stream input file (video, or audio + image)"""
fn = Path(self.loop).expanduser()

if self.image:
vid1 = ['-loop','1']
Expand Down Expand Up @@ -345,6 +345,21 @@ def __init__(self, ini:Path, site:str):
stream.golive()


class Loop(Livestream):

def __init__(self, ini:Path, site:str, infn:Path):

site = site.lower()
vidsource = 'file'
ini=Path(ini).expanduser()
image = False
loop = infn

stream = Livestream(ini,site,vidsource,image,loop)

stream.golive()



class Save(Stream):

Expand Down
34 changes: 19 additions & 15 deletions README.rst
Expand Up @@ -110,49 +110,53 @@ Audio is included::
python Screenshare.py stream.ini site


File Input
----------


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

FileLoop.py stream.ini site videofile


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

python FileGlob2YouTubeLive.py stream.ini path pattern
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 stream.ini ~/Videos "*.avi"
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 stream.ini path pattern -i image
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 stream.ini ~/Library "*.mp3" -i mylogo.jpg


Loop single video endlessly
---------------------------
::

FileLoop2YouTubeLive.py stream.ini videofile
python FileGlob2YouTubeLive.py ~/Library "*.mp3" -i mylogo.jpg


Screen capture to disk
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -4,7 +4,7 @@

setup(name='PyLivestream',
packages=find_packages(),
version = '1.1.1',
version = '1.2.0',
author='Michael Hirsch, Ph.D.',
url='https://github.com/scivision/PyLivestream',
description='Easy streaming using FFmpeg to YouTube Live, Periscope, Facebook Live.',
Expand Down
6 changes: 6 additions & 0 deletions tests/Test.py
Expand Up @@ -22,6 +22,12 @@ def test_webcam():
PyLivestream.Webcam(inifn,'facebook')


def test_loop():
PyLivestream.Loop(inifn,'periscope')

PyLivestream.Loop(inifn,'youtube')

PyLivestream.Loop(inifn,'facebook')

if __name__ == '__main__':
test_screenshare()
Expand Down

0 comments on commit e4d2dbe

Please sign in to comment.