allenai / ai2thor

An open-source platform for Visual AI.
http://ai2thor.allenai.org
Apache License 2.0
1.14k stars 215 forks source link

How to generate a video #498

Open laopao2002 opened 3 years ago

laopao2002 commented 3 years ago

Hi,

I find that there is no document or tutorial which shows how to generate a video. I can get the frames after each event and then merge to a video, but it's choppy. Or I can use a screen recording software to record a video from the renderer, but the actions (such as move ahead, rotate and pick up something etc) perform suddenly.

Is there another way to generate a video? I find a file called "video controller.py", but when I run the following code, some errors occur:

from ai2thor.controller import VideoController with VideoController() as vc: vc.play(vc.MoveAhead()) vc.wait(5) vc.play(vc.MoveAhead()) vc.exportVideo('thor.mp4')

And if I want to get a smooth video, what should I do?

Thank you!

mattdeitke commented 3 years ago

Hey, what error did you get from running the code?

laopao2002 commented 3 years ago

Hey, the error was:

in ----> 1 with VideoController() as vc: 2 vc.play(vc.MoveAhead()) 3 vc.wait(5) 4 vc.play(vc.MoveAhead()) 5 vc.exportVideo('thor.mp4') in __init__(self, cam_rot, cam_pos, cam_fov, **controller_kwargs) 13 cam_fov=60, 14 **controller_kwargs): ---> 15 super().__init__(continuous=True, **controller_kwargs) 16 self.step( 17 action='AddThirdPartyCamera', ~/anaconda3/lib/python3.8/site-packages/ai2thor/controller.py in __init__(self, quality, fullscreen, headless, port, start_unity, local_executable_path, width, height, x_display, host, scene, image_dir, save_image_per_frame, docker_enabled, depth_format, add_depth_noise, download_only, include_private_scenes, server_class, **unity_initialization_parameters) 445 ) 446 --> 447 event = self.reset(scene) 448 if event.metadata['lastActionSuccess']: 449 init_return = event.metadata['actionReturn'] in reset(self, scene) 31 self.step( 32 action='AddThirdPartyCamera', ---> 33 rotation=self.initial_cam_rot, 34 position=self.initial_cam_pos, 35 fieldOfView=self.initial_cam_fov) AttributeError: 'VideoController' object has no attribute 'initial_cam_rot'
d-val commented 3 years ago

Same error. @laopao2002 and @mattdeitke PR https://github.com/allenai/ai2thor/pull/856 fixes this bug