forked from scivision/PyLivestream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoop.py
More file actions
executable file
·42 lines (33 loc) · 1.39 KB
/
Loop.py
File metadata and controls
executable file
·42 lines (33 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
"""
LIVE STREAM using FFMPEG -- Looping input file endlessly
NOTE: for audio files,
use FileGlob2Livestream.py with options `-image myimg.jpg -loop`
https://www.scivision.dev/youtube-live-ffmpeg-livestream/
https://support.google.com/youtube/answer/2853702
"""
from typing import List
import pylivestream as pls
import signal
from argparse import ArgumentParser
def main():
signal.signal(signal.SIGINT, signal.SIG_DFL)
p = ArgumentParser(description="Livestream a single looped input file")
p.add_argument('infn', help='file to stream, looping endlessly.')
p.add_argument('websites', help='site to stream, e.g. localhost youtube periscope facebook twitch', nargs='+')
p.add_argument('-i', '--ini', help='*.ini file with stream parameters')
p.add_argument('-y', '--yes', help='no confirmation dialog', action='store_true')
p.add_argument('-t', '--timeout', help='stop streaming after --timeout seconds', type=int)
P = p.parse_args()
S = pls.FileIn(P.ini, P.websites, infn=P.infn, loop=True, yes=P.yes, timeout=P.timeout)
sites: List[str] = list(S.streams.keys())
# %% Go live
if P.yes:
print(f'going live on {sites} looping file {P.infn}')
else:
input(f"Press Enter to go live on {sites},"
f"looping file {P.infn}")
print('Or Ctrl C to abort.')
S.golive()
if __name__ == '__main__':
main()