dalboris / vpaint

Experimental vector graphics and 2D animation editor
http://www.vpaint.org
Apache License 2.0
732 stars 54 forks source link

Export complete animation #135

Open nasirzid opened 1 year ago

nasirzid commented 1 year ago

Hello, how I can export the complete animation.

dalboris commented 1 year ago

Unfortunately, VPaint is just a prototype and there is no video export feature at the moment.

In the meantime, as a workaround, you can do file > Export > PNG > [X] Image Sequence > my_animation.png.

It will create files named my_animation_0001.png, my_animation_0002.png, etc., that you can import in a video editor (Kdenlive, Premiere, etc.) or use ffmpeg to convert the image sequence to an *.mp4.

nasirzid commented 1 year ago

Thanks Boris, for the response and in email as well. I export the image sequence as mentioned and to convert it into .mp4 I used the following python script. It just take all images in sequence and then make its video.

`import cv2 import os import re

def create_video_from_pngs(directory, output_file):

Get all PNG files in the directory

png_files = [file for file in os.listdir(directory) if file.endswith('.png')]

# Sort the files numerically
png_files.sort(key=lambda x: int(re.search(r'\d+', x).group()))

# Read the first image to get the dimensions
first_image = cv2.imread(os.path.join(directory, png_files[0]))
height, width, _ = first_image.shape

# Create a video writer object
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video_writer = cv2.VideoWriter(output_file, fourcc, 30, (width, height))

# Write each image to the video
for png_file in png_files:
    image = cv2.imread(os.path.join(directory, png_file))
    video_writer.write(image)

# Release the video writer
video_writer.release()

print(f"Video created successfully: {output_file}")

if name == 'main':

Specify the directory containing the PNG files and the output file name

png_directory = '/path/to/png/files'
output_file_name = 'output.mp4'

# Call the function to create the video
create_video_from_pngs(png_directory, output_file_name)

`