Log in

View Full Version : Any way to improve deinterlacing quality?


VictiniSter
9th January 2024, 05:03
So I got this interlaced video I'm trying to deinterlace however I am curious if there's anyway to further reduce the noticeable artifacts from deinterlacing.

Below are three sets of screenshots to compare the quality of three different deinterlacers (well, two deinterlacers and one field matcher) I've tried TFM, TDeInt, and QTGMC+.

I should clarify that the source I'm working with I believe does not contain progressive frames, I believe most if not all the frames are interlaced.
Here's a five minute sample for anyone to double check (https://mega.nz/file/E94gnJ6a#pFMgW-ZWlJWKUt5L0nP8DVpPXSb-7fJpXLhgkBk5f-k)

The following sets of screenshots are ordered as follows from top to bottom:
- raw (only using source filter)
- TFM
- TDeInt
- QTGMC+

Here are the various function calls I used when using the various deinterlacers, note these were not all in the script at once, just one at a time.

QTGMCp(preset="Slower", FpsDivisor=2)
TDeint()
tfm(PP=5, cthresh=8)

Frame 1:
https://i.ibb.co/857Qwxm/pressure-point-1-raw.png
https://i.ibb.co/518jRwZ/pressure-point-1-tfm.png
https://i.ibb.co/PmD8H6j/pressure-point-1-tdeint.png
https://i.ibb.co/pbhpxTb/pressure-point-1-qtgmcp.png

Frame 2:
https://i.ibb.co/QKkSwyV/pressure-point-2-raw.png
https://i.ibb.co/FqXyhmv/pressure-point-2-tfm.png
https://i.ibb.co/SwStrvH/pressure-point-2-tdeint.png
https://i.ibb.co/PGY37ss/pressure-point-2-qtgmcp.png

Frame 3:
https://i.ibb.co/3yhnh0h/pressure-point-3-raw.png
https://i.ibb.co/tpx8PgY/pressure-point-3-tfm.png
https://i.ibb.co/2g15GcF/pressure-point-3-tdeint.png
https://i.ibb.co/ZGySsC3/pressure-point-3-qtgmcp.png

Frame 4:
https://i.ibb.co/bLnk7fc/pressure-point-4-raw.png
https://i.ibb.co/wW8L6Kp/pressure-point-4-tfm.png
https://i.ibb.co/8jNdbrm/pressure-point-4-tdeint.png
https://i.ibb.co/CWJw6Vv/pressure-point-4-qtgmcp.png

Thanks in advance

Sharc
9th January 2024, 08:34
Taking a look at your 5 minutes sample:
Your source is not really interlaced IMO. It is just flagged as interlaced, but the video is progressive. Fields are pairwise from the same instant in time, means there is no motion between these fields.
Separate the fields and step through the fields and you will see that there is motion with every 2nd field only. If it would be truly interlaced you would see motion with every field advancement.
So deinterlacing is actually moot.
The combs you see on a progressive monitor is because the progressive video is field-shifted. The fields of a frame are taken from different progressive (movie) pictures rather than from the same movie picture. Field matching like TFM() will restore the progressive frames. (QTGMC includes field matching AFAIK ).
Did you somehow process it? Is it a TV recording/capture? If so, what tools did you use?
So my recommendation is to apply TFM(...). There may remain some orphaned fields though which TFM() deinterlaces depending on its post-processing (pp) options. You can also experiment which deinterlacer you want to kick in for best results where no field matches are found by TFM().

Analyzing single frames only can be misleading for drawing general conclusions as your examples above indicate.

VictiniSter
9th January 2024, 16:12
I see what you mean when you say there's only motion on every second field advancement, after adding in the SeparateFields call I see motion on every second frame (I assume every frame corresponds with every field advancement).

This source is a TV capture, it occurred to me that perhaps posting more of the source might be good to gauge what I'm working with in terms of preventing artifacts. The artifacts I'm talking about are where there's some form of outline, in between two full progressive frames, of an object in motion from one full progressive frame to the next. On every field advancement in sections where this artifact is present, you can see a lighter section of the frame moving between field advancements despite there being no motion in the rest of the frame.

Here's a 22 min long sample this time. (https://mega.nz/file/9tRjGAKC#1_jH6PmyJ1tsLYXSOUhLBuQmHM6q_jo3iZURjU_ryOc)

Note that the main places I'm having trouble with getting rid of artifacts are around the 10:22-10:32 mark.

VictiniSter
9th January 2024, 16:51
In the scene of the pilots in the cockpit, it's in the source and it's not field blending. There's nothing you can do about it.

I am referring to the scene with the woman in the cabin as she manipulates an oxygen mask and sits down.

Sharc
9th January 2024, 17:03
I am referring to the scene with the woman in the cabin as she manipulates an oxygen mask and sits down.
As I wrote, don't throw deinterlacers to field-shifted (aka phase-shifted) video. It damages the video. Use Field matching only.
The ugly artifacts (banding and blocking) you are getting are most probably caused by the encoder. Was the encoding (with possibly deinterlacing the source?) done on the fly in real time? It's better to capture lossless or visually lossless and do the encoding offline to give the encoder sufficient time to do a decent job. Maybe it was already flawed in the TV broadcasted version?
There is not much to nil you can do about it now, as I see it.

VictiniSter
9th January 2024, 19:25
I got that artifact while using TFM FWIW with the same settings I put in the OP. My understanding is that TFM does field matching if it detects what it calls a "clean frame" which from my understanding means it doesn't detect enough combing in the frame. When it does detect enough combing that's when TFM performs deinterlacing.

Yeah I had a hunch that the banding and stuff I can't do much about, I'm recording off an h264 stream. Capturing straight from a cable box is a bit out of the question for me.

EDIT: or is it that when it detects a clean frame it just performs post processing and it does field matching when it detects a combed frame?

VictiniSter
9th January 2024, 19:47
If the large .ts you linked is the unprocessed source, then the artifact is in the source, not from TFM.



Sorry I should have been more clear, this is the answer to the question I didn't articulate before: is the artifact from TFM or from the source?



"I'm recording off an h264 stream"

Makes no sense. What are you talking about? How exactly did you generate that .ts file?


As for how I generated the .ts file, I opened a link to a TV stream in VLC Media Player and hit the record button. When looking at the codec information for that stream as it's playing in VLC it says
Codec: H264 - MPEG-4 AVC (part 10) (h264)

I'll be frank I'm quite confused as to how field matching and deinterlacing relate with each other, but after reading more of TFM's docs and this thread, I get the impression field matching and deinterlacing are two different processes correct?

Sharc
9th January 2024, 20:40
I'll be frank I'm quite confused as to how field matching and deinterlacing relate with each other, but after reading more of TFM's docs and this thread, I get the impression field matching and deinterlacing are two different processes correct?
Yes, correct.

VictiniSter
9th January 2024, 21:57
For anyone (including myself) who finds this thread later on, setting the PP (post-processing) parameter of TFM to 0 seems to do field matching, but not look for or do anything with, any combed frames.

VictiniSter
9th January 2024, 21:58
What is "a link to a TV stream"? What link?

A link inside an M3U file, got from github.

Sharc
10th January 2024, 00:04
For anyone (including myself) who finds this thread later on, setting the PP (post-processing) parameter of TFM to 0 seems to do field matching, but not look for or do anything with, any combed frames.
Correct, as per its documentation. It's worth to study it.
Anyway the ugly artefacts have nothing to do with TFM or deinterlacing. It is baked into the video.

hello_hello
11th January 2024, 16:12
I'll be frank I'm quite confused as to how field matching and deinterlacing relate with each other, but after reading more of TFM's docs and this thread, I get the impression field matching and deinterlacing are two different processes correct?

TFM field matches and then de-interlaces when it detects combing. It has several options for adjusting the combing detection.
Metric=1 is often better at detecting very fine combing than the default metric.
For PP=5, 6 or 7, TFM only de-interlaces where combing is detected rather than de-interlacing the whole frame. You can do something like this to see which parts of the frame are being de-interlaced to aid in adjusting TFM's combing detection. The parts of the frame being replaced with red are where combing is detected.

A = last
B = BlankClip(A, color=color_red)
TFM(clip2=B, metric=1)

https://imgur.com/iE12MjO.png

Katie Boundary
1st May 2024, 05:35
If what Sharc says is true, then use tfm(mode=0,pp=0,micmatching=0)

Setting mode and micmatching to 0 will mostly just speed things up slightly with no effect on quality or accuracy. Setting pp to 0 will improve accuracy/quality and also speed things up.