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

dash_live.main()   A

Complexity

Conditions 1

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nop 0
dl 0
loc 14
rs 9.8
c 0
b 0
f 0
1
"""
2
examples.dash.dash_live
3
~~~~~~~~~~~~
4
5
Upload DASH streams and manifest 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
21
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
22
23
24
def progress(per, ffmpeg):
25
    sys.stdout.write("\n%s%% - %s" % (per, ffmpeg))
26
27
28
def main():
29
    parser = argparse.ArgumentParser()
30
    parser.add_argument('-i', '--input', required=True,
31
                        help='The path to the video file(or a supported resource) (required).')
32
    parser.add_argument('-o', '--output', required=True,
33
                        help='A URL(or a supported resource e.x. http://website.com/live-out.mpd) to upload files.')
34
    args = parser.parse_args()
35
36
    (
37
        ffmpeg_streaming
38
            .dash(args.input, adaption='"id=0,streams=v id=1,streams=a"')
39
            .format('libx265')
40
            .auto_rep()
41
            .live(args.output, progress=progress)
42
    )
43
44
45
if __name__ == "__main__":
46
    sys.exit(main())
47