frame to timecode

pull/5/head
florentin.luce 2024-02-13 16:01:31 +01:00
parent a1d7773165
commit e921dafb49
1 changed files with 13 additions and 0 deletions

View File

@ -15,6 +15,17 @@ from vse_toolbox.constants import SOUND_SUFFIXES
import subprocess
def frame_to_timecode(frame, fps):
total_seconds = frame / fps
hours = int(total_seconds // 3600)
minutes = int((total_seconds % 3600) // 60)
seconds = int(total_seconds % 60)
frames = int((total_seconds * fps) % fps)
timecode = f"{hours:02d}:{minutes:02d}:{seconds:02d}:{frames:02d}"
return timecode
def new_text_strip(name='Text', channel=0, start=0, end=50, text='Text', font_size=48,
x=0.5, y=0.5, align_x='CENTER', align_y='CENTER', select=False,
box_color=None, box_margin=0.005):
@ -485,6 +496,7 @@ def update_text_strips(scene):
'shot_duration': 0,
'shot_start': 0,
'shot_end': 0,
'time_code': ''
}
shot_strip = get_strip_at('Shots', frame=scene.frame_current)
@ -499,6 +511,7 @@ def update_text_strips(scene):
'shot_frame': scene.frame_current - shot_strip.frame_final_start + 1,
'shot_start': shot_strip.frame_final_start,
'shot_end': shot_strip.frame_final_end,
'timecode' : frame_to_timecode(scene.frame_current, scene.render.fps)
})
for strip in scene.sequence_editor.sequences_all: