为下面的python3代码增加多视频格式支持import osimport reimport subprocessimport openpyxlimport mathfrom openpyxlstyles import Font PatternFill Alignment# 需要处理的视频文件夹video_folder = home115up# 输出Excel文件夹路径excel_folder =
为了增加多视频格式支持,可以在使用mediainfo获取视频信息时,增加对其他格式的支持。需要根据不同视频格式,调整mediainfo命令中的参数和输出格式。例如:
- 增加对.mkv格式的支持:
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String%|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
改为:
if video_file.endswith(".mkv"):
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String% %/s|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
else:
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String%|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
- 增加对.avi格式的支持:
if video_file.endswith(".mkv"):
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String% %/s|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
elif video_file.endswith(".avi"):
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String%|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
else:
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String%|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
- 增加对.flv格式的支持:
if video_file.endswith(".mkv"):
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String% %/s|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
elif video_file.endswith(".avi"):
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String%|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
elif video_file.endswith(".flv"):
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String%|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
else:
video_result = subprocess.run(["mediainfo", "--Inform=Video;%Format%|%Width%x%Height%|%BitRate/String%|%FrameRate%|%Duration/String3%", video_file], stdout=subprocess.PIPE)
需要根据实际情况,增加对应视频格式的支持。
原文地址: https://www.cveoy.top/t/topic/bak1 著作权归作者所有。请勿转载和采集!