make_video.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """Make a video file with or without graphic window"""
  2. from vedo import dataurl, Plotter, Mesh, Axes, Video
  3. msh = Mesh(dataurl+"data/teapot.vtk").normalize()#.rotate_x(-90)
  4. msh.shift(-msh.center_of_mass())
  5. plt = Plotter(bg="beige", bg2="lb", offscreen=False)
  6. plt += [msh, Axes(msh), __doc__]
  7. ##############################################################
  8. # Open a video file and force it to last 3 seconds in total
  9. video = Video("vedo_video.mp4", duration=3) # or gif
  10. ##############################################################
  11. # Any rendering loop goes here, e.g.:
  12. # for i in range(80):
  13. # plt.show(elevation=1, azimuth=2) # render the scene
  14. # video.add_frame() # add individual frame
  15. ##############################################################
  16. # OR use the automatic video shooting function:
  17. # Options are: elevation=(0,80), # range of elevation values
  18. # azimuth=(0,359),
  19. # zoom=None,
  20. # cameras=None
  21. ##############################################################
  22. # OR set a sequence of camera positions, e.g.:
  23. cam1 = dict(
  24. position=(5.805, 17.34, -0.8418),
  25. focal_point=(0.133, 0.506, -0.132),
  26. viewup=(-0.3099, 0.1871, -0.9322),
  27. clipping_range=(12.35, 21.13),
  28. )
  29. cam2 = dict(
  30. position=(-1.167, 3.356, -18.66),
  31. focal_point=(0.133, 0.506, -0.132),
  32. clipping_range=(8.820, 25.58),
  33. )
  34. cam3 = dict(
  35. position=(-4.119, 0.9889, -0.8867),
  36. focal_point=(0.948, 0.048, -0.592),
  37. viewup=(-0.01864, 0.9995, -0.02682),
  38. clipping_range=(0.07978, 17.04),
  39. )
  40. video.action(cameras=[cam1, cam2, cam3, cam1])
  41. video.close() # merge all the recorded frames and write to disk
  42. plt.interactive().close()