Total Complexity | 2 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 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 |