Skip to content

Google Colab: Video data is no longer automatically embedded in the notebook #3741

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

Closed
mathriddle opened this issue May 1, 2024 · 5 comments
Labels
good first issue Good for newcomers issue:bug Something isn't working... For use in issues

Comments

@mathriddle
Copy link

Previously, running the command "from manim import *" all by itself in a Colab cell would result in the output "Manim Community v0.18.0". Then the manim code to make a video could be run in additional cells. With v0.18.1, however, no output is generated running that import command, but the "Manim Community v0.18.1" appears as the output after rendering a manim snippet in a subsequent cell, along with the message about "no video with supported format and MIME type found".

Adding the line config.media_embed=True to the cell with the import command does resolve the issue, but the "Manim Community v0.18.1" output still appears as the output along with the now functioning video.

@github-project-automation github-project-automation bot moved this to 🆕 New in Dev Board May 1, 2024
@behackl behackl changed the title With v0.18.1 in Colab, no video produced when rendering a manim snippet Google Colab: Video data is no longer automatically embedded in the notebook May 1, 2024
@behackl
Copy link
Member

behackl commented May 1, 2024

The version spash shown on import has been disabled by default.

As for the video: it actually is being generated, Colab can just not display it if it is not directly embedded into the notebook source. The default behavior of this config option (config.media_embed) has been changed; it is False now by default, None is no longer an allowed value.

The corresponding code that needs to be updated is here:

if embed is None:
# videos need to be embedded when running in google colab.
# do this automatically in case config.media_embed has not been
# set explicitly.
embed = "google.colab" in str(get_ipython())

We should change this such that media_embed is True whenever the IPython magic is run on Colab.

@behackl behackl added good first issue Good for newcomers issue:bug Something isn't working... For use in issues labels May 1, 2024
@21-kunal
Copy link

Hi, I would like to work on this issue.

@antoinebou12
Copy link

antoinebou12 commented Nov 18, 2024

My fix

url = "media/videos/content/720p30/example.mp4"
import os

current_directory = os.getcwd()
print(current_directory)

video_path = os.path.join(current_directory, url)
print(video_path)

from IPython.display import HTML
from base64 import b64encode
mp4 = open(video_path,'rb').read()
data_url = "data:video/mp4;base64," + b64encode(mp4).decode()
HTML("""
<video width=1080 controls>
      <source src="%s" type="video/mp4">
</video>
""" % data_url)

@behackl
Copy link
Member

behackl commented Nov 18, 2024

My fix

This replicates manually what `config.media_embed = True does automatically.

The issue has already been fixed on the main branch an will be available with the upcoming release.

@behackl behackl closed this as completed Nov 18, 2024
@antoinebou12
Copy link

Thank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers issue:bug Something isn't working... For use in issues
Projects
Status: 🆕 New
Development

No branches or pull requests

4 participants