Skip to content

Saved movie looks completely black #1553

@vambrosi

Description

@vambrosi

Bug description: If you try to use the save_movie=True parameter in the movie.play() function you get the correct preview, but the saved AVI file looks completely black. This happens with both opencv backends.

Minimal working example:

import numpy as np
import caiman as cm

movie = cm.movie(np.random.rand(150, 300, 300))
movie.play(save_movie=True, plot_text=True)

Possible Fix: Before playing the movie, the code seems to normalize the frame range to be between 0 and 1 (for offset=0 and gain=1). And afterwards, at least in the embed_opencv backend, it scales the data back to span the uint8 range.

However, this is not done when saving the file. So changing this line to

frame = np.clip((frame * 255.), 0, 255).astype('u1')

seems to fix the problem. This uses the same scaling and clipping as used to display the preview (I was not sure what the expected behavior would be when gain != 1 or offset != 0).

@pgunn is there any chance I could get an early release with this fix? Thanks! (I can submit a pull request.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions