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

Add height and width parameters to core.display.Video #11328

Closed
jwkvam opened this issue Sep 23, 2018 · 4 comments
Closed

Add height and width parameters to core.display.Video #11328

jwkvam opened this issue Sep 23, 2018 · 4 comments
Labels
good first issue Hacktoberfest you want to participate to hacktoberfest ? Here is an easy issue. help wanted
Milestone

Comments

@jwkvam
Copy link

jwkvam commented Sep 23, 2018

I'm viewing some videos in a notebook. The videos are larger than the width of my notebook so I can't see the entire frame unless I scroll left and right. I would like to specify a height and width so I can view the entire frame at once. I think it'd be pretty cool if it could resize automatically, but I'd be happy with the ability to set the height and width.

I can post some pictures if it helps.

ipython --version
6.5.0
jupyter lab --version
0.34.12

I've been doing this work around:

HTML(
    '<video controls width=500>'
    '<source src="video.mp4" type="video/mp4"/>'
    '</video>'
)

It seems like a simple PR, I could make it if you all like this.

@Carreau Carreau added help wanted Hacktoberfest you want to participate to hacktoberfest ? Here is an easy issue. labels Sep 24, 2018
@Carreau
Copy link
Member

Carreau commented Sep 24, 2018

Sure feel free to send a PR if you looked at the code and it seem easy enough.
Feel free to ask if you want some pointers.

You can also wait a few days if you are participating to hacktoberfest.

@IpshitaC
Copy link

IpshitaC commented Oct 1, 2018

Hi @Carreau
Can I take this up for hacktoberfest? Could you give me some pointers for this?

@Carreau
Copy link
Member

Carreau commented Oct 1, 2018

Hi @IpshitaC

The source code for the current Video object can be found here:

class Video(DisplayObject):
def __init__(self, data=None, url=None, filename=None, embed=False, mimetype=None):
"""Create a video object given raw data or an URL.
When this object is returned by an input cell or passed to the
display function, it will result in the video being displayed
in the frontend.
Parameters
----------
data : unicode, str or bytes
The raw video data or a URL or filename to load the data from.
Raw data will require passing `embed=True`.
url : unicode
A URL for the video. If you specify `url=`,
the image data will not be embedded.
filename : unicode
Path to a local file containing the video.
Will be interpreted as a local URL unless `embed=True`.
embed : bool
Should the video be embedded using a data URI (True) or be
loaded using a <video> tag (False).
Since videos are large, embedding them should be avoided, if possible.
You must confirm embedding as your intention by passing `embed=True`.
Local files can be displayed with URLs without embedding the content, via::
Video('./video.mp4')
mimetype: unicode
Specify the mimetype for embedded videos.
Default will be guessed from file extension, if available.
Examples
--------
Video('https://archive.org/download/Sita_Sings_the_Blues/Sita_Sings_the_Blues_small.mp4')
Video('path/to/video.mp4')
Video('path/to/video.mp4', embed=True)
Video(b'raw-videodata', embed=True)
"""
if url is None and isinstance(data, str) and data.startswith(('http:', 'https:')):
url = data
data = None
elif os.path.exists(data):
filename = data
data = None
if data and not embed:
msg = ''.join([
"To embed videos, you must pass embed=True ",
"(this may make your notebook files huge)\n",
"Consider passing Video(url='...')",
])
raise ValueError(msg)
self.mimetype = mimetype
self.embed = embed
super(Video, self).__init__(data=data, url=url, filename=filename)

You will likely need to search how to update the _repr_html_ of it, or it' superclass to have a width= parameter

@Carreau
Copy link
Member

Carreau commented Oct 3, 2018

see #11353, I leave that open, as some improvements are possible, mainly if users are passing string like 10%, 12em it should still be valid sizes.

nestoralonso pushed a commit to nestoralonso/ipython that referenced this issue Oct 19, 2018
…o percentages and other units can be passed
nestoralonso pushed a commit to nestoralonso/ipython that referenced this issue Oct 19, 2018
…o percentages and other units can be passed
@Carreau Carreau added this to the 7.1 milestone Oct 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Hacktoberfest you want to participate to hacktoberfest ? Here is an easy issue. help wanted
Projects
None yet
Development

No branches or pull requests

3 participants