In this tutorial, I will explain how to upscale videos from a low resolution to a higher resolution such as 1080p or 4K using neural networks.
This is an improved and streamlined version of the tutorial I posted previously. Instead of using multiple programs to do all of the steps, this tutorial makes do with only two programs: AI Gigapixel by Topaz Labs and FFmpeg.
This tutorial is written for Windows users. Both programs will work for Mac though.
There is a free 30-day trial available for AI Gigapixel, so you can try it out for yourself. After the trial has ended it normally costs $99.99 for a lifetime license. As an official affiliate, I can give you a 15% discount. This means it's only $84.99. To get the discount, enter the coupon code captrobau15 during checkout.
You can download the free trial or purchase AI Gigapixel here.
Installation is easy, just follow the installer's instructions.
You can download FFmpeg for free here.
Extract the zip file. You will use the ffmpeg.exe later.
This is an improved and streamlined version of the tutorial I posted previously. Instead of using multiple programs to do all of the steps, this tutorial makes do with only two programs: AI Gigapixel by Topaz Labs and FFmpeg.
This tutorial is written for Windows users. Both programs will work for Mac though.
Step 1. Download and install the programs
AI Gigapixel
This program by Topaz Labs is a paid program, but it is one of the best methods for upscaling photos and video. It uses a neural network which analyzes thousands of photos to learn how details generally get lost when downscaling. The algorithm "learns" how to fill in the details in new images based on what is learned from the photos it was trained on. This machine learning allows Gigapixel to add new detail to these images.There is a free 30-day trial available for AI Gigapixel, so you can try it out for yourself. After the trial has ended it normally costs $99.99 for a lifetime license. As an official affiliate, I can give you a 15% discount. This means it's only $84.99. To get the discount, enter the coupon code captrobau15 during checkout.
You can download the free trial or purchase AI Gigapixel here.
Installation is easy, just follow the installer's instructions.
FFmpeg
While Gigapixel helps you upscale your video, you will need FFmpeg to extract the frames and audio from the original and put the upscaled video back together. This is a command-line program, but I will guide you through all the commands below.You can download FFmpeg for free here.
Extract the zip file. You will use the ffmpeg.exe later.
Step 2. Prepare your workspace
To make the upscaling process more efficient, I suggest you make an orderly workspace somewhere on your computer. I'm going to make a folder on my desktop called 'upscale-projects'. Make another folder in 'upscale-projects' for your first project. In my example, I will call it 'example', and I will be upscaling an episode of Star Trek: Deep Space Nine.
Within your project folder, make three folders:
- frames-original
- frames-upscaled
- video
In the next couple of steps, we will fill those folders with audio, images, and videos.
Keep in mind that extracting an entire episode or movie requires quite a bit of free space on your hard drive. One 45 minute episode needs 29 GB for the original frames. If you upscale to 1080p that will add another 72 GB. If you upscale to 4K you will need around 180 GB for an episode's worth of frames. And finally, you will need about 1 GB or more for the exported episode. So make sure you have enough room on your PC.
Step 3. Export The Frames Of The Source Video
You will use FFmpeg to extract the individual frames of the source video. This is the tutorial I used, which tells you about more options.
How to export the source video:
How to export the source video:
- Get your source video and put it into example/video
- Put ffmpeg.exe in the folder you also put your source video into.
- Open up command prompt (cmd)
- In cmd, navigate to the work folder. Do this by typing in: cd C:\Users\UserName
\Desktop\upscale-projects\example\video. The part after cd depends on where your work folder is of course. - Now you will give FFmpeg the command to export the frames. Type in:
ffmpeg -i example.mkv example%04d.png -hide_bannerWhat does this all mean?
- example.mkv is the source file in my case. Change it to the name and extension of your source video file.
- example%04d tells FFmpeg how to name the frames (example0001.png, example0002, etc.). Adding text before the frame number helps to keep multiple video's worths of extracted frames organized.
- .png is the extension of the exported file. PNG is bigger than JPG, but JPG creates extra artifacts that the upscaling program can't handle very well. So the lossless PNG format is preferred.
- -hide_banner hides FFmpeg compilation information. Personal preference.
When you press enter on the filled in command, FFmpeg will get to work. This will take a while, depending on the length of the video and the original resolution.
Once you've installed the program, open it up. Drag one of the exported frames to the middle of the program's window. You will then be shown something that looks like the screenshot below.
Below I will explain what all the settings mean:
Once you have a working set of settings, you can start upscaling footage. Select a few hundred frames when first getting your footing with this whole workflow and drag and drop them in the window. Upscaling an entire episode can take a long time, so start small.
How many frames you can upscale in one go depends on your PC's specs. It can be 1000s, 10000s, etc. You'll just have to find out for yourself. How fast the entire upscaling process also depends on your PC. It could take a day/multiple days to convert an entire episode/movie depending on the length and the upscaled resolution (4K takes a lot longer than 1080p).
You can download the free trial or purchase AI Gigapixel here.
Step 3. Upscale The Frames To 1080p/4K
You will use AI Gigapixel to upscale the frames from the SD original. There's a lot of things you can with Gigapixel, but in this tutorial, I will focus on the settings that are most suitable for most SD footage.Once you've installed the program, open it up. Drag one of the exported frames to the middle of the program's window. You will then be shown something that looks like the screenshot below.
Click to enlarge |
- You can base the upscale's resolution by scale, width or height. I chose height, because...
- I want to make the upscaled image have the height of 4K footage, so I input 2160 pixels. Full HD has a height of 1080 pixels.
- Suppress Noise and Remove Blur can improve the quality of the end result. This really depends on the project. Just try out everything to see what gives the best result for your project. I chose Low and Low, as it gave just a bit of smoothing/noise removal without going overboard.
- I save to a Custom Folder and point it to upscale-projects\example\frames-upscaled. Ignore Prefix and Suffix.
- For video it's best to output in JPG format. It is smaller and results in a fast upscale process. Since the original is PNG, you will need to choose Convert File Format: Yes. The few artifacts created by the JPG format at Maximum Quality won't be noticed when you later convert the frames to a video.
- Keep Color Profile to Yes, as it's faster.
Once you have a working set of settings, you can start upscaling footage. Select a few hundred frames when first getting your footing with this whole workflow and drag and drop them in the window. Upscaling an entire episode can take a long time, so start small.
How many frames you can upscale in one go depends on your PC's specs. It can be 1000s, 10000s, etc. You'll just have to find out for yourself. How fast the entire upscaling process also depends on your PC. It could take a day/multiple days to convert an entire episode/movie depending on the length and the upscaled resolution (4K takes a lot longer than 1080p).
Step 4. Exporting The Audio Of The Video
While the frames are being upscaled in the background, you can go ahead and do other things. For example, ripping the audio from the original video file using FFmpeg. This is the tutorial I used for this part.
Perform the following steps:
- Open up command prompt (cmd)
- In cmd, navigate to the work folder. Do this by typing in: cd C:\Users\UserName
\Desktop\upscale-projects\example\video. - Now you will give FFmpeg the command to export the audio. Type in:
ffmpeg -i original-video.mkv -vn -acodec copy original-audio.wavWhat does this mean?
- example.mkv is the source file in my case. Change it to the name and extension of your source video file.
- vn means no video.
- acodec copy tells FFmpeg to use the same audio stream that's already in there.
- original-audio.wav is the name of the exported file. I chose .wav as a file format, because it is the most generally supported lossless codec.
When you press enter on the filled in command, FFmpeg will get to work. It should take at most a few minutes.
Step 5. Combining The Frames And Audio Into A Video
Once AI Gigapixel is done upscaling the frames, you can combine these frames with the audio into a video. I used this tutorial for this section.
- Move the exported audio file to example/frames-upscaled
- Copy ffmpeg.exe into the example/frames-upscaled folder
- Open up command prompt (cmd)
- In cmd, navigate to the work folder. Do this by typing in: cd C:\Users\UserName
\Desktop\upscale-projects\example\frames-upscaled. The part after cd depends on where your work folder is of course. - Now you will give FFmpeg the command to combine the frames and the audio. Type in:
ffmpeg -r 29.970628 -f image2 -s 1440x1080 -i example%04d.jpg -i original-audio.wav -vcodec libx264 -crf 20 -pix_fmt yuv420p -acodec copy upscaled_video.mp4What do these commands mean?
- -r is the frame rate of the exported file. 29.970628 is a common fps for older American shows, but it could be 24, 30, or 60. It depends on the original video's frame rate.
- -s is the resolution. This should be the same as the upscaled images, in my case 1440x1080.
- example%04d.jpg is the way the frames you upscaled are named. Change example to the text you chose in step 3.
- original-audio.wav is the audio file you want to combine with the frames into a video.
- vcodec libx264 is the codec you're using. Libx264 is a widely supported codec, so a safe bet.
- -crf is the quality of the video. The lower number the higher the quality but the larger the file size, with a range of 15-25 a good trade-off between file size and quality.
- -pix_fmt determines the pixel format. I chose yuv420p because it is one of the most compatible pixel formats.
- -acodec copy tells FFmpeg to copy the audio from the input stream (the .wav file) to the output stream (the video)
- upscaled_video.mp4 is the name of the output video file.
Press enter to start generating the video file. This can take several minutes to complete, depending on the length of the video and the video quality (crf) chosen.
Once it's done, your upscaled video is ready to be watched, shared and enjoyed!
Interested in AI Gigapixel?
Did this tutorial interest you in Topaz's AI Gigapixel? There is a free 30-day trial available for AI Gigapixel, so try it out for yourself.
Normally costs $99.99 to purchase for a lifetime license. As an official affiliate, I can give you a 15% discount.
This means it's only $84.99. To get the discount, enter the coupon code captrobau15 during checkout.
You can download the free trial or purchase AI Gigapixel here.
Comments
In this case nvidia tends to fare better as it customarily has better clock speeds, so I'd look for an upgrade that took that into account.
My task manager also curiously (at least for me and I'm not specially tech savvy) accounts the work gigapixel is doing as "3D" so maybe the research into which would be the best GPU to upgrade to could take info from reccomendations for GPUs that render 3D well
There were over 30,000 frames, and on my 2080ti it took nearly 40 hours. On import, any batch larger than a few thousand frames took a long time to load in to ai gigapixel, but eventually loads all the frames.
If you want to see the result, check out here https://imgur.com/a/4Jxy3bb
The whole episode is also up on tpb
I tryed Megapixel AI on an Anime scene and it seems not that good with drawed content.
Much Artefact in the middle of the scene.
With wifu2x i got an better result.
I tryed also dubble scaling. First wifu2x and second Gigapixel AI.
http://www.framecompare.com/image-compare/screenshotcomparison/PY6PNNNX
The quality might not be quite as good as Topaz AI Gigapixel but it's totally free and automates the entire process (as long as you're comfortable using the command line on Windows).
i just get an error message saying ffmpeg is not a recognised internal or external command
thanks in advance for any answer. If yes give me some contact to you as email.
My question is: If i delete some frames and video becomes shorter, how to fit audio and trim it on the end of video?
Also, does anyone have experience extracting multiple audio tracks? My video has a passthrough of AC3 and a stereo downmix track.
To extract audio tracks, assuming it's an MP4, mkv, ts, or m2ts file, use mkvtoolnix to save audio tracks to .mka files, and remux those back in to your output video when finished. Remuxing takes about as long as it takes to copy and paste the video, so not long. Hope this helps