showing original and processed video inline

This commit is contained in:
Aleksey Morozov
2021-07-11 12:46:55 +03:00
parent fc4b701354
commit 04b5b11326
+40 -1
View File
@@ -351,6 +351,25 @@
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import HTML\n",
"from base64 import b64encode\n",
"\n",
"def show_mp4(filename, width=720):\n",
" mp4 = open(filename, 'rb').read()\n",
" data_url = \"data:video/mp4;base64,\" + b64encode(mp4).decode()\n",
" display(HTML(\"\"\"\n",
" <video width=\"%d\" controls autoplay loop>\n",
" <source src=\"%s\" type=\"video/mp4\">\n",
" </video>\n",
" \"\"\" % (width, data_url))) "
]
},
{
"cell_type": "code",
"metadata": {
@@ -564,12 +583,32 @@
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"show_mp4(opt.video_path) # original video"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"img_a_align_crop_pil # swappable face"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Rty2GsyZZrI6"
},
"source": [],
"source": [
"show_mp4(opt.output_path) # processed video"
],
"execution_count": null,
"outputs": []
}