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

stream_to_file.main()   A

Complexity

Conditions 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nop 0
dl 0
loc 13
rs 9.85
c 0
b 0
f 0
1
"""
2
examples.conversion.stream_to_file
3
~~~~~~~~~~~~
4
5
Convert a stream(DASH or HLS) to File
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='A URL to a stream manifest (HLS or DASH) (required).')
31
    parser.add_argument('-o', '--output', default=None,
32
                        help='The output to write a file. e.x. /var/www/media/new-video.mp4')
33
    args = parser.parse_args()
34
35
    (
36
        ffmpeg_streaming
37
            .stream2file(args.input)
38
            .format('libx264')
39
            .save(args.output, progress=progress)
40
    )
41
42
43
if __name__ == "__main__":
44
    sys.exit(main())
45