Creating videos - AnyScript Community

In this post, I will show a new AnyScript template to create awesome videos of your musculoskeletal simulations with a single click.


This is a companion discussion topic for the original entry at https://anyscript.org/tips-n-tricks/creating-videos-from-your-simulations/

Hi Morten,

When I try to create a video with the BVH_Xsens model, no matter what, I always get the stick-figure model displayed on the background behind the actual MS model.

I already verified that the macro operation, InverseDynamicView, is executed as part of the operation that I want to record (InverseDynamics), which should hide the stick-figure, but still I get that into my video:
2019-06-14_003

I also tried to manually set the InverseDynamicView before creating the video, but it doesn’t help.

Another very weird thing: if I right-click on the stick-figure in the model view and select Main.ModelSetup.BVHFileData > This objects + all levels > Hide, then I don’t see the stick-figure in the video, but the MS model doesn’t move from its initial position!
2019-06-14_003

The only way I found, at the moment, to have the stick-figure not ending up in the video is to set Main.ModelSetup.BVHFileData.ModelDrawOnOff to Off:
2019-06-14_003

Maybe you understand better what’s going on?

Many thanks in advance!

Marco

Hi Marco. There are some quirks when recording videos. As you have experienced, it doesn't respect the views you set after the model has loaded. But if you hide stuff on the script it should work. I really hope this will be fixed for the 7.3 release. It is on the backlog but there are a lot of things fighting for priority :slight_smile:

Dear melund,

When I run the Create_video operation, it produces pictures frame by frame (I can see in the file manager) but after that the operation has ended, all of the pictures are deleted and there is no .mp4 or .gif file available in the windows file manager! What am I doing wrong?

Best regards,
Iman

Hi Imran

Sorry. The scripts really needs a better error messages when that happens. It is probably faiing to find ffmpeg on you system. It uses ffmpeg to convert the images to videos. To fix this either install ffmpeg from here: https://ffmpeg.zeranoe.com/builds/ and make sure it is on the Windows PATH. Alternatively just place the ffmpeg binary (ffmpeg.exe) together with the main file of your model.

hope it helps.
/Morten

Hi Morten,

Thanks for quick reply. I have just copied the ffmpeg.exe in the same folder with the *.main.any file and the problem is solved. Thanks.

best regards,
Iman

Dear Morten,

I would like to ask how can I make a rotating animation of my model? Which lines of the scripts should I change for this purpose?

  VideoLookAtCamera  MyCam (UP_DIRECTION=y, _AUTO_PLAY_VIDEOS=1) = 
{
   // The point the camera focus on.
   CameraLookAtPoint = {3, 1, .5};  
   
   // The vertical field of view in meters (the lower the zoomer)
   CameraFieldOfView  = 2.5;
   
   // The direction in which the camera is placed. In global 
   // coordinate with respect to the LookAtPoint. 
   // (Can also be a time varying vector)
   CameraDirection  = {2, 0.35, 1};
   
   // The background color used for the video
   BackgroundColor = {1, 1, 1};
   
   // Determines the speed of the video. Setting it to 
   // nStep/(tEnd-tStart) make the video run in real time. 
   VideoInputFrameRate  = 10;
   
   VideoResolution = {1920, 1080};
   
   // The operations which should be included in the video.
   Analysis = {
     AnyOperation &ref = Main.RunAnalysis.InverseDynamics;
   };
};

I think I should define a time varying vector for CameraDirection and CameraLookAtPoint? But how can I define a time varying vectors in Anyscript?

Best regards,
Iman

Hi Iman;

Please have a look at the following example. I was looking for creating the animation with a rotating camera and I was able to do it using the example. Please note the requirement on putting a reference to the camera object within the study.

Can