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 68 69 70 71 72 73 74 75 76 77 78
| import imageio, os import moviepy.editor as mp
def create_gif(image_list, gif_name, duration): frames = [] for image_name in image_list: frames.append(imageio.imread(image_name)) imageio.mimsave(gif_name, frames, 'GIF', duration=duration) return
def main(): postfix = '.jpg' postfix1 = 'Global_SSS_All1.gif' prefix = ['2020_01170', '2020_02170', '2020_03170', '2020_04170', '2020_05170', '2020_06170', '2020_07170', '2020_08170', '2020_09170', '2020_10170', '2020_11170', '2020_12170', '2021_01170', '2021_02170', '2021_03170', '2021_04170', '2021_05170', '2021_06170', '2021_07170', '2021_08170', '2021_09170', '2020_01160', '2020_02160', '2020_03160', '2020_04160', '2020_05160', '2020_06160', '2020_07160', '2020_08160', '2020_09160', '2020_10160', '2020_11160', '2020_12160', '2021_01160', '2021_02160', '2021_03160', '2021_04160', '2021_05160', '2021_06160', '2021_07160', '2021_08160', '2021_09160', '2020_01150', '2020_02150', '2020_03150', '2020_04150', '2020_05150', '2020_06150', '2020_07150', '2020_08150', '2020_09150', '2020_10150', '2020_11150', '2020_12150', '2021_01150', '2021_02150', '2021_03150', '2021_04150', '2021_05150', '2021_06150', '2021_07150', '2021_08150', '2021_09150', '2020_01140', '2020_02140', '2020_03140', '2020_04140', '2020_05140', '2020_06140', '2020_07140', '2020_08140', '2020_09140', '2020_10140', '2020_11140', '2020_12140', '2021_01140', '2021_02140', '2021_03140', '2021_04140', '2021_05140', '2021_06140', '2021_07140', '2021_08140', '2021_09140', '2020_01130', '2020_02130', '2020_03130', '2020_04130', '2020_05130', '2020_06130', '2020_07130', '2020_08130', '2020_09130', '2020_10130', '2020_11130', '2020_12130', '2021_01130', '2021_02130', '2021_03130', '2021_04130', '2021_05130', '2021_06130', '2021_07130', '2021_08130', '2021_09130', '2020_01120', '2020_02120', '2020_03120', '2020_04120', '2020_05120', '2020_06120', '2020_07120', '2020_08120', '2020_09120', '2020_10120', '2020_11120', '2020_12120', '2021_01120', '2021_02120', '2021_03120', '2021_04120', '2021_05120', '2021_06120', '2021_07120', '2021_08120', '2021_09120', '2020_01110', '2020_02110', '2020_03110', '2020_04110', '2020_05110', '2020_06110', '2020_07110', '2020_08110', '2020_09110', '2020_10110', '2020_11110', '2020_12110', '2021_01110', '2021_02110', '2021_03110', '2021_04110', '2021_05110', '2021_06110', '2021_07110', '2021_08110', '2021_09110', '2020_01100', '2020_02100', '2020_03100', '2020_04100', '2020_05100', '2020_06100', '2020_07100', '2020_08100', '2020_09100', '2020_10100', '2020_11100', '2020_12100', '2021_01100', '2021_02100', '2021_03100', '2021_04100', '2021_05100', '2021_06100', '2021_07100', '2021_08100', '2021_09100', '2020_0190', '2020_0290', '2020_0390', '2020_0490', '2020_0590', '2020_0690', '2020_0790', '2020_0890', '2020_0990', '2020_1090', '2020_1190', '2020_1290', '2021_0190', '2021_0290', '2021_0390', '2021_0490', '2021_0590', '2021_0690', '2021_0790', '2021_0890', '2021_0990', '2020_0180', '2020_0280', '2020_0380', '2020_0480', '2020_0580', '2020_0680', '2020_0780', '2020_0880', '2020_0980', '2020_1080', '2020_1180', '2020_1280', '2021_0180', '2021_0280', '2021_0380', '2021_0480', '2021_0580', '2021_0680', '2021_0780', '2021_0880', '2021_0980', '2020_0170', '2020_0270', '2020_0370', '2020_0470', '2020_0570', '2020_0670', '2020_0770', '2020_0870', '2020_0970', '2020_1070', '2020_1170', '2020_1270', '2021_0170', '2021_0270', '2021_0370', '2021_0470', '2021_0570', '2021_0670', '2021_0770', '2021_0870', '2021_0970', '2020_0160', '2020_0260', '2020_0360', '2020_0460', '2020_0560', '2020_0660', '2020_0760', '2020_0860', '2020_0960', '2020_1060', '2020_1160', '2020_1260', '2021_0160', '2021_0260', '2021_0360', '2021_0460', '2021_0560', '2021_0660', '2021_0760', '2021_0860', '2021_0960', '2020_0150', '2020_0250', '2020_0350', '2020_0450', '2020_0550', '2020_0650', '2020_0750', '2020_0850', '2020_0950', '2020_1050', '2020_1150', '2020_1250', '2021_0150', '2021_0250', '2021_0350', '2021_0450', '2021_0550', '2021_0650', '2021_0750', '2021_0850', '2021_0950', '2020_0140', '2020_0240', '2020_0340', '2020_0440', '2020_0540', '2020_0640', '2020_0740', '2020_0840', '2020_0940', '2020_1040', '2020_1140', '2020_1240', '2021_0140', '2021_0240', '2021_0340', '2021_0440', '2021_0540', '2021_0640', '2021_0740', '2021_0840', '2021_0940', '2020_0130', '2020_0230', '2020_0330', '2020_0430', '2020_0530', '2020_0630', '2020_0730', '2020_0830', '2020_0930', '2020_1030', '2020_1130', '2020_1230', '2021_0130', '2021_0230', '2021_0330', '2021_0430', '2021_0530', '2021_0630', '2021_0730', '2021_0830', '2021_0930', '2020_0120', '2020_0220', '2020_0320', '2020_0420', '2020_0520', '2020_0620', '2020_0720', '2020_0820', '2020_0920', '2020_1020', '2020_1120', '2020_1220', '2021_0120', '2021_0220', '2021_0320', '2021_0420', '2021_0520', '2021_0620', '2021_0720', '2021_0820', '2021_0920', '2020_0110.', '2020_0210.', '2020_0310.', '2020_0410.', '2020_0510.', '2020_0610.', '2020_0710.', '2020_0810.', '2020_0910.', '2020_1010.', '2020_1110.', '2020_1210.', '2021_0110.', '2021_0210.', '2021_0310.', '2021_0410.', '2021_0510.', '2021_0610.', '2021_0710.', '2021_0810.', '2021_0910.', '2020_010', '2020_020', '2020_030', '2020_040', '2020_050', '2020_060', '2020_070', '2020_080', '2020_090', '2020_100', '2020_110', '2020_120', '2021_010', '2021_020', '2021_030', '2021_040', '2021_050', '2021_060', '2021_070', '2021_080', '2021_090', '2020_01-10.', '2020_02-10.', '2020_03-10.', '2020_04-10.', '2020_05-10.', '2020_06-10.', '2020_07-10.', '2020_08-10.', '2020_09-10.', '2020_10-10.', '2020_11-10.', '2020_12-10.', '2021_01-10.', '2021_02-10.', '2021_03-10.', '2021_04-10.', '2021_05-10.', '2021_06-10.', '2021_07-10.', '2021_08-10.', '2021_09-10.', '2020_01-20', '2020_02-20', '2020_03-20', '2020_04-20', '2020_05-20', '2020_06-20', '2020_07-20', '2020_08-20', '2020_09-20', '2020_10-20', '2020_11-20', '2020_12-20', '2021_01-20', '2021_02-20', '2021_03-20', '2021_04-20', '2021_05-20', '2021_06-20', '2021_07-20', '2021_08-20', '2021_09-20', '2020_01-30', '2020_02-30', '2020_03-30', '2020_04-30', '2020_05-30', '2020_06-30', '2020_07-30', '2020_08-30', '2020_09-30', '2020_10-30', '2020_11-30', '2020_12-30', '2021_01-30', '2021_02-30', '2021_03-30', '2021_04-30', '2021_05-30', '2021_06-30', '2021_07-30', '2021_08-30', '2021_09-30', '2020_01-40', '2020_02-40', '2020_03-40', '2020_04-40', '2020_05-40', '2020_06-40', '2020_07-40', '2020_08-40', '2020_09-40', '2020_10-40', '2020_11-40', '2020_12-40', '2021_01-40', '2021_02-40', '2021_03-40', '2021_04-40', '2021_05-40', '2021_06-40', '2021_07-40', '2021_08-40', '2021_09-40', '2020_01-50', '2020_02-50', '2020_03-50', '2020_04-50', '2020_05-50', '2020_06-50', '2020_07-50', '2020_08-50', '2020_09-50', '2020_10-50', '2020_11-50', '2020_12-50', '2021_01-50', '2021_02-50', '2021_03-50', '2021_04-50', '2021_05-50', '2021_06-50', '2021_07-50', '2021_08-50', '2021_09-50', '2020_01-60', '2020_02-60', '2020_03-60', '2020_04-60', '2020_05-60', '2020_06-60', '2020_07-60', '2020_08-60', '2020_09-60', '2020_10-60', '2020_11-60', '2020_12-60', '2021_01-60', '2021_02-60', '2021_03-60', '2021_04-60', '2021_05-60', '2021_06-60', '2021_07-60', '2021_08-60', '2021_09-60', '2020_01-70', '2020_02-70', '2020_03-70', '2020_04-70', '2020_05-70', '2020_06-70', '2020_07-70', '2020_08-70', '2020_09-70', '2020_10-70', '2020_11-70', '2020_12-70', '2021_01-70', '2021_02-70', '2021_03-70', '2021_04-70', '2021_05-70', '2021_06-70', '2021_07-70', '2021_08-70', '2021_09-70', '2020_01-80', '2020_02-80', '2020_03-80', '2020_04-80', '2020_05-80', '2020_06-80', '2020_07-80', '2020_08-80', '2020_09-80', '2020_10-80', '2020_11-80', '2020_12-80', '2021_01-80', '2021_02-80', '2021_03-80', '2021_04-80', '2021_05-80', '2021_06-80', '2021_07-80', '2021_08-80', '2021_09-80', '2020_01-90', '2020_02-90', '2020_03-90', '2020_04-90', '2020_05-90', '2020_06-90', '2020_07-90', '2020_08-90', '2020_09-90', '2020_10-90', '2020_11-90', '2020_12-90', '2021_01-90', '2021_02-90', '2021_03-90', '2021_04-90', '2021_05-90', '2021_06-90', '2021_07-90', '2021_08-90', '2021_09-90', '2020_01-100', '2020_02-100', '2020_03-100', '2020_04-100', '2020_05-100', '2020_06-100', '2020_07-100', '2020_08-100', '2020_09-100', '2020_10-100', '2020_11-100', '2020_12-100', '2021_01-100', '2021_02-100', '2021_03-100', '2021_04-100', '2021_05-100', '2021_06-100', '2021_07-100', '2021_08-100', '2021_09-100', '2020_01-110', '2020_02-110', '2020_03-110', '2020_04-110', '2020_05-110', '2020_06-110', '2020_07-110', '2020_08-110', '2020_09-110', '2020_10-110', '2020_11-110', '2020_12-110', '2021_01-110', '2021_02-110', '2021_03-110', '2021_04-110', '2021_05-110', '2021_06-110', '2021_07-110', '2021_08-110', '2021_09-110', '2020_01-120', '2020_02-120', '2020_03-120', '2020_04-120', '2020_05-120', '2020_06-120', '2020_07-120', '2020_08-120', '2020_09-120', '2020_10-120', '2020_11-120', '2020_12-120', '2021_01-120', '2021_02-120', '2021_03-120', '2021_04-120', '2021_05-120', '2021_06-120', '2021_07-120', '2021_08-120', '2021_09-120', '2020_01-130', '2020_02-130', '2020_03-130', '2020_04-130', '2020_05-130', '2020_06-130', '2020_07-130', '2020_08-130', '2020_09-130', '2020_10-130', '2020_11-130', '2020_12-130', '2021_01-130', '2021_02-130', '2021_03-130', '2021_04-130', '2021_05-130', '2021_06-130', '2021_07-130', '2021_08-130', '2021_09-130', '2020_01-140', '2020_02-140', '2020_03-140', '2020_04-140', '2020_05-140', '2020_06-140', '2020_07-140', '2020_08-140', '2020_09-140', '2020_10-140', '2020_11-140', '2020_12-140', '2021_01-140', '2021_02-140', '2021_03-140', '2021_04-140', '2021_05-140', '2021_06-140', '2021_07-140', '2021_08-140', '2021_09-140', '2020_01-150', '2020_02-150', '2020_03-150', '2020_04-150', '2020_05-150', '2020_06-150', '2020_07-150', '2020_08-150', '2020_09-150', '2020_10-150', '2020_11-150', '2020_12-150', '2021_01-150', '2021_02-150', '2021_03-150', '2021_04-150', '2021_05-150', '2021_06-150', '2021_07-150', '2021_08-150', '2021_09-150', '2020_01-160', '2020_02-160', '2020_03-160', '2020_04-160', '2020_05-160', '2020_06-160', '2020_07-160', '2020_08-160', '2020_09-160', '2020_10-160', '2020_11-160', '2020_12-160', '2021_01-160', '2021_02-160', '2021_03-160', '2021_04-160', '2021_05-160', '2021_06-160', '2021_07-160', '2021_08-160', '2021_09-160', '2020_01-170', '2020_02-170', '2020_03-170', '2020_04-170', '2020_05-170', '2020_06-170', '2020_07-170', '2020_08-170', '2020_09-170', '2020_10-170', '2020_11-170', '2020_12-170', '2021_01-170', '2021_02-170', '2021_03-170', '2021_04-170', '2021_05-170', '2021_06-170', '2021_07-170', '2021_08-170', '2021_09-170', '2020_01-180', '2020_02-180', '2020_03-180', '2020_04-180', '2020_05-180', '2020_06-180', '2020_07-180', '2020_08-180', '2020_09-180', '2020_10-180', '2020_11-180', '2020_12-180', '2021_01-180', '2021_02-180', '2021_03-180', '2021_04-180', '2021_05-180', '2021_06-180', '2021_07-180', '2021_08-180', '2021_09-180'] input_directory = '/Users/leo/Desktop/MarineTechTest8/Results/Img2/' output_directory = '/Users/leo/Desktop/' if not os.path.exists(output_directory): os.mkdir(output_directory) file_list = os.listdir(input_directory) path_list = [] sum = 0 for k in prefix: for i in file_list: if i.endswith(postfix) and i[0:].startswith(k): sum += 1 print(sum, k, i) file_path = input_directory + i path_list.append(file_path)
print(path_list)
gif_path = output_directory + postfix1 duration = 0.02 create_gif(path_list, gif_path, duration)
if __name__ == '__main__': main() vfc = mp.VideoFileClip("/Users/leo/Desktop/Global_SSS_All1.gif") vfc.write_videofile("/Users/leo/Desktop/Global_SSS_All1.mp4")
|