Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit e4e193c

Browse files
committed
added sandbox
1 parent 233ab65 commit e4e193c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

sandbox/so73726025.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import numpy as np
2+
# from matplotlib.animation import FFMpegWriter
3+
from matplotlib import pyplot as plt
4+
import ffmpegio
5+
6+
np.random.seed(0)
7+
fig, ax = plt.subplots(figsize=(9, 4),dpi=300)
8+
ln, = ax.plot([])
9+
ax.set_xlim([0, 1000])
10+
ax.set_ylim([-1, 1])
11+
ax.grid(True)
12+
13+
# writer = FFMpegWriter(fps=1)
14+
# with writer.saving(fig, "writer_test.mp4", 300):
15+
with ffmpegio.open(
16+
"sandbox/writer_test.mp4", # output file name
17+
"wv", # open file in write-video mode
18+
1, # framerate in frames/second
19+
pix_fmt="yuv420p", # specify the pixel format (default is yuv444p)
20+
overwrite=True
21+
) as writer:
22+
for i in range(20):
23+
x = np.arange(1000)
24+
t = np.random.randn(1000)
25+
y = np.sin(2 * np.pi * t)
26+
ln.set_data(x, y)
27+
writer.write(fig)
28+
# plt.show()

0 commit comments

Comments
 (0)