import os.path as osp def file_parse(file,video): """ 根据视频名返回关键信息 file: 处理视频文件 video: 源视频文件 return: 返回源视频以及处理后视频起止帧及索引 """ file = osp.basename(file) file_information = file.split(".")[0] video = video.split('/')[-1] video_name = video.split(".")[0] file_information = file_information.split("_") file_name = file_information[0] + "_" + file_information[1] start_frame_origin = file_information[2] end_frame_origin = file_information[3] idx_origin = file_information[4] start_frame_single = file_information[5] end_file_sigle = file_information[6] idx_sigle = file_information[7] result = [] if file_name == video_name: result = [start_frame_origin, end_frame_origin, idx_origin,start_frame_single,end_file_sigle,idx_sigle] else: print("enter filename does not match the video name!") # print(result) return result if __name__ == "__main__": file = "0711-7_5_291_302_0_3_10_0.avi" video = "0711-7_5.mp4" result = file_parse(file,video) """用于查看返回关键值信息""" # if result : # start_frame_o,end_frame_o,idx_o,start_frame_s,end_frame_s,idx_s = result # print("start_frame_origin:",start_frame_o) # print('end_frame_origin:',end_frame_o) # print("idx_origin:",idx_o) # print("start_frame_sigle:",start_frame_s) # print("end_frame_sigle:", end_frame_s) # print("idx_sigle:", idx_s) # else: # pass