Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import OpenEXR
- import Imath
- import os
- def extract_metadata_from_exr(filename, metadata_key):
- """Extract metadata from an EXR file."""
- exr_file = OpenEXR.InputFile(filename)
- header = exr_file.header()
- return header[metadata_key]
- def get_average_render_time(directory, prefix, extension=".exr"):
- """Get average render time from a sequence of EXR files."""
- total_time = 0.0
- count = 0
- # Loop over files in directory
- for file in os.listdir(directory):
- if file.startswith(prefix) and file.endswith(extension):
- full_path = os.path.join(directory, file)
- render_time = extract_metadata_from_exr(full_path, "exr/renderTime_s")
- if isinstance(render_time, float): # Ensure the metadata is a float
- total_time += render_time
- count += 1
- return total_time / count if count != 0 else None
- directory = "." # current directory
- prefix = "image." # prefix for your sequence
- average_time = get_average_render_time(directory, prefix)
- if average_time:
- print(f"Average render time: {average_time} seconds")
- else:
- print("No EXR files with the specified prefix found or missing metadata.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement