As i’m trying, for one more time, to get familiar with scripting i started writing an addon that, if you had a video file selected in the sequencer, it would tell you the file’s framerate and set it in the properties.
The core of the script works, but i don’t know how to display it to the user. This is the code that i have so far:
import bpy
import subprocess, re
class GetFps(bpy.types.Operator):
bl_idname = "sequencer.getfps"
bl_label = "get fps"
fps = bpy.props.FloatProperty(name = "some name")
def get_fps(self, filepath):
filepath = bpy.path.abspath(filepath)
#filepath = filepath.replace(' ', '\ ')
movieFile = r"" + filepath
movieFile = (re.escape(movieFile))
output = subprocess.check_output("exiftool " + movieFile, shell=True)
string = b"Video Frame Rate"
if string in output:
z = output.index(string)
x = output[z:]
y = output.index(b"
")
y = x[:y]
y = re.findall(b"\d[0-9].[0-9]", y)
y = float(y[0])
return y
def execute(self, context):
file = context.selected_sequences[0]
if file.type == 'MOVIE':
filepath = file.filepath
self.fps = self.get_fps(filepath)
print(self.fps)
return {'FINISHED'}
EDIT: After i posted the question i realized that i could just do the calculations in a menu class and call the operator for submiting them. I don’t really know how to do that, but i think that this thread is now irrelavent