Skip to content

Instantly share code, notes, and snippets.

@Pankraz01
Last active November 21, 2023 13:29
Show Gist options
  • Save Pankraz01/3a59dc58174f001ebb8e229663215521 to your computer and use it in GitHub Desktop.
Save Pankraz01/3a59dc58174f001ebb8e229663215521 to your computer and use it in GitHub Desktop.
Timecode Converter EDL (23.978 to 25 FPS)
import pandas as pd
import tkinter as tk
from tkinter import filedialog
def frames_to_timecode(frames, fps):
"""Konvertiert Frames zurück in einen Timecode, beginnend bei 10 Stunden."""
h = frames // (3600 * fps)
frames %= (3600 * fps)
m = frames // (60 * fps)
frames %= (60 * fps)
s = frames // fps
f = frames % fps
# 10 Stunden hinzufügen
h += 10
return f"{h:02}:{m:02}:{s:02}:{f:02}"
def convert_excel_timecodes(file_path, original_fps, new_fps):
# Excel-Datei laden, verwende Zeile 5 als Überschriften
df = pd.read_excel(file_path, header=4)
# Funktion zur Umwandlung von Frames in Timecode, überspringt NaN-Werte
def convert_frames(frame):
if pd.notna(frame):
return frames_to_timecode(int(frame), new_fps)
return frame # Gibt NaN zurück, wenn der Wert NaN ist
# Timecodes für Spalte B und Spalte C umrechnen
df['RecTCStart 25p'] = df.iloc[:, 1].apply(convert_frames)
df['RecTCEnd 25p'] = df.iloc[:, 2].apply(convert_frames)
# Ergebnis in neuer Excel-Datei speichern
output_file = file_path.replace('.xlsx', '_converted.xlsx')
df.to_excel(output_file, index=False)
print(f"Konvertierte Datei gespeichert als: {output_file}")
def main():
# Tkinter-Fenster für Dateiauswahl
root = tk.Tk()
root.withdraw() # Wir wollen nicht das volle GUI-Fenster
file_path = filedialog.askopenfilename(filetypes=[("Excel files", "*.xlsx")])
if file_path:
convert_excel_timecodes(file_path, 23.976, 25)
else:
print("Keine Datei ausgewählt.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment