<jupyter_start><jupyter_text>Displaying Video in IPython Notebook<jupyter_code># Import the required modules
%pylab inline 
import cv2
from IPython.display import clear_output
# Grab the input device, such as webcam or video file
vid = cv2.VideoCapture("videos/Vincent-Van-Gogh-in-Google-Deep-Dream.mp4")

while(True):
    # Capture frame-by-frame
    ret, frame = vid.read()
    if not ret:
        # Release the Video Device if ret is false
        vid.release()
        # Message to be displayed after releasing the device
        print("Released Video Resource")
        break

    # Convert the image from OpenCV BGR format to
    # matplotlib RGB format to display the image
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

    # make the out put look like a video display
    axis('off')             # Turn off the axis
    title("Input Stream")   # Title of the window

    # Display the frame within matplotlib
    imshow(frame)
    show()

    # Display the frame until new frame is available
    clear_output(wait=True)

    # keyboard entry of 'q' or esc key to stop
    k = cv2.waitKey(1)
    if chr(k & 255) == 'q' or k == 27:
        vid.destroyAllWindows()
        vid.release()
        break
from IPython.display import Image

image = Image('/home/jeff/Jupyter-Notebooks/DataSets/Images/jemma.png')
image<jupyter_output><empty_output><jupyter_text>Video from YouTube<jupyter_code>from IPython.display import YouTubeVideo
# a talk about IPython at Sage Days at U. Washington, Seattle.
# Video credit: <NAME>.
YouTubeVideo('1j_HxD4iLn8')
from IPython.display import HTML
from base64 import b64encode
video = open("/home/jeff/tmp/animation.m4v", "rb").read()
video_encoded = b64encode(video)
video_tag = '<video controls alt="test" src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
HTML(data=video_tag)<jupyter_output><empty_output><jupyter_text>Below is a video of the above code in action.<jupyter_code>%%html
<!-- TODO -->
<iframe width="560" height="315" src="https://www.youtube.com/embed/2TT1EKPV_hc" frameborder="0" allowfullscreen></iframe><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10603899191631003, 'fraction_numerical': 0.017118402282453638, 'mean_word_length': 3.8816705336426915, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '377380', 'license': 'Unlicense', 'n_tokens_mistral': 710, 'n_tokens_neox': 681, 'n_words': 196, 'path': 'notebooks/Using Jupyter/displaying-video-in-ipython-notebook.ipynb', 'repo_name': 'jeffskinnerbox/computer-vision', 'size': '2110'}