Log in

View Full Version : 720p25 -> 1080i29.97


MrVideo
3rd September 2017, 07:51
Believe it, or not, but the PBS network screwed up. Tonight I captured the PBS network sat feed of the NOVA episode Zeppelin Terror Attack. The screwup is that the closing credits were from the NOVA episode Emperor's Ghost Army. The feeds have been wrong from Wednesday, as they use the same file on their server farm (I'm assuming). No one caught it or bothered to fix it.

So, I downloaded a usenet posting of the episode. There were two available, but both were 25fps. No idea why the idiot did that, considering the source for one of them was OTA New Jersey Network.

In order to "fix" what I have, I need to convert from 25fps progressive to 29.97 fps interlaced and 720 to 1080.

High quality is not a must, as it is only the credits. I just need the video to match my capture (1080i29.97).

Anyone have a simple AVI script to do such a thing?

Thanks in advance.

johnmeyer
3rd September 2017, 08:59
Totally untested, based on code I have lying around ...

# Convert 25p progressive to 60i
#Re-size to 1920x1080

blocksize=16

source=AVISource("E:\fs.avi")

superfps= MSuper(source,pel=2)
backward_vec2 = MAnalyse(superfps, isb = true,blksize=blocksize)
forward_vec2 = MAnalyse(superfps, isb = false,blksize=blocksize)
MFlowFps(source,superfps, backward_vec2, forward_vec2, num=60000, den=1001, ml=200)
Spline36Resize(1920,1080)
SeparateFields()
SelectEvery(4,0,3)
output=Weave()

return output

MrVideo
3rd September 2017, 11:25
Thanks. Here is the ultimate script:
blocksize=16
LoadPlugin("C:\Program Files (x86)\DGAVCDecNV\DGDecodeNV.dll")
dgsource("e:\\nova.s41e11.zeppelin.terror.attack.proper.720p.hdtv.x264-w4f.dgi")
superfps=MSuper(pel=2)
backward_vec2 = MAnalyse(superfps, isb = true,blksize=blocksize)
forward_vec2 = MAnalyse(superfps, isb = false,blksize=blocksize)
MFlowFps(superfps, backward_vec2, forward_vec2, num=60000, den=1001, ml=200)
Spline36Resize(1920,1080)
SeparateFields()
SelectEvery(4,0,3)
Weave()
The script worked perfectly. It is something that I would never have figured out by myself.

Thanks again.

johnmeyer
3rd September 2017, 15:39
Glad it worked for you. I didn't know what source format you were dealing with so I'm glad you were able to figure out DGDecode.

MrVideo
3rd September 2017, 16:22
I do a lot of x264 encodes using a Z-shell script that builds the .avs file. The lines dealing with DGDecode are a standard part of all my .avs files. Since the output of one line is basically piped to the next line, your "source" line wasn't needed and I suspected that the "source" input wasn't required by your other lines as the pattern is normally a piped input by default. I tried it and it worked right off the bat.

johnmeyer
3rd September 2017, 16:25
Many of my scripts let me compare the output with the source, sometimes using a Stack command, and sometimes using an interleave construct. Very useful for denoising, etc. None of that was needed here, but as I said in my initial post, this was just code I had lying around and I wasn't going to re-write it.

P.S. I still have a one-season cottage in Wisconsin, near Oconomowoc. I haven't been there for years because I have come to hate flying commercial so much. I do miss Wisconsin in the summer.

MrVideo
3rd September 2017, 17:41
I still have a one-season cottage in Wisconsin, near Oconomowoc. I haven't been there for years because I have come to hate flying commercial so much. I do miss Wisconsin in the summer.
The north woods is where you need to be. I had an aunt/uncle that lived in Woodruff. They had a small cottage on one of the lakes. As a kid we went up there a lot. Still did as an adult a few times. Sadly they are no longer with us. So, I haven't been up to Woodruff in many a year.

Ya, flying is not as fun as it used to be. Having TSApre really helps. Flying out of Milwaukee to Phoenix, and back, via Southwest actually is not bad at all.

MysteryX
3rd September 2017, 18:48
Thanks. Here is the ultimate script:
blocksize=16
LoadPlugin("C:\Program Files (x86)\DGAVCDecNV\DGDecodeNV.dll")
dgsource("e:\\nova.s41e11.zeppelin.terror.attack.proper.720p.hdtv.x264-w4f.dgi")
superfps=MSuper(pel=2)
backward_vec2 = MAnalyse(superfps, isb = true,blksize=blocksize)
forward_vec2 = MAnalyse(superfps, isb = false,blksize=blocksize)
MFlowFps(superfps, backward_vec2, forward_vec2, num=60000, den=1001, ml=200)
Spline36Resize(1920,1080)
SeparateFields()
SelectEvery(4,0,3)
Weave()
The script worked perfectly. It is something that I would never have figured out by myself.

Thanks again.

What this script is basically doing is
- Intepolate frames
- Upscale
- Interlace

but it does it using the simplest methods available, which is good if you want max performance.

If you want higher quality, or if it generates artifacts, you could look into doing the interpolation with FrameRateConverter (https://forum.doom9.org/showthread.php?t=174793) and the upscale with SuperRes+NNEDI2 (https://forum.doom9.org/showthread.php?t=172698)

johnmeyer
3rd September 2017, 21:47
Wow, I have some great memories of Woodruff. Back in 1960 we stayed at Keith's Key-of-the-North when we visited my sister who was spending the summer at Red Pine Camp for Girls. Great memories of watching the Minoquabats (with Gil Keith skiing barefoot), eating Bosaki's fudge (I think the original place burned down), and fishing on the various lakes connected to Minoqua.

Sorry to take this OT.

Back on topic, you should try the FrameRateConverter script. He put a lot of time into it. I myself have some very critical frame rate conversion that I have to do this week for a wedding tribute video where I'd like to get video from various sources all converted to 60p, and I'm going to see if it really does improve on the basic MVToosl2 approach that is at the heart of the script I posted.

MysteryX
4th September 2017, 01:31
see if it really does improve on the basic MVToosl2 approach that is at the heart of the script I posted.
Well yeah, the basic script generates artifacts. Any artifact masking will improve it, and I think this one is doing it pretty well.

I could even argue that it's better than doing it manually, as when you go frame by frame by hand, you flag whole frames to blend instead of just hiding the artifact areas. Of course there can be a few glitches here and there, but it's rather rare.

johnmeyer, if you still want to do the work manually, you can have the automated clip, a clip with output="flow", and a clip with blending, and fix just a few details here and there

MrVideo
4th September 2017, 03:34
If you want higher quality, or if it generates artifacts, you could look into doing the interpolation with FrameRateConverter (https://forum.doom9.org/showthread.php?t=174793) and the upscale with SuperRes+NNEDI2 (https://forum.doom9.org/showthread.php?t=172698)
I did initially look at your program. Then I saw the list of requirements. Programs that I didn't have and didn't really want to install for a one-off project. The output of the script was great. It was clean, no artifacts. It was way better than I expected.

MysteryX
4th September 2017, 04:59
Good for you. Generally texts and subtitles perform poorly, but in your case it worked.

MrVideo
4th September 2017, 05:07
The closing credits were loaded with text. I was surprised how well it all looked.

Now, if the PBS network hadn't screwed up in the first place. :D

Sharc
4th September 2017, 14:15
You could also telecine the 25p source (with very little audio pitch shift), like
DGSource("xxxx.dgi") #25p source
SeparateFields()
Selectevery(10, 0,1, 2,3,2, 5,4, 7,6,7,8,9) #2:2:3:2:3 pulldown; returns 60.00 fields per second.
Weave()
AssumeFPS (29.97, True)

johnmeyer
4th September 2017, 15:04
Actually, since text moves in only one direction, in a completely uniform and predictable way, I am not surprised at all that it worked well. Of course a lot depends on how thick the fonts were, how large, etc.

If I were to look at the credit roll that had been processed by the script I posted, the one place I would expect problems is where the text enters the screen at the bottom. ME is notorious for not doing the right thing when objects come out from behind another object in the foreground.

But, when motion is all in the same direction, like a horizontal camera pan of a static scene, motion estimation can deliver results which are close to perfect. So I am not surprised that a simple credit roll would turn out great.

MrVideo
4th September 2017, 20:13
I guess you don't watch NOVA. :D They do not scroll the closing credits. They fast fade from one page to the next.

Motenai Yoda
4th September 2017, 23:15
most ntsc to pal conversion are made speeding up ivtc'd 23.976fps to 25fps
assumefps("ntsc_film")
changefps("ntsc_double")
SeparateFields()
SelectEvery(4,0,3)
weave()

hello_hello
7th September 2017, 05:05
Assuming the credits were broadcast at 23.976fps, but captured at 25fps, wouldn't decimating back to 23.976fps and then applying standard 3:2 pulldown for 29.970fps be a possibility? Or did capturing at 25fps drop a lot of frames (29.970fps source) rather than add an extra frame each second (23.976fps source)?

MrVideo
7th September 2017, 20:21
OTA broadcast is 29.97fps. Any 23.976 material would have been 2:3 pulldown converted to 29.97 for editing, as NOVA is mostly video sourced material.

As OTA is MPEG-2 and the file that I downloaded was H.264, the person that did the capture converted the file to 720p25fps from the 1080i29.97fps source.

ADDED: It might be possible that NJN is one of those PBS stations that output in 720p59.94. Still, the person went and converted to 720p25fps, for some unknown reason.