{ "cells": [ { "cell_type": "markdown", "id": "9416c1c1", "metadata": {}, "source": [ "# Video example\n", "\n", "**This example depends on imageio and imageio-ffmpeg.**\n", "\n", "Plays a video as fast as it can. This will be quite a slow playback on localhost. On a remote server it will be even slower." ] }, { "cell_type": "code", "execution_count": 1, "id": "19dd4c54", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "227f7e729f224496a029f0abf1580c7d", "version_major": 2, "version_minor": 0 }, "text/plain": [ "OutputContext()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
initial snapshot
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "529221f8e2e64d308ba5f760e8f9e9d8", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VideoPlayer()" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import imageio\n", "import numpy as np\n", "from jupyter_rfb import RemoteFrameBuffer\n", "\n", "r = imageio.get_reader(\"imageio:cockatoo.mp4\", \"ffmpeg\")\n", "\n", "class VideoPlayer(RemoteFrameBuffer):\n", " \n", " def get_frame(self):\n", " v.request_draw()\n", " return r.get_next_data()\n", "\n", "\n", "v = VideoPlayer(max_buffered_frames=3)\n", "v" ] }, { "cell_type": "code", "execution_count": null, "id": "b603178b", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.1" } }, "nbformat": 4, "nbformat_minor": 5 }