Last active
May 9, 2021 23:39
-
-
Save lunaisnotaboy/f003faab394cbef9d189252bcb0c83b6 to your computer and use it in GitHub Desktop.
Video2x with YouTube-DL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Video2X_on_Colab.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"accelerator": "GPU" | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/lunaisnotaboy/f003faab394cbef9d189252bcb0c83b6/video2x_on_colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "TZc9KswXw0R7" | |
}, | |
"source": [ | |
"This is an example playbook for using Google Colab with Video2X. Press Shift+Tab to run a line. All ncnn-vulkan upscalers are supported currently\n", | |
"\n", | |
"Be sure to select a GPU instance under \"Runtime\" above. Depending on the instance you get the speed of upscaling will vary a lot.\n", | |
"\n", | |
"Be warned: Colab is free to use, but also requires users to not abuse it!\n", | |
"\n", | |
"In this example a short clip will be upscaled and uploaded to your Google Drive. You will need to enter an authorization key at the last step!" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "KHWzMi7epefm" | |
}, | |
"source": [ | |
"!apt install ffmpeg\n", | |
"!apt install libmagic1 python3-yaml\n", | |
"!apt install libvulkan-dev\n", | |
"!pip install --user youtube-dl " | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "J_HgTNbqsb7b" | |
}, | |
"source": [ | |
"!git clone https://github.com/k4yt3x/video2x.git" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "AYqbe1d-s_Qd" | |
}, | |
"source": [ | |
"import os\n", | |
"os.chdir('video2x/src')\n", | |
"!git checkout 4.7.0\n", | |
"!pip install -r requirements.txt\n", | |
"!rm -rf video2x.yaml\n", | |
"!wget -O video2x.yaml http://akas.io/v2xcolab\n", | |
"os.chdir('../..')" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "L-B9cbd3svK3" | |
}, | |
"source": [ | |
"!wget https://github.com/nihui/realsr-ncnn-vulkan/releases/download/20200818/realsr-ncnn-vulkan-20200818-linux.zip\n", | |
"!7z x realsr-ncnn-vulkan-20200818-linux.zip\n", | |
"!wget https://github.com/nihui/waifu2x-ncnn-vulkan/releases/download/20200818/waifu2x-ncnn-vulkan-20200818-linux.zip\n", | |
"!7z x waifu2x-ncnn-vulkan-20200818-linux.zip\n", | |
"!wget https://github.com/nihui/srmd-ncnn-vulkan/releases/download/20200818/srmd-ncnn-vulkan-20200818-linux.zip\n", | |
"!7z x srmd-ncnn-vulkan-20200818-linux.zip" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "rS7V937Geyqr" | |
}, | |
"source": [ | |
"Replace the link with the YouTube (or any other site YT-DL supports) link you want to use." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "aG7elRJztDwm" | |
}, | |
"source": [ | |
"!sh -c '/root/.local/bin/youtube-dl https://www.youtube.com/watch?v=X8TCB9s1kRs -f mp4 -o video.mp4'" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "CGcpvH3vtEmX" | |
}, | |
"source": [ | |
"!pip install -U PyYAML\n", | |
"!python video2x/src/video2x.py -i /content/video.mp4 -o video_4x.mp4 -d waifu2x_ncnn_vulkan -r 4.0" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "cPhLseBZxhEN" | |
}, | |
"source": [ | |
"Enter your authorization key below. Just follow the steps :)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "sCQAsq2SuN4H" | |
}, | |
"source": [ | |
"from google.colab import drive\n", | |
"drive.mount('/content/gdrive')\n", | |
"!cp video_4x.mp4 \"gdrive/My Drive/video_4x_2.mp4\"" | |
], | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment