-
Notifications
You must be signed in to change notification settings - Fork 10
/
cmds_ffmpeg.py
67 lines (56 loc) · 1.8 KB
/
cmds_ffmpeg.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
from mylib.ffmpeg_alpha import FFmpegArgsList
from oldezpykitext.appkit import *
from mylib import ffmpeg_alpha
__logger__ = logging.get_logger(__name__)
ap = argparse.ArgumentParserWrapper()
@ap.sub()
@ap.map()
def test():
print(ap.extra)
@ap.sub()
def concat_seg_in_folder():
for dp in os.clpb.get_path():
if not os.path_isdir(dp):
return
seg_l = [os.join_path(dp, f) for f in sorted(os.listdir(dp))]
if not seg_l:
return
seg_ext = '.mkv'
dst = f'{dp} +{{seg}}{seg_ext}'
ff = ffmpeg_alpha.FFmpegRunnerAlpha()
ff.concat(seg_l, dst, output_args=ap.extra)
@ap.sub()
@ap.arg('frame_size_and_rate', help='{width}x{height}@{fps}')
@ap.map('frame_size_and_rate')
def concat_frame_in_folder(frame_size_and_rate):
w, h, r = re.search(r'(\d+)x(\d+)@(\d+)', frame_size_and_rate).groups()
a = FFmpegArgsList(
vf=f'scale={w}:{h}:force_original_aspect_ratio=1,pad={w}:{h}:(ow-iw)/2:(oh-ih)/2',
c__v='hevc', crf=22, pix_fmt='yuv420p',
# x265_params='log-level=error:aq-mode=3',
x265_params='aq-mode=3',
x264opts='aq-mode=3',
)
for dp in os.clpb.get_path():
if not os.path_isdir(dp):
return
seg_l = [os.join_path(dp, f) for f in sorted(os.listdir(dp))]
if not seg_l:
return
seg_ext = '.mkv'
dst = f'{dp}{seg_ext}'
ff = ffmpeg_alpha.FFmpegRunnerAlpha()
ff.concat(
seg_l, dst,
input_args=['-r', str(r)],
output_args=a + ap.extra,
)
def main():
logging.init_root(fmt=logging.FMT_MESSAGE_ONLY)
logging.set_root_level('INFO')
# logging.set_root_level('DEBUG')
ap.parse(catch_unknown_args=True)
ap.run()
if __name__ == '__main__':
main()