TODO : asynch process control
This commit is contained in:
1 parent
78a08269a1
commit
d959e573d5
2 files changed
+15
-3
No files matched your search
+9
-3
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user