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

Export with transparency on Windows #2110

Open
stephanedebove opened this issue Mar 16, 2024 · 0 comments
Open

Export with transparency on Windows #2110

stephanedebove opened this issue Mar 16, 2024 · 0 comments
Labels

Comments

@stephanedebove
Copy link

Describe the bug

I have spent a couple of days working on my animations and exporting them as .mp4 for testing purposes. I thought switching to a .mov format with transparent background would be as easy as adding the -t flag to my manim command, but apparently it’s not.

manim -qh myfile.py BounceImage

works. It produces a .mp4 and I can see my animation (a simple image entering the screen with a bouncing effect, see code below). But with

manim -tqh myfile.py BounceImage

it’s producing a .mov file that can only be opened in VLC and not Premiere ("File import failure: The file has no audio or video stream") neither Windows Media Player, Media Player, Movies & TV ("The file is encoded in rle format which isn’t supported").

Plus, when opened in VLC, I do not see the boucing animation, I just see my image at its final position.

I’m using Manim Community v0.18.0 inside a Conda environment on Windows if it matters.

If it’s a known bug, what would be the best workaround? Can ffmpeg remove the solid background from a .mp4 for instance? Or is it better to export as a series of transparent .png and then use ffmpeg to merge them into a .mov file that can be read by Premiere (which is the final editing software I will be importing into)?

My bouncing effect:

class BounceImage(Scene):
    
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.img_path = "path/to/image.jpg"
    
    def construct(self):
        img = ImageMobject(self.img_path)
        video_width = config.frame_width
        img_width = video_width * 0.4
        img.scale_to_fit_width(img_width)

        margin = 0.02 * video_width
        final_pos = np.array([-config.frame_width / 2 + margin + img_width / 2, config.frame_height / 2 - margin - img.height / 2, 0])

        img.move_to(final_pos + 5*UP)
        img_start = img.copy()

        points = [
            final_pos + 5*UP,
            final_pos + 2*UP,
            final_pos + 0.3*UP,
            final_pos - 0.15*UP,
            final_pos + 0.15*UP,
            final_pos + 0.05*UP,
            final_pos,
            final_pos - 0.075*UP,
            final_pos + 0.075*UP,
            final_pos - 0.05*UP,
            final_pos
        ]

        path = VMobject().set_points_smoothly(points)
        
        self.play(MoveAlongPath(img_start, path, rate_func=smooth), run_time=1)
        self.wait(10)

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

No branches or pull requests

1 participant