README.md Loading last commit info...
bm3d-qtgmc.vpy
process.sh
README.md

MiniDV2mkv


These instructions are for PAL tapes. You can encode according to you preferences after the denoise + deinterlacing step. If you denoise, you should add artificial noise in the encode step to keep the original look and mask some of the denoising artifacts. You could also skip denoising and instead encode at a much lower CRF. This keeps the original noise but you get huge files if you don't want to destroy all the noise.

Capture raw data

You will need a PC with an IEEE 1394 (firewire) port running linux. Connect to your camera over IEEE 1394. Then run:

dvgrab --timestamp --size 0 --rewind --srt --showstatus dv-

You will get a .dv file which contains the raw data from the tape. You will also get a .srt0 file which contains the timestamp as subtitles. You should save these.

mkv master

This creates a lossless master with corrected timing and correct color metadata. Use this file when processing further to avoid issues. The video will be encoded with ffv1 and audio with FLAC. Both are lossless. You should permanently keep either this mkv or the .dv file.

ffmpeg -i .\dv-*.dv -vf "setparams=colorspace=bt470bg:color_primaries=bt470bg:color_trc=bt709,format=yuv422p,setfield=bff" -color_range tv -chroma_sample_location center -c:v ffv1 -level 3 -g 1 -c:a flac -sample_fmt s16 master.mkv

Denoise using BM3D and Deinterlace using QTGMC

This step should be done on a machine with a GPU to save a significant amount of time.

You need to have vapoursynth installed and the bestsource, vsjetpack, mvtools, znedi3, bm3d and fmtconv plugins installed. On Arch you can install everything with:

yay -Syu vapoursynth vapoursynth-plugin-bestsource vapoursynth-plugin-vsjetpack-git vapoursynth-plugin-mvtools vapoursynth-plugin-znedi3-git vapoursynth-plugin-bm3d-git vapoursynth-plugin-fmtconv-git

Copy the bm3d-qtgmc.vpy and master.mkv to the working directory. Then run:

vspipe -c y4m --arg input_file=master.mkv bm3d-qtgmc.vpy - | ffmpeg -f yuv4mpegpipe -i - -i master.mkv -c:v ffv1 -level 3 -g 1 -pix_fmt yuv422p -vf setsar=16/15 -c:a copy denoised_deinterlaced.mkv

Encoding

av1an

You can change the preset and CRF based on the encode speed and quality you want. Use the lowest preset you can tolerate and the highest CRF where you can't notice any quality loss.

You can set -w to at most half of you CPU cores. You may need to lower it if you do not have enough RAM.

If you did not denoise, remove the film grain parameter and use a much lower CRF.

You may want to use more film grain according to your preferences. 10 is enough to mask most of the denoising artifacts, but is quite a lot less noise than the original. If you want to stay closer to the original look, you should use a higher value.

MiniDV actually has lossless audio, so if you want to keep the lossless FLAC, you can change to -a "-c:a copy".

ulimit -n 200000 && av1an -i "denoised_deinterlaced.mkv" --verbose --sc-pix-format=yuv420p --resume --temp "av1an-temp-$(tr -dc A-Za-z0-9 </dev/urandom | head -c20)" --split-method av-scenechange -m bestsource -c mkvmerge --sc-downscale-height 1080 -e svt-av1 --force -v "--tune 0 --enable-qm 1 --keyint 250 --irefresh-type 1 --tile-columns 0 --tile-rows 0 --film-grain 10 --preset 0 --crf 20" --pix-format yuv420p10le -f "-y" -a "-c:a libopus -b:a 128k" --set-thread-affinity 2 -w 8 -o "encode.mkv"

When resuming a previously partially completed encode, set --temp to the directory that was used for the partial encode.

Embed subtitles

mkvmerge -o final.mkv encode.mkv dv-*.0.srt

Fix SAR

mkvpropedit final.mkv --edit track:v1 --set display-width=768

Automate .dv processing

Once you have verified that the above works, you can just copy process.sh and bm3d-qtgmc.vpy to a folder with the .dv file and run process.sh after dvgrab. If you made any tweaks to the above commands, also edit process.sh.

chmod +x process.sh && ./process.sh
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover