Closed FedeClaudi closed 4 years ago
Thanks for sharing this wonderful codes.
I am trying to make a video, but there's an error while I running "from brainrender.Utils.videomaker import VideoMaker"
No module named 'brainrender.Utils.videomaker'
Do I need to update the source files?
Thanks,
Hi, thanks for getting in touch.
I'm in the process of updating the code to generate videos to fix a few problems with it, so it's currently not functional. I will have it fixed by the end of the day though, so will let you know soon. Sorry about that!
Hi,
The code for making videos is now fixed. However there seems to be a problem with the underlying vtkplotter
video making code (see this issue https://github.com/marcomusy/vtkplotter/issues/122) which means that you might encounter problems if you're using brainrender
on Windows, we'll try to fix it ASAP.
You can find an example on how to make videos with the new code here: https://github.com/BrancoLab/BrainRender/blob/master/Examples/basic_video_maker.py
And a more detailed description of how to use the code here: https://github.com/BrancoLab/BrainRender/blob/master/Docs/MakingVideos.md
Hope this works, but let me know otherwise.
P.S.: for this to work you'll have to update your brainrender installation: pip install brainrender --upgrade
.
Thanks for your work. I create a new virenv as you've instructed us in the other issue. (also applied the upgrade)
I just wonder whether the line that evokes the error might have some typo for the module name.
Since from brainrender.scene import Scene works, while from brainrender.Utils.videomaker import Video maker not
you mean a Window user still has the problem not having the module in your library?
Best
Hi,
If you'll look to the example script I've linked above you'll notice that I've changed a few things around as I've reorganised the code.
The code for making videos is not in brainrender.animation.video
, which means that you'll have to change
from brainrender.Utils.videomaker import VideoMaker
to
from brainrender.animation.video import BasicVideoMaker as VideoMaker
This is an example of how you can make a simple video:
import brainrender
brainrender.WHOLE_SCREEN = True
brainrender.SHADER_STYLE = 'cartoon'
from brainrender.scene import Scene
from brainrender.animation.video import BasicVideoMaker as VideoMaker
scene = Scene(display_inset=False, camera="sagittal")
scene.add_brain_regions(['MOs'])
vmkr = VideoMaker(scene)
vmkr.make_video(azimuth=1, niters=360, duration=30, save_name="test")
The problem with windows is (presumably) a bug with vtkplotter
which is what brainrender uses for creating the renderings and the videos. You won't get an error because of it, so the code should run smoothly, but unfortunately the video will not be formatted correctly.
p.s.: I'm hoping for the author of vtkplotter
to fix this issue soon, but if you need to make a video urgently we can work out a solution together, let me know :)
Thanks for your help. I tried your new suggestion, but I still have problem when I run the last line. Actually, I also run the code in linux but still...
the image I've attached here is from linux.
It says both in Windows and linux 'NoneType' object has no attribute 'SetPosition'
Thanks.
Hi,
Thanks for trying. I have good news: I've found what the problem is.
When using jupyter/ipython vtkplotter will handle things differently depending on which backend and other packages you have installed.
I believe that you have k3d
installed and that's what's causing the problem.
It seems that when using k3d the vtkplotter plotter (which is what brainrender's scenes consist of) doesn't have a camera object (or its called something different). Thus when the scene gets rendered and brainrender tries to specify the position of the camera you get that error.
I will fix this in the future, but for now the quickest solution is to either not use jupyter notebooks or to uninstall k3d (pip uninstall k3d
). If you restart jupyter after uninstall k3d you'll see a warning message below the first cell (see image below) and I'm confident that you'll be able to create your videos.
Hope this helps!
Thanks for your early response!
I am happy to get less errors while working with you.
I tried your suggestion, it looks like have no error while running the codes. However, once the rendering is done (rotating 360) then the rendering window gets frozen. Also even though the output message said "test.mp4" saved as mp.4 file, but I couldn't find the corresponding file in .brainrender/Output/Videos.
Thanks!
Hi,
the window remains frozen because you're using jupyter notebooks.
Until brainrender supports k3d
I'm afraid that this will remain an issue, but I will work on this soon.
Regarding the video not being saved, you'll see in the output text in your screenshot the message ffmepg returning error
, this means that there where a problem with the creation of the video, which is why the video wasn't saved.
Video Creation for now requires ffmpeg for creating the video, do you have ffmpeg correctly installed? If not you can follow these instructions: http://blog.gregzaal.com/how-to-install-ffmpeg-on-windows/
Hi,
Thanks for sharing the fantastic code! Let me jump in.
I have trouble saving a video as well (on Mac and tried Jupyter and Spyder).
The error I got is shown below. Do you have any ideas to solve this problem?
Thanks,
I just install ffmpeg. Thanks for your advice.
So it seems create a video with mp4 extension, but I couldn't open the file in my computer, while I am still able to open other mp4 files.
I shared the video file to my friend through slack, and noticed that some weird movie was shown. not like I've seen in the rendering window.
this is what I am seeing through the window
The error when I try to open it.
@youeh1 that's probably a codec issue, have you tried opening with VLC, that should be open to deal with it. I will be extending the video functionality soon to support more codecs and video formats so hopefully this won't be an issue in the future.
@jt522 I've never seen that error before, so I'm not sure. A bit more information could help here, specifically: 1) which versions of brainrender and vtkplotter you're using 2) Are you able to render scenes without errors?
I can open it but i got this.
Thanks for your work and let us know later once it is figured out.
I don't know what it is. I suspect that it's an ffmpeg
issue as it seems that the frames got corrupted, but hard for me to diagnose. You can check online how to know if your ffmpeg installation has errors and/or if you need to install more codecs for creating mp4
videos.
If you don't need the video urgently however I'd suggest waiting a couple days, I will change things so that you won't need ffmpeg anymore for creating videos, so this problem will be solved with the new changes (see https://github.com/BrancoLab/BrainRender/issues/50).
Thanks for quick reply! Here is my answer.
brainrender 0.3.4.2 vtkplotter 2020.2.3
I can render scene without error.
@jt522 let's move this conversation to a separate issue since it's not related to the issue above.
@youeh1 I will close this issue for now as the original problem has been fixed, but stay tuned for updates on how to create videos with brainrender.
@youeh1 if you'd like you could test the new code for creating videos, which doesn't require ffmpeg and also lets you save videos as .avi
.
To do so you need to:
Install brainrender from the animation github branch with:
pip uninstall brainrender
pip install brainrender git+https://github.com/BrancoLab/BrainRender.git@animation
Install termcolor and opencv with
pip install termcolor opencv-python
Then you can try creating a video. The code for creating videos is the same as what you've already used, but hopefully you'll get better results.
Let me know if you get a chance to try this and if you get better results, thanks.
The
VideoMaker
class is a bit buggy. Some actors (e.g. cells) are not rendered in the video frames. This is probably because inbrainrender.scene
the vtkplotter plotter is populated withshow(*self.get_actors()...
while videomaker usesshow()
.This will be fixed when I update the VideoMaker class (currently under development in the
Animation
branch), but for now a workaround is to:Scene.render()