This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[HELP] Deinterlacing + Detelecining VFR (Star Trek: Voyager DVD Rips)
#1
Hey everyone. 

Apologies if this topic has already been addressed; I attempted multiple searches of both this forum and the wider Internet without success. 

I’m trying to deinterlace and detelecine my DVD rips of “Star Trek: Voyager”. However, the variable frame rate seems to be confusing Hybrid; I’ve tried using frame duplication in HandBrake to make the frame rate a constant 29.97 fps before processing with Hybrid, but this falsely sets the scan type to progressive (messing up automatic deinterlacing and detelecining in Hybrid) and it also bloats the video size by +25% to the 23.97 fps sections. 

Specifically, when I attempt to feed the raw DVD rips into Hybrid, the output is the wrong length and it has the wrong number of frames. I think the problem is in my TIVTC settings, specifically the TDecimate Mode — the documentation suggests I should use TDecimate Mode 3 for VFR content, but Hybrid only shows TDecimate modes 0, 1, 2, and 7. Also, the Hybrid section within the TDecimate settings says to use option 2 for VFR, but the only options it shows are “no handling”, “blend 30p->24p, keep 24p", and "blend 24p->30p, keep 30p".

A few tips suggested that I split the videos by frame rate so that I have one set of 23.97 fps clips and another set of 29.97 fps clips, but I’ve never heard of a way to do that automatically and it would be unacceptably labor-intensive to do it manually. Plus that just sounds unnecessary. ¯\_(ツ)_/¯ 

Maybe I’m just using the wrong auto deinterlace handler? But my understanding is that TIVTC is the correct choice for content that is both interlaced and telecined. 

Oh, and I need the output to be lossless because this is just a preliminary processing step before I feed the videos into Topaz Video AI’s Artemis LQ 2x upscaling model, after which I then import into Final Cut Pro to add an appropriate amount of simulated film grain using the FilmConvert plugin as well as doing some modest amateur color grading. Then, after all that, I transcode using x265 10-bit RF 18 veryslow. 

Basically, it’s a lot. I’m feeling overwhelmed. I really hope someone here has experience feeding variable frame rate interlaced telecined content into Hybrid, so that they can just tell me what settings to use. But short of that, pointing me in the right direction would also be very helpful. :)
Reply
#2
look https://drive.google.com/file/d/1ymDc9jO...share_link

PS
if you don't understand -how to use this

then everything is bad.
Reply
#3
a. Some older sci-fi dvd like some Star Trek releases (Voyager, DS9,.. all the same trashy authoring) and Babylon 5 are simply a mess.
As far as I know there is no way to handle these properly in an automated way, which is why Hybrid isn't really suited for these. One would have to write one's own scripts to handle these.

b. Hybrid uses MediaInfo to analyze the input, if the input is detected as progressive, means that it is flagged as progressive. So my guess it whatever you do with Handbrake flags the content as progressive.
c. Content on DVDs is always constant frame rate, otherwise those are not standard conform DVDs. The DVD might contain a mix of interlaced, telecined, progressive content, but the frame rate is cfr.

Since you don't want to handle the content properly, you can quick&dirty, deinterlace the content to 29.976 and live with:
a. duplicates for scenes that were telecined or (soft) telecined.
b. duplicates and aliasing for scenes that were progressive 23.976.
c. aliasing for scenes that are progressive 29.976.

Cu Selur

Ps.: Regarding TDecimates modes (https://github.com/pinterf/TIVTC/blob/ma...D%20ME.txt), it is correct that Hybrid does not support the modes which create vfr output.
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#4
Do you have any tips for writing those scripts? Or perhaps just pointing me in the right direction for further research?
Reply
#5
Afaik there is no automated&working way to handle such mixed content properly, so the general idea is probably to. write a script per episode which splits the episode into different parts using trim and then decide per scene what to do (deinterlace, ivtc, copy, frame interpolate,..).

First thing you would need to do is gain a basic understanding of Avisynth or Vapoursynth and the methods that they offer to deal with deinterlacing, telecine handling, etc. . After that, I would recommend to search over at Doom9 and Videohelp for StarTrek, since there have been discussions about handling those DVDs for years. (they pop up from time to time)
You might also want to look into Wollby and Yatta for Vapoursynth/Avisynth and the StarTrek upscale projects which have popped up over the years.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#6
Posting late as this is one of the top results and I've been trying to figure this out myself. I'm not trying to upscale but hopefully you can learn something from this. I have a flawless looking straight up encode.


 Problems

There are two main issues with encoding these DVDs:

1. The content is VFR,

A. encoding to CFR involves dropping or duplicating frames. Dropping down to 23.970 looks terrible and stuttery because you lose frames.
B. Because it's VFR, trying to apply CFR at all (Even adding too many frames) looks bad because the frame times are wrong. Where in the middle of the footage some frames are displayed for 41ms (23.976fps) and some are displayed for 33ms (29.97fps). To increase frames in CFR you'd need to encode into a framerate that divides exactly into both 29.97 and 23.976, even then you'll likely end up with some merged frames (blurry!). If you apply CFR the frame times are stretched to a consistent number for all frames which is why it looks jerky
C. Either way you go, CFR looks bad.

Do not reencode CFR! Keep the variable framerate or it looks awful.

2. The content is telecined

I played around with all kind of inverse telecine filters, almost all the examples online ultimately rely on a `decimate` filter, which drops frames and causes motion issues. However you do it, it will mess with the frame times.

While there may be a way to do this with decimate, ultimately it's not necessary.


Goals

It's worth considering what we want to achieve here. If you do a straight up 1:1 VFR encode without any detelecine filters the motion looks perfect but the telecined frames are jarring.

1. Remove telecine artifacts (deinterlacing the correct frames)
2. We can't deinterlace the progressive frames as that causes new artifacts
3. Keep VFR for the best looking motion

Solution

The solution is the following:

- Detect interlaced frames
- Deinterlace only those frames
- Keep VFR

While I'd played around with VapourSynth a lot, I actually had the best luck with straight up ffmpeg as it doesn't decouple the timecodes from the video making the process a lot tidier.

The follow filter chain in ffmpeg can solve this:

fieldmatch=mode=pc_n_ub:combmatch=full:combpel=70,nnedi=weights=/usr/lib/vapoursynth/nnedi3_weights.bin:deint=interlaced


`fieldmatch` identifies any deinterlaced frames and tags them as iterlaced for the deinterlace filter, the settings above worked for all my samples, I haven't noticed any jarring interlaced frames in playback.

`nnedi` is the deinterlace filter I'm using, specify the path to the weights.bin file. You can use `yadif` or another alternative, nnedi looks better but since it's only on certain frames you're unlikely to tell the difference here. `:deint=interlaced` is important so that only the frames identified by `fieldmatch` are deinterlaced.

I have also verified that this approach doesn't insert any extra frames, extracting a frame before/after a deinterlaced frame so all the frame times are perfect, only the interlaced frames are fixed

(You can extract a frame using
ffmpeg -i "file.mkv" -vf "select=eq(n\,60184)" -vframes 1 60184.png
where 60184 is the number of the frame given by fieldmatch in the output, try comparing the same frame from the source video and the result)

tl;dr here's a script that encodes every file in a directory using those filters, I'm encoding to AV1/Opus but choose your codecs.

#!/bin/sh
for FILE in *; do
  INFILE=$FILE
  OUTFILE="${FILE//mkv/av1\.mkv}"

  if [ ! -f "$OUTFILE" ]; then
        if [[ ${INFILE} != *".av1.mkv"* ]]; then
        ffmpeg  -i "$INFILE" \
            -vf "fieldmatch=mode=pc_n_ub:combmatch=full:combpel=70,nnedi=weights=/usr/lib/vapoursynth/nnedi3_weights.bin:deint=interlaced" \
            -ac 6 \
            -map_metadata 0 \
            -pix_fmt yuv420p10le \
            -c:v libsvtav1 -crf 24 -preset 3 -c:a libopus -b:a 384k -c:s copy \
            -map "0:v"  -map "0:a" -map "0:s"  \
            "$OUTFILE"
        fi
    fi
done



edit: If you want the output to be lossless so you can work on it, use `-c:a copy` to use the existing audio and `-c:v ffv1` be warned though that the file sizes will be huge.
Reply
#7
THANK YOU SO MUCH. 

To address an assertion made here: https://www.extremetech.com/extreme/3249...-dont-work

Did you have your success on rips made using MakeMKV?
Reply
#8
For this purpose I want VFR so makemkv is doing what I want.

If you want to do postprocessing with vapoursynth you'd need to encode to ffv1 (or pipe) then extract the timecodes from the source, create a new file with your filters applied (it will play back at the wrong speed), then mux together the audio and timecodes from the source with the filtered (wrong speed) video. You won't be able to apply any filters that add or remove frames but colour correction and single frame image processing will be fine.

I don't actually know exactly how to do this but it is possible.
Reply
#9
Additionally: https://forum.videohelp.com/threads/4092...rogressive

Personally: DVD content is always cfr not vfr. So I think using the time codes from the mkv created by MakeMKV is the wrong approach.
That said, have fun, but please move further not Hybrid discussion to a separate thread in the 'A/V Talk' section. Thanks!

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#10
This might be a silly question, but why not just use TIVTC with the deinterlacer set to QTGMC, with PNG output that I then stitch back up into a video, then apply the original video's timestamps?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)