Jupyter video creation

Hello,

I am trying to automate some simulations with Jupyter. Everything goes well, except the part when I am trying to create the video.

If I upload the simulated data to AB and select from the drop down menu Main.MyCam.Create_Video, then it works as intended. But when I set the following command in Jupyter: OperationRun('Main.MyCam.Create_Video'), then the end result is a series of .png without the video.

I know that the video creation command first saves a .png for every frame, then puts it together to create a video, and then deletes the images so in the designated folder only the video is left. Now my question is, why is the same command run from Jupyer not giving the same output? Is there something else I should be passing to Jupyter except the command to make a video? I have tried to give the commands line by line as well : Create_video, ConvertVideo, RemoveImageFiles, but the end result is the same.

Thanks in advance!

Best,
Diana

So I have found that during the simulations there is the following warning:

Warning: Material::setShininess() of 11520 is above permitted maximum, clamping to 128.

This warning does not appear when I play the video from the AB menu, but it does appear when I run it from Jupyter. Otherwise I have no errors or other warnings.

Hi @diana

You can just ignore the setShininess warning, that has been fixed internally and do not affect the model in any way - it is just annoying.

For the missing video generation, my best guess is that your Jupyter environment do not include ffmpeg.
Try to see if you have ffmpeg on your PATH variable or included in your Jupyter environment.

Best regards,
Bjørn
AnyBody Technology

Hi Bjørn,

I have added the ffmpeg to my PATH variable but the result is the same. I also tried using pip install and conda install but nothing changed.

Best,
Diana

Hi @diana

Have you set up a dedicated environment for the notebook?
In the VideoLookAtCamera class you can enable the debug mode and try to set the VideoPathFFMPEG to the absolute path to your ffmpeg executable.

Do you see any errors in the log files generated by anypytools?

Best regards,
Bjørn

Hi Bjørn,

I have activated the debug mode. The path was already set so I did not change that. In the log files generated by anypytools, I do not have errors, but only the above mentioned warning.

When I run the simulation I have the following error:

I have made the name of the video a design variable in AB, such as: `VideoName = DesignVar("_testing_video"); and I am giving it a different name when runing the simulation. For some reason, the images created are named correctly (the same name I pass in Jupyter) but when the ffmpeg is executed, the name is switched back to the one I have in AB, so I guess it cannot find the .png to convert it.

Is there a way to make the name last for the entire simulation? Or maybe I am doing something wrong. Right now I am using the following sequence:

    SetValue('Main.MyCam.VideoName', video_name),
    SetValue('Main.MyCam.CameraDirection', camera_direction),
    OperationRun('MyCam.Create_Video'),

*EDIT: I just tried to run the simulation without changing the name of the video and it works as intended, but I would still like to be able to change the name of the file from Jupyter if possible.

Best,
Diana
`

Okay, that brings us a lot closer to the problem.

My first step would be to try and use a UpdateValues() class in your macro.
You import it the same way as other macro command classes.

So you insert something like:

...
SetValue('Main.MyCam.CameraDirection', camera_direction),
UpdateValues(),
OperationRun('MyCam.Create_Video'),
...

Be sure to put it after all your set value operations and before the study operation run.

Best regards,
Bjørn

1 Like

Thank you so much! That was indeed the problem, I was not updating the values. Now everything works perfectly.

Thank you for your help and have a nice day!

Best,
Diana