From e921dafb49ab7b07114f74570afce2dd80a547b7 Mon Sep 17 00:00:00 2001 From: "florentin.luce" Date: Tue, 13 Feb 2024 16:01:31 +0100 Subject: [PATCH] frame to timecode --- sequencer_utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sequencer_utils.py b/sequencer_utils.py index c8cae24..84aec15 100644 --- a/sequencer_utils.py +++ b/sequencer_utils.py @@ -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: