Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making Video on Windows doesn't work #122

Closed
FedeClaudi opened this issue Apr 7, 2020 · 8 comments
Closed

Making Video on Windows doesn't work #122

FedeClaudi opened this issue Apr 7, 2020 · 8 comments

Comments

@FedeClaudi
Copy link
Contributor

Hi Marco,

I've encountered a problem with the Video class: https://github.com/marcomusy/vtkplotter/blob/471ae90046f00579d6e4ad894f78a9018564224b/vtkplotter/vtkio.py#L1403

If I make a video with code similar to the one provided in the example, I get different behaviours depending on the OS:

On Mac it works fine, it creates the video and it's all good.
On Windows it creates a video where the frames are either black or messed up.

I've become convinced that the problem is with the ffmpeg command in Video.close(), but was unable to find a fix. It should be something about the codec and pixel format used, but I'm unsure about what the solution is.

I should also add that I've tried updating ffmpeg to the latest build but that doesn't change anything.

I don't know if the Video class changed recently, but I think I was able to create videos on windows in the past, and I haven't changed anything on my machine. The only change is that I'm using a more recent version of vtkplotter.

@adamltyson
Copy link
Contributor

FYI - works on Ubuntu too.

@marcomusy marcomusy added the bug label Apr 7, 2020
@FedeClaudi
Copy link
Contributor Author

Hi, just adding this here:
if there's a problem with ffmpeg (e.g. not installed correctly), the video.close() method still prints "~save Video as..." even though nothing gets actually saved.

@marcomusy
Copy link
Owner

hi @FedeClaudi sorry for the late answer, i would first check if the screenshots are rendered correctly, if so the isuue must be ffmpeg as you say.
if in the meanwhile you found a better way of doing this, using opencv, we could integrate that in vtkplotter as an alternative backend option, something like Video(use='opencv').

@FedeClaudi
Copy link
Contributor Author

Hi, yep the screenshots are rendered correctly on both mac and windows, the problem seems to be with the video creation.

Sure, if you'd like to take the code I've made for using opencv and make it part of vtkplotter that'd work.

Do you know how much do users create animations/videos in vtkplotter? I suspect that it's going to become increasingly important for brainrender so I'd be keen to support this functionality.

@marcomusy
Copy link
Owner

it's cool that at least screenshots are doing fine :) if you have some lines of code already using opencv can you share them?
though i dont know how many users need videos, making videos is for sure one important feature and it should be fully supported in vtkplotter

@FedeClaudi
Copy link
Contributor Author

sure,
this is a bunch of utility functions to create videos with opencv: https://github.com/BrancoLab/BrainRender/blob/animation/brainrender/animation/video_utils.py

And this is the brainrender class that handles creating a video (mostly builds upon the vtkplotter video class): https://github.com/BrancoLab/BrainRender/blob/animation/brainrender/animation/video.py

BasicVideoMaker.close() uses opencv VideoCapture to create a video stream from the saved screenshots and then a VideoWriter to save them as a .mp4 or .avi video. Let me know if there's anything that is not clear.

@marcomusy
Copy link
Owner

marcomusy commented Apr 16, 2020

In the latest release i include opencv support, interface is:
video = Video("spider.mp4", duration=6, backend='ffmpeg') # backend='opencv'
also added some semi-automated video shooting where one can specify rotations and elevation ranges, or a start to end camera positions (as either a vtkCamera or python dictionary):

video.action(zoom=1.1)
#Options are:  elevation_range=(0,80),
#              azimuth_range=(0,359),
#              zoom=None,
#              cam1=None, cam2=None  # initial and final camera positions

check out example here
M.

@FedeClaudi
Copy link
Contributor Author

Cool, nice stuff!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants