mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-21 20:52:11 -03:00
0.77
This commit is contained in:
34
save_tmp_video.py
Normal file
34
save_tmp_video.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
class SaveTmpVideo:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"video_path": ("STRING", {"forceInput": True}),
|
||||
},
|
||||
}
|
||||
|
||||
FUNCTION = "save_video"
|
||||
RETURN_TYPES = ()
|
||||
OUTPUT_NODE = True
|
||||
CATEGORY = "Bjornulf"
|
||||
|
||||
def save_video(self, video_path):
|
||||
# Ensure the output directory exists
|
||||
os.makedirs("./output", exist_ok=True)
|
||||
|
||||
# Verify the video file exists
|
||||
if not os.path.exists(video_path):
|
||||
raise FileNotFoundError(f"Video file not found: {video_path}")
|
||||
# Get the file extension
|
||||
ext = os.path.splitext(video_path)[1].lower()
|
||||
if ext not in ('.mp4', '.mkv', '.webm'):
|
||||
raise ValueError("video_path must be a .mp4, .mkv, or .webm file")
|
||||
# Copy the file to the output directory with the same extension
|
||||
filename = f"./output/tmp_api{ext}"
|
||||
shutil.copy(video_path, filename)
|
||||
|
||||
print(f"Temporary video saved as: {filename}")
|
||||
return {"ui": {"videos": [{"filename": filename, "type": "output"}]}}
|
||||
Reference in New Issue
Block a user