You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
i'm sure i installed ffmpeg,because that can out put the version like this:
but seems VideoManager still doesn't work as follows information , what is problem ?
To Reproduce
# fractal.py
import taichi as ti
import numpy as np
ti.init(arch=ti.gpu)
# 假定屏幕分辨率1920*1080
Width=1920
Height=1080
#假定分形图的高为660,宽为高的两倍
n = 660
# 设定偏移量
OffW=(Width-2*n)/2
OffH=(Height-n)/2
#灰度表示像素
#pixels = ti.var(dt=ti.f32, shape=(Width, Height))
#rgb表示像素
pixels =ti.Vector(3, dt=ti.f32, shape=(Width, Height))
def encode_rgb_for_pcl(rgb):
""" Encode bit-packed RGB for use with PCL.
:param rgb: Nx3 uint8 array with RGB values.
:rtype: Nx1 float32 array with bit-packed RGB, for PCL.
"""
assert(rgb.dtype == np.uint8)
assert(rgb.ndim == 2)
assert(rgb.shape[1] == 3)
rgb = rgb.astype(np.uint32)
rgb = np.array((rgb[:, 0] << 16) | (rgb[:, 1] << 8) | (rgb[:, 2] << 0),
dtype=np.uint32)
rgb.dtype = np.float32
return rgb
def decode_rgb_from_pcl(rgb):
""" Decode the bit-packed RGBs used by PCL.
:param rgb: An Nx1 array.
:rtype: Nx3 uint8 array with one column per color.
"""
rgb = rgb.copy()
rgb.dtype = np.uint32
r = np.asarray((rgb >> 16) & 0xFF, dtype=np.uint8)
g = np.asarray((rgb >> 8) & 0xFF, dtype=np.uint8)
b = np.asarray(rgb & 0xFF, dtype=np.uint8)
rgb_arr = np.zeros((len(rgb), 3), dtype=np.uint8)
rgb_arr[:, 0] = r
rgb_arr[:, 1] = g
rgb_arr[:, 2] = b
return rgb_arr
# print(encode_rgb_for_pcl(np.uint8(7)))
#ti.Vector()
@ti.func
def complex_sqr(z):
return ti.Vector([z[0] ** 2 - z[1] ** 2, z[1] * z[0] * 2])
#EFEFEF
@ti.kernel
def paint(t: ti.f32):
for i, j in pixels: # 对于所有像素,并行执行
#设分形图区左边距屏幕宽-分形图宽/2,顶距距为屏幕高度-分形图高/2;渲染分型图
if(i>OffW and j>OffH):
c = ti.Vector([-0.8, ti.sin(t) * 0.2])
z = ti.Vector([float(i-OffW) / n - 1, float(j-OffH) / n - 0.5]) * 2
iterations = 0
while z.norm() < 20 and iterations < 50:
z = complex_sqr(z) + c
iterations += 1
pixels[i, j] = ti.Vector([1-iterations * 0.02, 1-iterations * 0.02, 1-iterations * 0.02])
else:
pixels[i, j] = ti.Vector([0.93,0.93,0.93])
#ti.Vector(239,239,239)
gui = ti.GUI("Fractal", (Width, Height))
#gui.background_color=0xFFFFFF
for i in range(50):
paint(i * 0.03)
gui.set_image(pixels)
gui.show()
result_dir = "./results"
video_manager = ti.VideoManager(output_dir=result_dir, framerate=24, automatic_build=False)
video_manager.make_video(gif=True, mp4=True)
print(f'MP4 video is saved to {video_manager.get_output_filename(".mp4")}')
print(f'GIF video is saved to {video_manager.get_output_filename(".gif")}')
Log/Screenshots
[Taichi] mode=release
[Taichi] version 0.6.37, llvm 10.0.0, commit e0ac1d86, win, python 3.8.5
[Taichi] Starting on arch=cuda
[Taichi] materializing...
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Traceback (most recent call last):
File "D:/Infinity/XEngine/HiXEngine", line 95, in <module>
video_manager.make_video(gif=True, mp4=True)
File "D:\python\Anaconda3\envs\XEngine\lib\site-packages\taichi\tools\video.py", line 126, in make_video
mp4_to_gif(self.get_output_filename('.mp4'),
File "D:\python\Anaconda3\envs\XEngine\lib\site-packages\taichi\tools\video.py", line 53, in mp4_to_gif
os.remove(palette_name)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。: 'palette.png'
there's new information here ,i annotation this line:
print(f'GIF video is saved to {video_manager.get_output_filename(".gif")}')
and i debug the file with video.py , try to add the print as above:
and i recive a new message like these:
[Taichi] mode=release
[Taichi] version 0.6.37, llvm 10.0.0, commit e0ac1d86, win, python 3.8.5
[Taichi] Starting on arch=cuda
[Taichi] materializing...
ffmpeg -loglevel panic -framerate 24 -i ./results\frames\%06d.png -s:v NonexNone -c:v libx264 -profile:v high -crf 1 -pix_fmt yuv420p -y ./results\video.mp4
1
MP4 video is saved to ./results\video.mp4
there 1 meaning the os.system(command) result1
it in linux system means "Operation not permitted" but i'm using windows system
i dont know what's mean,and can't find related information on internet
then i try run cmd with admin premission,cd in project folder and run script
Actually you aren't including any frame in the video, try this:
result_dir="./results"video_manager=ti.VideoManager(output_dir=result_dir, framerate=24, automatic_build=False)
gui=ti.GUI("Fractal", (Width, Height))
#gui.background_color=0xFFFFFFforiinrange(50):
paint(i*0.03)
gui.set_image(pixels)
video_manager.write_frame(pixels) # HERE: include the pixels!gui.show()
# i'm trying to realize a board game by taichi that's would be good idea? i worry about it will very lag,because i already run few example,alomost it just mini window runing it's already very lag few demo of them,like ad_gravity just 36 fpsvideo_manager.make_video(gif=True, mp4=True)
print(f'MP4 video is saved to {video_manager.get_output_filename(".mp4")}')
print(f'GIF video is saved to {video_manager.get_output_filename(".gif")}')
i'm trying to realize a board game by taichi that's would be good idea? i worry about it will very lag,because i already run few example,alomost it just mini window runing it's already very lag few demo of them,like ad_gravity just 36 fps
The FPS issue is due to memory overhead, don't worry, #1922 will fix this.
Describe the bug
i'm sure i installed ffmpeg,because that can out put the version like this:
but seems VideoManager still doesn't work as follows information , what is problem ?
To Reproduce
Log/Screenshots
there's new information here ,i annotation this line:
and i debug the file with video.py , try to add the print as above:
and i recive a new message like these:
there 1 meaning the os.system(command) result1
it in linux system means "Operation not permitted" but i'm using windows system
i dont know what's mean,and can't find related information on internet
then i try run cmd with admin premission,cd in project folder and run script
"ffmpeg -loglevel panic -framerate 24 -i ./results\frames\%06d.png -s:v NonexNone -c:v libx264 -profile:v high -crf 1 -pix_fmt yuv420p -y ./results\video.mp4"
like above motioned,but it doesn't work too,there's result
how to solve that? i already change too many version of ffmepg,thanks for any advice
The text was updated successfully, but these errors were encountered: