42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Complete video generation from existing frames
|
|
"""
|
|
import os
|
|
import glob
|
|
from moviepy import ImageSequenceClip
|
|
|
|
def create_video_from_frames():
|
|
frames_folder = "/home/pi/Desktop/traccar_animation/resources/projects/day 2/frames"
|
|
output_path = "/home/pi/Desktop/traccar_animation/resources/projects/day 2/advanced_3d_animation.mp4"
|
|
|
|
# Get all frame files
|
|
frame_files = glob.glob(os.path.join(frames_folder, "frame_*.png"))
|
|
frame_files.sort() # Ensure correct order
|
|
|
|
if not frame_files:
|
|
print("No frames found!")
|
|
return
|
|
|
|
print(f"Found {len(frame_files)} frames")
|
|
print("Creating video...")
|
|
|
|
# Create video clip
|
|
clip = ImageSequenceClip(frame_files, fps=30)
|
|
|
|
# Write video file
|
|
clip.write_videofile(
|
|
output_path,
|
|
codec='libx264',
|
|
bitrate='8000k',
|
|
audio=False,
|
|
temp_audiofile=None,
|
|
remove_temp=True
|
|
)
|
|
|
|
print(f"Video created successfully: {output_path}")
|
|
return output_path
|
|
|
|
if __name__ == "__main__":
|
|
create_video_from_frames()
|