├── README.md └── SOFTWARE.md /README.md: -------------------------------------------------------------------------------- 1 | # How to capture, deinterlace, and encode analog video 2 | 3 | ## Notice 4 | This guide is still a work in progress, some things might not be complete. 5 | 6 | ## Introduction 7 | I've spent about 3 years now trying various methods to get the best captures of old analog video such as VHS and Video8/Hi8 tapes. A lot of what I've read describes ways to do this for old TVs, DVDs, or old computers which just isn't going to cut it in 2018. 8 | I have 3 methods of capturing and encoding. I personally use a mix of the 3 depending on what I'm capturing. 9 | For a capture device I use a Hauppauge USB-Live 2 on Windows 10 64-bit, so these instructions will be based on that. 10 | 11 | ### Interlacing 12 | Analog video is interlaced. Interlacing means each frame of video is split into 2 parts, each called a field. This video is captured and played back at 59.94 fields per second, or 29.97 frames per second for NTSC video. Analog CRT TVs play back interlaced video, but all modern LCD/LED displays only display progressive video. To play interlaced video on a progressive display the video must be deinterlaced or else you'll see jagged lines anywhere there's motion, [like this](https://upload.wikimedia.org/wikipedia/commons/1/19/Interlaced_video_frame_%28car_wheel%29.jpg). 13 | 14 | If you're going to be playing your video on modern displays or upload it to the web you should deinterlace your video! You *can* leave it interlaced and your video player or TV will deinterlace it for you, but most TVs have poor deinterlacing methods. You can use some software to do a much better job. 15 | 16 | ### Encoding 17 | In order to save your video it must be encoded into a video codec. Some examples are H.264, H.265, and VP9. A lot of older guides and some capture software encode video in MPEG2 which is just outdated and doesn't perform nearly as well as H.264. 18 | 19 | ## Method 1 20 | 21 | **Use FFmpeg to capture, deinterlace, and encode your video all at once.** 22 | This method uses little storage space and doesn't require any 2nd processing steps. 23 | 24 | Software: [FFmpeg](SOFTWARE.md#ffmpeg), [Avidemux](SOFTWARE.md#avidemux) (optional) 25 | 26 | 1. Choose a folder you want to save your video to, and hold down shift and right click. 27 | 2. Choose "Open PowerShell window here" 28 | 3. List your capture devices with this command: 29 | ``` 30 | ffmpeg -list_devices true -f dshow -i dummy 31 | ``` 32 | 4. Find the audio and video device that corresponds to your capture device. Mine are `Hauppauge Cx23100 Video Capture` and `Hauppauge Cx23100 Audio Capture`. 33 | 5. Use this command to record your video. Make sure to substitute in your capture devices. 34 | ``` 35 | ffmpeg -f dshow -video_size 720x480 -framerate 29.97 -pixel_format yuyv422 -i video="Hauppauge Cx23100 Video Capture":audio="Hauppauge Cx23100 Audio Capture" -c:v libx264 -crf 18 -aspect 4:3 -vf "yadif=1" -pix_fmt yuv420p -c:a aac -b:a 392k recording.mp4 36 | ``` 37 | 6. Running this command will start capturing right away. To stop press `q`. Since you cannot see a preview I reccomend testing at least once before capturing the full thing. 38 | ### Explanation 39 | - `-f dshow` Use the DirectShow input format, for capture devices on Windows. 40 | - `-video_size 720x480` Set our video side to 720x480, for NTSC video. USe 720x576 for PAL video. 41 | - `-framerate 29.97` Use 29.97 FPS, for NTSC video. Use 25 for PAL video 42 | - `-pixel_format yuyv422` Capture in YUYV 4:2:2 43 | - `-i video="Hauppauge Cx23100 Video Capture":audio="Hauppauge Cx23100 Audio Capture"` Set our input sources 44 | - `-c:v libx264` Set our encoder to x264, which encodes to H.264. 45 | - `-crf 18` Set out output video quality. Lower is better/higher bitrate. See [this](https://slhck.info/video/2017/02/24/crf-guide.html) for more deails on CRF. 46 | - `-aspect 4:3` Set our aspect ratio to 4:3, which mostly all analog video uses. 47 | - `-vf "yadif=1"` Use the yadif deinterlacer and use interpolation to generate 59.94 fps video. You can use `-vf "yadif=0"` instead to generate 29.97 fps video if you don't like the more fluid motion. 48 | - `-pix_fmt yuv420p` Set our output format to YUYV 4:2:0, which is required for most video players. 49 | - `-c:a aac` Set our audio encoder to AAC 50 | - `-b:a 384k` Set our audio bitrate to 384 kilobits/sec 51 | - `recording.mp4` Set the output filename of our recording 52 | 53 | 54 | ## Method 2 55 | **Use AmaRecTV to capture, and FFmpeg to encode and deinterlace.** 56 | This method uses significant disk space as it records to uncompressed AVI. It also takes more time since it requires a 2nd step to encode it to a more efficient format. 57 | 58 | Software: [AmaRecTV](SOFTWARE.md#amarectv-and-huffyuv), [FFmpeg](SOFTWARE.md#ffmpeg), [Avidemux](SOFTWARE.md#avidemux) (optional) 59 | 60 | 1. Open AmaRecTV and verify your video shows up fine. 61 | 2. Click the play button to record and stop when you're done. 62 | 3. You can use the mute and unmute button to monitor your audio. This does not affect your recording. 63 | 4. Optionally use avidemux to cut the begining and end off your video. Make sure to use "Copy" for both the video and audio formats, and save as AVI. 64 | 5. Use ffmpeg to encode your uncompressed video to H.264 video. Make sure to change the input file name. 65 | ``` 66 | ffmpeg -i 'amarec(XXXXXXXXXX).avi' -c:v libx264 -crf 18 -aspect 4:3 -vf "yadif=1" -pix_fmt yuv420p -c:a aac -b:a 384k output.mp4 67 | ``` 68 | The only difference here from above is using `-i filename.avi` instead of DirectShow for the input. 69 | 70 | ## Method 3 71 | **Use AmaRecTV to capture, AviSynth and QTGMC to deinterlace, and FFmpeg to encode.** 72 | This method takes significant disk space and signifcant time to process and encode the video, but it produces the best results. 73 | 74 | Software: [AmaRecTV](SOFTWARE.md#amarectv-and-huffyuv), [AviSynth](SOFTWARE.md#avisynth-and-qtgmc), [FFmpeg](SOFTWARE.md#ffmpeg), [Avidemux](SOFTWARE.md#avidemux) (optional) 75 | 76 | 1. Open AmaRecTV and verify your video shows up fine. 77 | 2. Click the play button to record and stop when you're done. 78 | 3. You can use the mute and unmute button to monitor your audio. This does not affect your recording. 79 | 4. Optionally use avidemux to cut the begining and end off your video. Make sure to use "Copy" for both the video and audio formats, and save as AVI. 80 | 5. Create a text file and save it as `deinterlace.avs` with this content: 81 | ``` 82 | import("C:\Program Files (x86)\AviSynth+\plugins64+\MT.avs") 83 | AviSource("amarec(XXXXXXXX-XXXX).avi").ConvertToYV12() # Enter your file here 84 | AssumeTFF() # Use top field first 85 | QTGMC(Preset="Slow") # Deinterlace 86 | Cnr2() # Reduce chroma noise 87 | DeHalo_alpha() # De-halo 88 | Prefetch(8) # Use 8 threads, enter your CPU thread count here! 89 | ``` 90 | 6. Change your input file name in AviSource and enter your CPU's thread count in Prefetch. 91 | 7. Now use FFmpeg to process this script and encode the video: 92 | ``` 93 | ffmpeg -i 'deinterlace.avs' -c:v libx264 -crf 18 -aspect 4:3 -pix_fmt yuv420p -c:a aac -b:a 384k output.mp4 94 | ``` 95 | This is the same as method 2, but we're omitting the yadif deinterlacer and changing the input file name. 96 | -------------------------------------------------------------------------------- /SOFTWARE.md: -------------------------------------------------------------------------------- 1 | ## Required software 2 | ### FFmpeg 3 | Required for all methods, you must install this to encode or capture any video. 4 | 1. Download ffmpeg from [here](https://ffmpeg.zeranoe.com/builds/). Use numerical version (like 4.0.2), 64-bit, and Static. 5 | 2. Extract the files from `ffmpeg-xxxxxx-win64-static/bin` to `C:\bin\ffmpeg`. You should have `C:\bin\ffmpeg\ffmpeg.exe` now. 6 | 3. In the start menu, search for `environment variables` and choose "Edit the system environment variables". 7 | 4. Click the "Environment Variables" button at the bottom of this window. 8 | 5. Under System Variables, find `Path` and double click it. 9 | 6. Click New on the right, and enter `C:\bin\ffmpeg` 10 | 7. Press OK on all windows to close them. 11 | 8. Done! Now you can use ffmpeg from the command prompt or powershell anyhwere on your system. 12 | 13 | ### Avidemux 14 | Great to have, easy software to cut your video after capturing 15 | Download and install from [http://avidemux.sourceforge.net](http://avidemux.sourceforge.net/download.html). Use the win64 build 16 | 17 | ### AmaRecTV and HuffYUV 18 | Great alternative capture software. Only required for methods 2 and 3. 19 | This only records in raw AVI and does not do any encoding. FFmpeg is required to encode or deinterlace your video. 20 | I also reccomend installing the HuffYUV codec as it reduces the disk space required to record raw AVI. 21 | 22 | 1. Download AmaRecTV from [http://www.amarectv.com](http://www.amarectv.com/english/amarectv_e.htm) and extract it to a folder of your choice. 23 | 2. Download the HuffYUV codec from [here](https://www.videohelp.com/download/huffyuv64.zip) and extract the 2 files to `C:\huffyuv64` 24 | 3. In the start menu, search for `powershell` then right click it and Run as administrator. 25 | 4. Run `cd C:\Windows\SysWOW64\` 26 | 5. Run `rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 0 C:\huffyuv64\huffyuv.inf` to install HuffYUV 27 | 6. Run `AmaRecTV.exe` then press the first button at the top for Config. 28 | 7. Under General, change the folder you want to record to. 29 | 8. Under Graph 1(Device) select your video and audio capture device. Use 720x480, YUY2, and 29.97 fps 30 | 9. Under Graph 2(Preview) select 4:3 aspect ratio and "Not use" for deinterlacing 31 | 10. Under recording, click "Other Codec" and "Update Codec List". Then select HFYU from the list. 32 | 11. Click OK to close. 33 | 34 | ### AviSynth+ and QTGMC 35 | AviSynth is a very powerful tool to process and edit video. This is only needed for method 3. 36 | 1. Download and install AviSynth+ from [http://avs-plus.net](http://avs-plus.net/). Use the reccomended install options. 37 | 2. Download QTGMC [here](https://forum.doom9.org/attachment.php?attachmentid=16429&d=1531449747). Extract it to `C:\Program Files (x86)\AviSynth+\plugins64+` 38 | 3. Download MaskTools2 [here](https://github.com/pinterf/masktools/releases). Extract the contents of `x64` to `C:\Program Files (x86)\AviSynth+\plugins64+` 39 | 4. Download MvTools2 [here](https://github.com/pinterf/mvtools/releases). Extract the contents of `x64` to `C:\Program Files (x86)\AviSynth+\plugins64+` 40 | 5. Download NNEDI3 [here](https://github.com/jpsdr/NNEDI3/releases). Extract the contents of `x64\Release_W7_AVX2` to `C:\Program Files (x86)\AviSynth+\plugins64+` 41 | 6. Download RgTools [here](https://github.com/pinterf/RgTools/releases). Extract the contents of `x64` to `C:\Program Files (x86)\AviSynth+\plugins64+` 42 | 7. Open SMDegrain [here](https://pastebin.com/raw/u1xsPLwK) and save it as `SMDegrain.avsi` into `C:\Program Files (x86)\AviSynth+\plugins64+` 43 | 8. Download PlanarTools [here](https://github.com/chikuzen/PlanarTools/releases). Extract the contents of `x64` to `C:\Program Files (x86)\AviSynth+\plugins64+` 44 | 9. Download Cnr2 [here](https://www.dropbox.com/s/9fiab3s5exi43h2/cnr2_v261-avs26.zip?dl=1). Extract `CNR2_x64.dll` to `C:\Program Files (x86)\AviSynth+\plugins64+` 45 | 10. Download WarpSharp [here](https://github.com/jpsdr/aWarpSharpMT/releases). Extract the contents of `x64\Release_W7_AVX2` to `C:\Program Files (x86)\AviSynth+\plugins64+` 46 | 9. You're done, finally! 47 | --------------------------------------------------------------------------------