Suggestion for upscaling old 640x480 DVD videos to 1024x768

qtgmc loses a lot of detail.. even with the medium profile, or even fast, without temporal smoothing. the deinterlacer that gave me the best quality is muksun with virtualdub, msu is good too. deinterlacing produces the staircase effect but proteus v4 corrects it well, if you use hybrid, export in ffv1 but in avi, not mkv. mkv loses a little quality.

3 Likes

does not with this settings

2 Likes

I agree you need to use the lossless or near lossless setting in QTGMC and it works very well. For “priming” i.e. cleaning up and deinterlacing an SD 50i/60i compressed source it can work well as a pre-conditioning stage before fully “decompressing” and removing remaining compression artifacts later on in Topaz with a HQ intermediate.

In StaxRip using Avisynth+ 64-bit you can optimize QTGMC quite well for multi-threading which makes those CPU intensive processes work faster by specifying use of all threads or multiple calls for each filter instance and how to divide across cores.

For broadcast quality quality MPEG sources though, not DVD, I’ve found Yadif2mod on balance to be the best from a raw deinterlacing quality standpoint, without needing any special filtering, just pure deinterlacing when working with a high quality SD source. The enhancement can then be handled downstream in Topaz and further restoration in your NLE like Resolve, Premeire Pro or Avid afterwards.

I agree with ssbroly though that the MKV container generally doesn’t look quite as crisp as an MPEG one, i.e. TS, M2TS or Quicktime MOV with mastering quality files. AVI does look better as well but not good for metadata. MKV is fine for an encoded asset for personal library function use. I have most of my Blu-ray discs backed up that way, but it’s not a good container during a serious workflow other than for quickly appending parts and the like.

1 Like

MKV is just a container, that means any quality difference is only a result of your player. For example, my player just shows a gray screen when I play ffv1, but the video is still there and processes correctly in TVAI.

Lossless is lossless.

3 Likes

To be clear I wasn’t disputing that it’s lossless, it’s more efficient. Bits are bits, just that software players don’t look quite as good playing back MKV as they do in an MPEG container. Not that any information is lost or degraded. Clearly it’s just a quirk of how it’s handled and played back by various PC video players. Be it, MPC-HC, MPV etc.

That was all.

Yes lossless is lossless and MKV can hold lossless like FFV1, mp4 can’t. MKV can also hold many other codecs like MPEG (not lossless), so you can’t say MKV is worser, it pends on what is inside, the stream, MKV is just the container.

Agree @njavguy. QTGMC, without significant tweaking can be quite destructive as a pre-processor. I hope this post is not seen as inflammatory since it challenges “common knowledge”. It is written with good intent.

The case against QTGMC as a pre-processor for TVAI


  1. QTGMC needs to do a whole bunch of stuff to reduce the bobbing caused by the NNEDI
. You can see the unpleasant bobbing caused by NNEDI with a very simple test - step through the frames and the horizontal instability in the timecodes and static objects like boxes are just horrible, especially on low-resolution/SD sources where one line of bobbing is more significant than in HD. It is easier to see NNEDI’s shortcomings in FFmpeg

$ ffplay -hide_banner -f 'lavfi' -i "testsrc2=size='ntsc':rate='(60000/1001)':sar='(8/9)', format=pix_fmts='yuv422p', drawtext=text='%{frame_num}':fontcolor='Yellow':x='(main_w-text_w)':y='(main_h-text_h)':box=true:boxcolor='Black':fontsize='(main_h/8)':font='monospace':y_align='font', tinterlace=mode='interleave_bottom', setparams=field_mode='bff'" -vf "nnedi=weights=${HOME}/models/nnedi/nnedi3_weights.bin:'field=bf'"
  1. QTGMC then has to work really hard and perform a bunch of temporal smoothing to try to work around NNEDI’s inherent bobbing / bob-shimmer. It has to calculate a bunch of motion vectors with a bob deinterlacer, and use those MV’s in a subsequent process to work around NNEDI. By default, QTGMC then uses 8-bit only NLMeans (thus killing any 10-bit, which is annoying) and applying per-frame spatial noise reduction. Real temporal noise reduction would be more appropriate, but QTGMC uses Temporal Gaussian blur to tidy up the temporal stuff and then slaps NLMeans (a spatial only noise reduction filter) to further mask temporal artifacts. It then throws in some unsharp-type masking to now try and undo what NLMeans has done. It looks great, but is sub-optimal as a pre-processor. There’s a lot of temporal smoothing, spatial noise reduction and sharpening going on, which is ultimately destructive as an input into TVAI.

QTGMC uses these two processes, plus a bunch of post-process shell-games to make it good for the eye, but while that post-process trickery is great for the eye, but isn’t particularly great as an input into something like TVAI. TVAI does not see frames the way that we see them. NNEDI can be great. QTGMC can use alternate deinterlacers, but QTGMC is a bunch of processors and filters, build on TGMC, which was itself built on working around NNEDI.

QTGMC real super-power is the telecine vs interlace detection and helps avoid the wrong process being applied - especially on hybrid and mixed-mode sources.

In defense of YADIF


The yadif/bwdif family do not suffer from the same bobbing as NNEDI, even though they are still technically line-doublers/bob deinterlacers. For a good source, yadif in field mode sends a really good clean input into TVAI - and TVAI likes a clean input.

yadif is highly unfashionable among the forumistas and has largely fallen out of favor, but since it is both a full-frame deinterlacer and cleans up its own bobbing, it is a better as a pre-process for TVAI. It does not suffer from NNEDI’s very unpleasant bob-shimmer and nor bwdif’s “selective bob-or-weave depending on the macroblock”. bwdif’s selective macroblock bob vs weave struggles with very rapidly moving objects and leaves artifacts on frames. NNEDI and bwdif are both “great to the eye” as final-output deinterlacers, but are sub-optimal pre-processors. What is good for the eye is not necessarily good for the AI / model-based super-resolution. Much of the criticism of yadif pre-dates model-based super resolution, but are now considered lore.

My personal preference in “FFmpeg-speak” is yadif, followed by mcdeint to provide scan-line motion compensation [mcdeint is not a deinterlacer in itself, so still requires yadif to do the field separation].

-vf "yadif=mode=‘send_field’:parity=‘bff’, mcdeint=mode='medium':parity='bff'

If anyone does not believe me around the bobbing, here are a couple of ready-to-paste FFmpeg commands that demonstrate the bobbing issue (assuming that you have NNEDI installed). Step through frame-by-frame, using P to pause and S to frame-step and the horizontal instability is obvious.

NNEDI (and thus inherited by QTGMC)


$ ffplay -hide_banner -f 'lavfi' -i "testsrc2=size='ntsc':rate='(60000/1001)':sar='(8/9)', format=pix_fmts='yuv422p', drawtext=text='%{frame_num}':fontcolor='Yellow':x='(main_w-text_w)':y='(main_h-text_h)':box=true:boxcolor='Black':fontsize='(main_h/8)':font='monospace':y_align='font', tinterlace=mode='interleave_bottom', setparams=field_mode='bff'" -vf "nnedi=weights=${HOME}/nnedi3_weights.bin:'field=bf'"

yadif


% ffplay -hide_banner -f 'lavfi' -i "testsrc2=size='ntsc':rate='(60000/1001)':sar='(8/9)', format=pix_fmts='yuv422p', drawtext=text='%{frame_num}':fontcolor='Yellow':x='(main_w-text_w)':y='(main_h-text_h)':box=true:boxcolor='Black':fontsize='(main_h/8)':font='monospace':y_align='font', tinterlace=mode='interleave_bottom', setparams=field_mode='bff'" -vf "yadif=mode='send_field':parity='bff', mcdeint=mode='medium':parity='bff'"

Now, the horizontal instability and bob-shimmer is more obvious on low-resolution sources like SD, and especially on static objects, on-screen text & chryons.

[and if anyone is doing analog source, dedot is a great pre-process to avoid dot-crawl, and hqdn3d or Neat Video can be used to reduce chroma-plane temporal noise, the curse of digitizations. TVAI is great at spatial noise reduction, but offers no control over “temporal vs spatial” or “luma vs chroma”. So, if dealing with digitized sources, hqdn3d in “temporal-only” mode and heavier temporal chroma than temporal luma reduction really helps TVAI to just focus on what it is good at, which is spatial noise reduction.]

I hope that the cited demonstration commands avoid accusations of trolling.

3 Likes

Thanks a lot! Can you please a tip how to execute this -vf yadif=mode=‘send_field’:parity=‘bff’, mcdeint=mode='medium':parity='bff' works with ffmpeg.exe right? and ffmpeg already can do yadif? where are the paths in/output files? Sorry I’m a script noob.

@Mayday

Try this


$ ffmpeg -i [INFILE] -vf "idet" -f 'null' -



Multi frame detection: TFF:  2 BFF:     65365 Progressive:   124 Undetermined:     2

This will analyze your file and multi-frame detection will make an educated guess about what the vast proportion of your frames are TFF or BFF. It’s not perfect, but will give you an decent indicator. In the example, the vast majority of frames (65365) were interpreted as BFF.

Then, run a simple preprocess with yadif


$ ffmpeg -i "infile.ts" -vf "format=pix_fmts='yuv422p', yadif=mode='send_field':parity='bff', mcdeint=mode='medium':parity='bff'" -codec:v 'ffv1' -level:v 3 -codec:a 'copy' "outfile.yadif.nut"

That should get you a deinterlaced file, with mcdeint motion compensated scan, in FFV1 lossless format, which you can then throw into TVAI.

If you want to add some temporal noise reduction etc, you can add more FFmpeg filters into the filterchain.

$ ffmpeg -hide_banner -sws_flags ‘lanczos+accurate_rnd+full_chroma_int’ -i "infile.ts" -vf "format=pix_fmts='yuv422p', yadif=mode='send_field':parity='bff', mcdeint=mode='medium':parity='bff', hqdn3d=luma_spatial=0.0001:chroma_spatial=0.0001:luma_tmp=4:chroma_tmp=8" -codec:v 'ffv1' -level:v 3 -codec:a 'copy' "outfile.nut"

FFmpeg has lots of useful filters (and many many obscure an potentially damaging filters), which you can research with a LLM or GPT. avisynth/vapoursynth/hybrid is a little more complex again, but has lots of nice stuff like yadif2mod rather than yadif
 but I’m just a simple FFmpeg guy. Useful FFmpeg filters are:

  • colorspace / primaries / trasfer characteristics to modify the colorspace from BT.601 (DVD/SD) to BT.701 (HD). This can avoid colorshift in TVAI.
  • setsar, setdar, scale or zscale to output to square pixels, if you are upscaling to HD.
  • cropdetect, crop, pad, if you do/don’t like padding
  • pixel format conversion to RGB (because TVAI works in RGB anyway, so this avoids TVAI having to do it). After TVAI has done its stuff, TVAI will eventually convert that RGB back to YUV when you output your H.264 (or similar) encode, but on input, TVAI has a strong preference for RGB.

FFmpeg is a complex beast, with complexities around licensing (for example, TVAI’s version of FFmpeg does not include hqdn3d for licensing reasons), so if you want to go down the FFmpeg route you are probably better getting help from a LLM or Reddit rather than this forum.

TVAI uses FFmpeg internally, and there is a “show FFmpeg command in TVAI” which you can do to see what TVAI is really doing under the hood. For legacy models, TVAI is really just a fancy wrapper for a custom build of FFmpeg that has been extended to include a tvai_up filter.

FFmpeg is a learning curve, and some of my nonsense in the post above about the nuances of various deinterlacers and QTGMC isn’t going to make that much difference over and above TVAI’s standard bwdif deinterlacer
. But I deal with old SD stuff, often from analog digitizations, often very noisy (especially temporal, chroma noise), interlaced files tagged as progressive, mixed interlace & telecine, untaggged color spaces etc. Every little optimization and preprocess can make a difference (both in a positive and negative way). Which is why I get a little deep into the weeds on spatial/temporal noise, colorspace, BT.601/BT.701 standards etc.

For standard stuff, TVAI’s built-in bwdif deinterlacer is really quite acceptable.

1 Like