User:Cosmia Nebula
Jump to navigation
Jump to search
Somepony that has wandered into human world before she was born and longs to return to her world. Astronomer and mathematician in pony world, merely mathematician in human world.
Main page in https://en.wikipedia.org/wiki/User:Cosmia_Nebula
How to use Template:Created with code:
The most important part: the source code used for image generation may not contain |, || ,[[ or }} (replace by {{!}}, {{!!}}, {{!((}} or {{))}} resp.)
{{Created with code|l1=matplotlib|c1= }}
And
for dir in ./*/; do
# Extract folder name
folder_name=$(basename "$dir")
# Create output path
output_path="./${folder_name}.webm"
# Convert images to webm
echo $output_path
ffmpeg -y -framerate 24 -i "$dir"%03d.png -c:v libvpx-vp9 -b:v 0 -crf 30 -pix_fmt yuva420p "$output_path"
done
import os
movie_name = ...
dir_path = f"./{movie_name}"
tmax = 4
frames_per_t = 24
t_values = np.linspace(-tmax, tmax, frames_per_t * (tmax * 2))
for N, t in tqdm(enumerate(t_values)):
if not os.path.exists(dir_path):
os.makedirs(dir_path)
plt.savefig(f"{dir_path}/{N:03d}.png",bbox_inches='tight')
plt.close()
# import imageio.v3 as iio
# from natsort import natsorted
# import moviepy.editor as mp
# for dir_path in [dir_path]:
# file_names = natsorted((fn for fn in os.listdir(dir_path) if fn.endswith('.png')))
# # Create a list of image files and set the frame rate
# images = []
# fps = 24
# # Iterate over the file names and append the images to the list
# for file_name in file_names:
# file_path = os.path.join(dir_path, file_name)
# images.append(iio.imread(file_path))
# filename = dir_path[2:]
# clip = mp.ImageSequenceClip(images, fps=fps)
# clip.write_videofile(f"output.mp4")
# !ffmpeg -framerate 24 -i %03d.png output.webm
# !ffmpeg -y -i output.mp4 -c:v libvpx-vp9 -b:v 0 -crf 10 -c:a libvorbis output.webm