Repository: ipython/ipython

Issue:
Add height and width parameters to core.display.Video
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.


Discussion:
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](http://hacktoberfest.digitalocean.com/).
Hi @Carreau 
Can I take this up for hacktoberfest? Could you give me some pointers for this?
Hi @IpshitaC 

The source code for the current Video object can be found here:

https://github.com/ipython/ipython/blob/94b894de4cef5b0e3cfb666d5328749205980d37/IPython/core/display.py#L1257-L1317

You will likely need to search how to update the `_repr_html_` of it, or it' superclass to  have a `width=` parameter


Resolving patch:
diff --git a/IPython/core/display.py b/IPython/core/display.py
--- a/IPython/core/display.py
+++ b/IPython/core/display.py
@@ -1256,7 +1256,8 @@ def _find_ext(self, s):
 
 class Video(DisplayObject):
 
-    def __init__(self, data=None, url=None, filename=None, embed=False, mimetype=None):
+    def __init__(self, data=None, url=None, filename=None, embed=False,
+                 mimetype=None, width=None, height=None):
         """Create a video object given raw data or an URL.
 
         When this object is returned by an input cell or passed to the
@@ -1288,6 +1289,12 @@ def __init__(self, data=None, url=None, filename=None, embed=False, mimetype=Non
         mimetype: unicode
             Specify the mimetype for embedded videos.
             Default will be guessed from file extension, if available.
+        width : int
+            Width in pixels to which to constrain the video in HTML.
+            If not supplied, defaults to the width of the video.
+        height : int
+            Height in pixels to which to constrain the video in html.
+            If not supplied, defaults to the height of the video.
 
         Examples
         --------
@@ -1314,16 +1321,24 @@ def __init__(self, data=None, url=None, filename=None, embed=False, mimetype=Non
 
         self.mimetype = mimetype
         self.embed = embed
+        self.width = width
+        self.height = height
         super(Video, self).__init__(data=data, url=url, filename=filename)
 
     def _repr_html_(self):
+        width = height = ''
+        if self.width:
+            width = ' width="%d"' % self.width
+        if self.height:
+            height = ' height="%d"' % self.height
+
         # External URLs and potentially local files are not embedded into the
         # notebook output.
         if not self.embed:
             url = self.url if self.url is not None else self.filename
-            output = """<video src="{0}" controls>
+            output = """<video src="{0}" controls {1} {2}>
       Your browser does not support the <code>video</code> element.
-    </video>""".format(url)
+    </video>""".format(url, width, height)
             return output
 
         # Embedded videos are base64-encoded.
@@ -1342,10 +1357,10 @@ def _repr_html_(self):
         else:
             b64_video = b2a_base64(video).decode('ascii').rstrip()
 
-        output = """<video controls>
- <source src="data:{0};base64,{1}" type="{0}">
+        output = """<video controls {0} {1}>
+ <source src="data:{2};base64,{3}" type="{2}">
  Your browser does not support the video tag.
- </video>""".format(mimetype, b64_video)
+ </video>""".format(width, height, mimetype, b64_video)
         return output
 
     def reload(self):


Test patch: