View Full Version : Progressive NTSC Wrong AR Clip from DVD
TruthOverFacts
13th January 2022, 08:53
The content is supposed to be 4x3 SD and I don't know the exact terminology but they basically authored it with as a 16x9 DVD so it's like a BluRay file incorrectly resized for a DVD. I hope that makes sense. Also it appears to be 29.97 progressive. What I'd like to accomplish is get this back to 4x3 SD 23.976 progressive.
Here are two different clips from it:
https://www.mediafire.com/file/di9dhkxafbd3hx9/Clip1.mpg/file
https://www.mediafire.com/file/22jalw1z6l92ucf/Clip2.mpg/file
Thank you all in advance
FranceBB
13th January 2022, 09:27
It's progressive with repeated frames, so TDecimate will do it.
As to the black borders, you can crop them.
You can do something like:
#Indexing
FFVideoSource("\\mibctvan000.avid.mi.bc.sky.it\Ingest\MEDIA\temp\Clip1.mpg")
#Going back to 23,976p
TDecimate(cycler=1, cycle=6)
AssumeFPS(24000,1001,sync_audio=true)
ResampleAudio(48000)
#Getting rid of black bars
Crop(118, 4, -118, -4)
#Black level adjustment
Levels(10, 1.0, 240, 0, 255)
#Temporal Degrain
super = MSuper(pel=2, sharp=1)
bv1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
fv1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
bv2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
fv2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
MDegrain2(super,bv1,fv1,bv2,fv2,thSADC=800, thSAD=800)
#Despot
SpotLess(RadT=6, ThSAD2=900, pel=4, chroma=true)
so that it goes from this:
https://i.imgur.com/7qtXPDL.png
to this:
https://i.imgur.com/6JsbesG.png
EDIT: thanks for pointing out the cadence, poison and Stainless.
tormento
13th January 2022, 09:48
You need to set SAR in your encoder of choice too, if it's an anamorphic video.
For PAL it usually works with 64:45, I don't know for NTSC, in your case.
FranceBB
13th January 2022, 10:13
You need to set SAR in your encoder of choice too, if it's an anamorphic video.
Yep. He could resize it to anamorphic again and set the right flag too so that it will be more compliant.
I don't know for NTSC.
Same here, we live in PAL-Land (and even only few km apart) after all eheheheheh
SeeMoreDigital
13th January 2022, 11:34
You need to set SAR in your encoder of choice too, if it's an anamorphic video.
For PAL it usually works with 64:45, I don't know for NTSC, in your case.
If this particular NTSC 720x480 pixel source is kept at 16:9 (ie: keeping the hard encoded left and right black bars) then the SAR is 32:27.
However, if the left and right black bars are cropped away to create a 4:3 'image only' encode at 720x480 pixels, the SAR would be 8:9.
EDIT: All that being said, the actual image is not exactly 4:3 :eek:
poisondeathray
13th January 2022, 16:21
It's sped up to 25p . If you directly decimate to 23.976p, you will get dropped frames and jumps in the motion every second
Another clue is every 5th,6th frame is duplicate . This pattern indicates 1 in 6 .
So likely you would decimate 1 in 6, then slowdown to 23.976p . For additional confirmation - I would examine the audio duration and confirm with what is know about the actual production running time. Likely it's sped up for this DVD , so you would slowdown the audio to match 24000/1001 (either in audio editor or avisynth)
TDecimate(cycler=1, cycle=6)
AssumeFPS(24000,1001)
StainlessS
13th January 2022, 16:50
slowdown the audio to match 24000/1001 (either in audio editor or avisynth)
TDecimate(cycler=1, cycle=6)
AssumeFPS(24000,1001,sync_audio=true) #changes samplerate
ResampleAudio (44100) # to required samplerate
hello_hello
13th January 2022, 18:10
The picture itself only has a display aspect ratio of roughly 1.22, assuming an input DAR of 16:9 is correct (I think it's more likely to have an mpeg4 20:11 DAR, making the picture 1.25 after cropping). If you want 4:3 without black bars you'll need to crop extra from the top and bottom to make it 1.33. If you don't want to crop extra picture but you want a 4:3 aspect ratio, you'll have to live with some black each side.
Resizing just the width for non-anamorphic dimensions. It's not resized here as the cropping preview is enabled (I cropped 8 pixels from the bottom to make it neater).
CropResize(0,0, 116,4,-118,-8, InDAR=20.0/11.0, ResizeWO=true, CPreview=1, Info=true)
https://i.postimg.cc/tCm3FbyD/1.jpg
After resizing
CropResize(0,0, 116,4,-118,-8, InDAR=20.0/11.0, ResizeWO=true)
https://i.postimg.cc/3NtgS5G8/2.jpg
I noticed at least one pattern where 1 in 7 frames was repeated, so I suspect you'd want to go directly to 25fps.
TDecimate(mode=7, rate=25)
Then possibly slow it down to 23.976.
Ignoring the frame rate for the moment, you can resize easily enough to 4:3 DVD dimensions with CropResize (https://forum.doom9.org/showthread.php?t=176667). There'll be some black each side with borders enabled, or the script will crop to the specified OutDAR if borders are disabled. Info=true will tell you the sample aspect ratio to use for encoding.
For PAL you'd just change the resizing to 720x576 instead of 720x480
CropResize(720,480, 116,4,-118,-8, InDAR=20.0/11.0, OutDAR=15.0/11.0, Borders=true)
For fast denoising I think QTGMC does a pretty good job (it'll probably blurs less than MDegrain on it's own).
Clip1.mkv (https://files.videohelp.com/u/210984/Clip1.mkv)
DGDecode_mpeg2source("D:\Clip1.d2v")
GreyScale()
TDecimate(mode=7, rate=25)
QTGMC(InputType=1, EzDenoise=1)
CropResize(0,0, 116,4,-118,-8, InDAR=20.0/11.0, ResizeWO=true)
PS FranceBB, I've gotta disagree about changing the levels. It looks better to me the way it is.
Sharc
13th January 2022, 20:27
You need to set SAR in your encoder of choice too, if it's an anamorphic video.
Yes for mpeg-4 encoding.
If I am not mistaken the Pixel Aspect Ratio (PAR, SAR) is not explicitly defined in mpeg-2. It's the DAR only which is specified (1:1, 4:3, 16:9, 2.21:1 (not used for DVD)). The PAR is a derived quantity only for mpeg-2 as far as I understand.
poisondeathray
13th January 2022, 20:57
I noticed at least one pattern where 1 in 7 frames was repeated, so I suspect you'd want to go directly to 25fps.
TDecimate(mode=7, rate=25)
Then possibly slow it down to 23.976.
For some reason, mode 7 drops the wrong frame in a few sections and produces compensatory duplicates on both clips. Not sure why, in theory mode7 should produce similar. You might have to play with the settings a bit to get mode 7 working better
FranceBB
13th January 2022, 22:00
PS FranceBB, I've gotta disagree about changing the levels. It looks better to me the way it is.
The thing is though that if you check with the waveform monitor, the black never touches ground (i.e the black is always higher than 16) which is wrong.
Sharc
13th January 2022, 23:41
The thing is though that if you check with the waveform monitor, the black never touches ground (i.e the black is always higher than 16) which is wrong.
Well yes, but where in the picture do we have proven full black, except for the black borders (which actually were at 16)? So I wouldn't claim it's "wrong".
poisondeathray
14th January 2022, 00:44
You have to check with levels coring=false
If you use Levels(10, 1.0, 240, 0, 255, false) and check the waveform, you see Y values clearly below 16 in the active image area (e.g. hat at the end of the 1st clip, suit at the end of the 2nd clip) . ie. clipped shadow details when Levels(10, 1.0, 240, 0, 255) is used.
hello_hello
14th January 2022, 04:28
For some reason, mode 7 drops the wrong frame in a few sections and produces compensatory duplicates on both clips. Not sure why, in theory mode7 should produce similar. You might have to play with the settings a bit to get mode 7 working better
It might need two passes or it might be the sample is too short (I can't remember how long the whole telecine cycle is to go from 25 to 29.97fps) or maybe I was wrong....
I had a conversation with Dedup about it, and ran a first pass on the first sample like this:
FastDegrain().DupMC(log="metrics.txt")
After checking the metrics file I think this gets all the duplicates, and hopefully nothing else.
DeDup(threshold=2.4, trigger2=2.41, maxcopies=2, maxdrops=2, log="metrics.txt", times="times.txt")
611 frames went it and 506 came out, so the new rate should be
30000 * 506 / 1001 / 611 = 24.819697fps
For 25fps we should be left with
25 * 1001 * 611 / 30000 = 509.67583 frames
And for 1 in 6 decimation it's
(30000 / 1001 / 6 * 5) * 1001 * 611 / 30000 = 509.166 frames
So my take-away from that is I still don't know anything more about what the real frame rate should be.....
TruthOverFacts
14th January 2022, 08:01
It's sped up to 25p . If you directly decimate to 23.976p, you will get dropped frames and jumps in the motion every second
Another clue is every 5th,6th frame is duplicate . This pattern indicates 1 in 6 .
So likely you would decimate 1 in 6, then slowdown to 23.976p . For additional confirmation - I would examine the audio duration and confirm with what is know about the actual production running time. Likely it's sped up for this DVD , so you would slowdown the audio to match 24000/1001 (either in audio editor or avisynth)
TDecimate(cycler=1, cycle=6)
AssumeFPS(24000,1001)
I used this script on Clip1 and stepped through the entire clip frame by frame and didn't see any missing or duplicate frames. Appears to work great. Am I missing something?
I didn't do any level adjusting, cropping, or resizing.
hello_hello
14th January 2022, 09:21
The difference between decimating 1 in 6 and decimating to 25fps is very small. The latter deviates from the 1 in 6 pattern every so often to output 25fps rather than 24.975 (25000/1001).
After more deliberation though, I've decided I was wrong about mode=7 but correct about the frame rate. :)
A = TDecimate(mode=2, m2PA=true, rate=25, Denoise=true)
B = TDecimate(cycler=1, cycle=6, Denoise=true)
Subtract(A, B)
A & B produce identical results (they output the same frames) until frame number 505 (frame number after decimation), where B drops a non-duplicate. I wouldn't have noticed had I not been comparing it to A.
Edit Admittedly that could be something to do with the way TDecimate decides to drop a frame on an incomplete cycle at the end, and not because of the telecine pattern as such, I don't actually know.
Frame 504
https://i.postimg.cc/zLLNpYS4/A.jpg (https://postimg.cc/zLLNpYS4)
Frame 505
https://i.postimg.cc/WDQvHY5z/B.jpg (https://postimg.cc/WDQvHY5z)
Even when you compare them this way it's not necessarily obvious, although the spot on his collar for a single frame gives it away.
StackVertical(A, B)
https://i.postimg.cc/87XDhzWh/C.jpg (https://postimg.cc/87XDhzWh)
m2PA=true can make opening scripts slow when using mode=2. If you plan on doing much experimenting with filters before encoding, you might consider doing a first pass with mode=4 and using the metrics files for mode=2 instead.
hello_hello
14th January 2022, 10:44
If you start the clip after a repeated frame (on a new cycle of 6), they lose sync at frame 108, and B is dropping a non duplicate, so I'm more confident it's 25fps, but there's no guarantee the telecine pattern hasn't been altered by editing, so try running the comparison on the whole video, or different sections of it. Keep in mind m2PA=true causes mode=2 to read 100 frames ahead, so it can make navigating a little slow.
Last.Trim(3,0)
A = TDecimate(mode=2, m2PA=true, rate=25, Denoise=true)
B = TDecimate(cycler=1, cycle=6, Denoise=true)
Subtract(A, B)
SeeMoreDigital
14th January 2022, 11:13
@TruthOverFacts,
I forgot to ask you... How will you be playing your new encode? Do you have a smart TV, disc player or computer?
Cheers
Sharc
14th January 2022, 14:05
You have to check with levels coring=false
If you use Levels(10, 1.0, 240, 0, 255, false) and check the waveform, you see Y values clearly below 16 in the active image area (e.g. hat at the end of the 1st clip, suit at the end of the 2nd clip) . ie. clipped shadow details when Levels(10, 1.0, 240, 0, 255) is used.
Yes, therefore it's technically correct to leave as is (apart from some personal taste/preference).
poisondeathray
14th January 2022, 16:38
A = TDecimate(mode=2, m2PA=true, rate=25, Denoise=true)
B = TDecimate(cycler=1, cycle=6, Denoise=true)
Subtract(A, B)
A & B produce identical results (they output the same frames) until frame number 505 (frame number after decimation), where B drops a non-duplicate. I wouldn't have noticed had I not been comparing it to A.
Edit Admittedly that could be something to do with the way TDecimate decides to drop a frame on an incomplete cycle at the end, and not because of the telecine pattern as such, I don't actually know.
Yes, nice catch, and you might need to look at a longer clip.
Yes, cycle=6 drops a good frame between 504,505, but it might not on a longer clip (it might be from the way this sample was cut). But TDecimate(mode=2, m2PA=true, rate=25, Denoise=true) drops the last frame (but it might not on a longer clip). If that was the entire movie, then dropping the last frame is preferrable to a gap in motion IMO
You could argue for some overrides - e.g. frames 4,5(pre decimation, and 3,4 after decimation by either method) are technically duplicates to human eye, but the warping causes them to be detected as "different" and keeps them
hello_hello
15th January 2022, 08:21
Yes, cycle=6 drops a good frame between 504,505, but it might not on a longer clip (it might be from the way this sample was cut). But TDecimate(mode=2, m2PA=true, rate=25, Denoise=true) drops the last frame (but it might not on a longer clip). If that was the entire movie, then dropping the last frame is preferrable to a gap in motion IMO
I don't know why I'd not thought of using that method to compare decimation before. Now I feel silly for not doing so when it might have helped.
I did manage to cause the 25fps decimation to get it wrong in a test below, so maybe it doesn't matter too much which way you do it.
I thought I'd also try this:
Where Frame #15 is the first frame after a repeat. They differ at frame 98, where "B" drops a duplicate.
Trim(15, 0)
A = TDecimate(mode=2, m2PA=true, rate=25, Denoise=true)
B = TDecimate(mode=2, m2PA=true, rate=25000.0/1001.0, Denoise=true)
Subtract(A, B)
Moving the start frame to #18. I had to trim the first frame from "B" so they'd match at the beginning.
They eventually differ at frame 157, because "A" keeps a duplicate. Now I wish I hadn't looked....
Trim(18, 0)
A = TDecimate(mode=2, m2PA=true, rate=25, Denoise=true)
B = TDecimate(mode=2, m2PA=true, rate=25000.0/1001.0, Denoise=true)
Subtract(A, B.Trim(1, 0))
The difference between 1 in 6 and decimating to 25fps may not be worth caring about anyway.
I checked, and to go from 25fps to 30000/1001 by duplicating fields, 199 fields out of every 1001 are repeated (last paragraph under 2:2 pulldown (https://en.wikipedia.org/wiki/Telecine#2:2_pulldown)), so for frames I assume the numbers are the same. Well... I think I eventually worked out that to calculate whole frame numbers, it needs to be 5 cycles of 1001 frames.
25fps
5005 frames * 1000ms / 25 = 200200ms
25fps to 29.97fps
(5005 frames + 995 repeats = 6000) * 1000ms / (30000 / 1001) = 200200ms
25fps to 30fps (or 24.975 to 29.97)
5005 frames * 6 / 5 = (1001 repeats) 6006 * 1000ms / 30 = 200200ms
I'm trying to wrap my head around that. I assume it means to go from 25fps to 29.97fps, one repeat in each cycle of six frames is dropped every 1001 frame cycle, except for the fifth 1001 frame cycle, where 2 repeats are dropped. Does that seem correct?? It's making my brain hurt.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.