From 4c59824e5d8c4af3a4f91161c14aa162cff64a55 Mon Sep 17 00:00:00 2001 From: Hansly Saw <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 8 May 2022 21:08:26 +0800 Subject: [PATCH] Removed blender file file name reference in the picture viewer + added video viewer utility. --- BlenderRender.ipynb | 48 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/BlenderRender.ipynb b/BlenderRender.ipynb index 9318224..9a03eca 100644 --- a/BlenderRender.ipynb +++ b/BlenderRender.ipynb @@ -271,7 +271,7 @@ "\n", "def fixFormatImage(): \n", " ## Give file format of png if the user didn't give any. Of course they should put it. \n", - " if getExtension(fileViewer.image_fileName) == None: blend_fileName = (str(blend_fileName) + '.png')\n", + " if getExtension(fileViewer.image_fileName) == None: fileViewer.image_fileName = (str(fileViewer.image_fileName) + '.png')\n", "\n", "def preview(): \n", " clear()\n", @@ -287,6 +287,52 @@ "main()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#@title Video Viewer\n", + "#@title Configuration\n", + "class formatting:\n", + " clear = '\\033[0m'\n", + " class color: \n", + " purple = '\\033[95m'\n", + " cyan = '\\033[96m'\n", + " cyan_dark = '\\033[36m'\n", + " blue = '\\033[94m'\n", + " green = '\\033[92m'\n", + " yellow = '\\033[93m'\n", + " red = '\\033[91m'\n", + " class font:\n", + " bold = '\\033[1m'\n", + " underline = '\\033[4m'\n", + "\n", + "## Define screen functions. \n", + "def clear(): from IPython.display import clear_output; return clear_output()\n", + "\n", + "class fileViewer: \n", + " video_fileName = '' #@param {type: \"string\"}\n", + "\n", + "def fixFormatVideo(): \n", + " ## Give file format of png if the user didn't give any. Of course they should put it. \n", + " if (getExtension(fileViewer.video_fileName) == None or getExtension(fileViewer.video_fileName) == ''): fileViewer.video_fileName = (str(fileViewer.video_fileName) + '.avi')\n", + "\n", + "def preview(): \n", + " clear()\n", + " try: \n", + " from IPython.display import Video\n", + " Video(fileViewer.video_fileName, embed=True)\n", + " except:\n", + " info.err(formatting.font.bold + 'Could not preview the video. ' + formatting.clear + 'Make sure that the file is present and that the file format is correct.')\n", + "\n", + "def main(): \n", + " fixFormatVideo(); preview()\n", + "\n", + "main()" + ] + }, { "cell_type": "code", "execution_count": null,