From d959e573d5bcf6f3f4878c809166d29bbe49da63 Mon Sep 17 00:00:00 2001 From: JunHo Kim Date: Tue, 11 Jan 2022 15:01:20 +0900 Subject: [PATCH] TODO : asynch process control --- pillar_detection.py | 12 +++++++++--- pillar_detection_core.py | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pillar_detection.py b/pillar_detection.py index 1a14428..f70a769 100644 --- a/pillar_detection.py +++ b/pillar_detection.py @@ -7,7 +7,7 @@ parser.add_argument("-i", "--input_dir", default="./input", help="Input source v parser.add_argument("-o", "--output_dir", default="./out", help="Output vid directory") # ffmpeg encoding option -parser.add_argument("-c", "--crf", default=20, type=int, help="set crf level") +parser.add_argument("-c", "--crf", default=18, type=int, help="set crf level") parser.add_argument("-fps", '-fr', "--frame_rate", default=-1, type=float, help="if minus value, same fps as input") parser.add_argument("-uhd", "--uhd_output", default=False, action="store_true", help="set output resolution to 3840:2160") parser.add_argument("-lb", "--add_letterbox", default=False, action="store_true", help="add letterbox to make 16:9 ratio") @@ -50,6 +50,13 @@ def main(): print("[INFO]\t Ouput dir :", output_dir) print("") + # for specific file process (use "/" not "\") + # input_dir = "Y:/Pixtree-NDA/SME/20211209_3차우선순위/output-20211222/source/" + # input_list = [ + # os.path.join(input_dir, "01. 샤이니_누난너무예뻐 MV_xfm_dec_ver3_edit.mov") + # ] + + crop_cfg = VideoCropCfg() for vid_index, fpath in enumerate(input_list): vid_name = os.path.basename(fpath)[:-4] vid_num = len(input_list) @@ -59,7 +66,7 @@ def main(): print("[INFO]\t Log dir :", logs_dir) # init crop configuration class - crop_cfg = VideoCropCfg() + # crop_cfg = VideoCropCfg() crop_cfg.vid_name = vid_name # Read log file if exist @@ -80,7 +87,6 @@ def main(): cropPos = [crop_cfg.frame_width, crop_cfg.frame_height, 0, 0] cropPos = adjustCropArea(cropPos, crop_cfg.frame_width, crop_cfg.frame_height) - print(cropPos) cv2.namedWindow(f'{vid_name}', cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # Display crop size control UI diff --git a/pillar_detection_core.py b/pillar_detection_core.py index 57650ab..7db595d 100644 --- a/pillar_detection_core.py +++ b/pillar_detection_core.py @@ -284,6 +284,10 @@ def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_pr vid_index += 1 start_time = getTime() + ''' + TODO : count running ffmpeg process aysnch. + ''' + running_process = 0 if manual_mode: # Manual Mode (always cropping one by one) # Hold process when encoding last video @@ -303,11 +307,13 @@ def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_pr Start Time : {getTime('string')}") p = subprocess.Popen(ffmpeg_command + ' -stats', shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') ffmpeg_process.append(p.pid) + # print(ffmpeg_process) while p.poll() is None: displayRemainTime(vid_duration, p.stderr, start_time) else : p = subprocess.Popen(ffmpeg_command, shell=False) ffmpeg_process.append(p.pid) + running_process += 1 retCode = 0