Passed
Push — master ( 671d58...c8c24d )
by Amin
03:46
created

hls_live   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A progress() 0 2 1
A main() 0 16 1
1
"""
2
examples.hls.hls_live
3
~~~~~~~~~~~~
4
5
Upload HlS files to a server
6
7
8
:copyright: (c) 2020 by Amin Yazdanpanah.
9
:website: https://www.aminyazdanpanah.com
10
:email: [email protected]
11
:license: MIT, see LICENSE for more details.
12
"""
13
14
import argparse
15
import sys
16
import logging
17
18
import ffmpeg_streaming
19
20
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
21
22
23
def progress(per, ffmpeg):
24
    sys.stdout.write("\n%s%% - %s" % (per, ffmpeg))
25
26
27
def main():
28
    parser = argparse.ArgumentParser()
29
    parser.add_argument('-i', '--input', required=True,
30
                        help='The path to the video file(or a supported resource) (required).')
31
    parser.add_argument('-m', '--master_playlist', required=True,
32
                        help='The path to write the master playlist (required).')
33
    parser.add_argument('-o', '--output', required=True,
34
                        help='A URL(or a supported resource e.x. http://website.com/live-out.m3u8) to upload files.')
35
    args = parser.parse_args()
36
37
    (
38
        ffmpeg_streaming
39
            .hls(args.input, master_playlist_path=args.master_playlist)
40
            .format('libx264')
41
            .auto_rep()
42
            .package(args.output, progress=progress)
43
    )
44
45
46
if __name__ == "__main__":
47
    sys.exit(main())
48