View Full Version : Deinterlacing for 1920x1080i
Seraphic-
10th August 2008, 13:20
Hi,
Could anyone recommended some scripts or link to a scripts with code examples that would work well for Deinterlacing 3D rendered graphics (PS3/Xbox360)?
Over a year ago, I had several scripts for Deinterlacing and frame doubling 480i@29.97 to 480p@59.94. They worked well, but that hard-drive died an I lost them (and lots of other data, lol). Would have liked to try those scripts with this 1080i source.
Anyway, here is a sample frame and video.
I will try and search the forums for some examples.
But any help would be appreciated as well.
Thanks
Frame 80 (http://www.temp.seraphicgate.com/frame.png) from the below five second sample video.
Sample Video (http://www.temp.seraphicgate.com/sample.rar) of 1920x1080i source from PS3.
Blue_MiSfit
10th August 2008, 19:27
The process you describe (480i30 to 480p60) is called bob deinterlacing. It's quite commonplace, and can be done in AviSynth as simply as Bob().
There are many other options
:search:
~MiSfit
Seraphic-
10th August 2008, 22:26
Yeah, I've been searching.
I don't think 59.94FPS would work out anyway as it might be a little much and hard for playback.
I'll have to shoot for 1080p@29.97FPS I think.
Comatose
11th August 2008, 06:25
What are you capturing with?
edit: Holy crap, that 300MB RAR is five seconds?
Blue_MiSfit
11th August 2008, 07:01
Or 720p60, most sources don't really deserve 1080p :)
2Bdecided
11th August 2008, 12:40
This one deserves 1080p!
If mcbob is too slow for you, try...
avisource("sample.avi")
assumetff()
converttoyuy2(matrix="PC.709")
interp=last.SeparateFields().eedi2(field=-2)
yadifmod(mode=1,edeint=interp)
converttoRGB(matrix="PC.709")
To keep 1080p but halve the frame rate, add selectevery(2,0)
(or use different eedi2 pre-processing and yadifmod parameters)
To keep the frame rate but resample to 720p, add lanczosresize(1280,720)
(I prefer this option - I hate choppy movement)
Cheers,
David.
Seraphic-
11th August 2008, 20:25
This one deserves 1080p!
If mcbob is too slow for you, try...
avisource("sample.avi")
assumetff()
converttoyuy2(matrix="PC.709")
interp=last.SeparateFields().eedi2(field=-2)
yadifmod(mode=1,edeint=interp)
converttoRGB(matrix="PC.709")
To keep 1080p but halve the frame rate, add selectevery(2,0)
(or use different eedi2 pre-processing and yadifmod parameters)
To keep the frame rate but resample to 720p, add lanczosresize(1280,720)
(I prefer this option - I hate choppy movement)
Cheers,
David.
Thanks. I'm also going to try and get a script together that uses MCBOB or NNEDI + MCBOB.
Also, why does it convert to yuy2 and RGB or is that yuy2 then RBG?
Here are the results with your script.
1080p@59.94 (frame 160) (http://www.temp.seraphicgate.com/noaa.png)
1080p@59.94 (frame 160) + Anti-Aliasing (http://www.temp.seraphicgate.com/withaa.png)
halsboss
12th August 2008, 13:19
I'm also going to try and get a script together that uses MCBOB or NNEDI + MCBOB.
already done http://forum.doom9.org/showthread.php?p=1055263#post1055263
1080i PAL delivered 0.3 fps processing speed on a Q9450 4-core when resizing to 576i. Putting ",threads=4" in every call to NNEDI inside mcbob increased the processing speed to 0.8 fps. I went back to tdeint+NNEDI+MT and get circa 18fps with a resize to 567i
henryho_hk
14th August 2008, 17:28
halsboss, would you pls post again your complete script for tdeint+nnedi+mt ?
Ranguvar
14th August 2008, 17:35
When I recorded from the 360, the output was just field-shifted, which seems like interlacing, but isn't. It's likely not in your case, but try a simple AssumeTFF or AssumeBFF and then Telecide.
Seraphic-
14th August 2008, 18:36
When I recorded from the 360, the output was just field-shifted, which seems like interlacing, but isn't. It's likely not in your case, but try a simple AssumeTFF or AssumeBFF and then Telecide.
I posted a sample video in my first post here if you want to take a look.
I'll try and find some scripts and give your idea a try.
already done http://forum.doom9.org/showthread.php?p=1055263#post1055263
1080i PAL delivered 0.3 fps processing speed on a Q9450 4-core when resizing to 576i. Putting ",threads=4" in every call to NNEDI inside mcbob increased the processing speed to 0.8 fps. I went back to tdeint+NNEDI+MT and get circa 18fps with a resize to 567i
Thanks. I'll take a look.
halsboss
15th August 2008, 11:20
halsboss, would you pls post again your complete script for tdeint+nnedi+mt ?
Sure, happy for you to tell me what's wrong with it :) This is the non-NNEDI version which, to my eyes and given resizing to 576i, is "good enough". It doesn't have a call to nnedi nor the ",threads=4" in the non-existant call to nnedi. I have probably mis-spoke about the fps given this is probably the "faster" one I ran without NNEDI.
SetMTmode(mode=5,threads=2) # start with mode=5 forAVIsource http://forum.doom9.org/showthread.php?p=1067216#post1067216
SetMemoryMax(768)
# Xfps-MT-HC-1pass 25fps settings
LoadPlugin("C:\SOFTWARE\DGindex\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\TDeint.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\EEDI2.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\Yadifmod.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\NNEDI.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\DePan.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\AGC.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\Cnr2.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\dctfilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\fft3dfilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\Convolution3d.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\despot.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\WarpSharp.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\aWarpSharp.dll")
#LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\MaskTools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\mvtools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\Unfilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\AddgrainC.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\hqdn3d.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\mt_masktools.dll")
# -------------------------------------------------------------------------------------
#LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\RemoveGrain.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\RemoveGrainSSE2.dll")
#LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\Repair.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\RepairSSE2.dll")
#LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\RemoveDirt.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-NOTautoloaded\RemoveDirtSSE2.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins2.0\LoadPluginEx.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins2.0\DustV5.dll")
# -------------------------------------------------------------------------------------
Import("C:\Program Files\AviSynth 2.5\LimitedSharpenFaster.avsi")
Import("C:\Program Files\AviSynth 2.5\dcwresize.avsi")
#Import("C:\Program Files\AviSynth 2.5\DeHalo_alpha.avsi")
Import("C:\Program Files\AviSynth 2.5\Deblock_QED_MT2.avs")
# -------------------------------------------------------------------------------------
#--- be sure to have run DGindex over the input to yield the .d2v file !
#
MPEG2Source("G:\HDTV\1\test-1080i.d2v",cpu=6) # cpu=6: DEBLOCK_Y_H, DEBLOCK_Y_V, DEBLOCK_C_H, DEBLOCK_C_V, DERING_Y, DERING_C
#MPEG2Source("G:\HDTV\1\test-1080i.d2v") # cpu=6: DEBLOCK_Y_H, DEBLOCK_Y_V, DEBLOCK_C_H, DEBLOCK_C_V, DERING_Y, DERING_C
AssumeFPS(25)
AssumeTFF() ### THIS IS VERY IMPORTANT TO SET CORRECTLY
#
#---
# -------------------------------------------------------------------------------------
FRAMERATE=25
WIDTH=704
HEIGHT=576
LastW=LAST.width()
LastH=LAST.height()
#
# -------------------------------------------------------------------------------------
#Trim(clip clip, int first_frame, int -num_frames [, bool pad_audio])
#Trim(clip clip, int first_frame, int last_frame [, bool pad_audio])
#Trim trims a video clip so that it includes only the frames first_frame through last_frame.
#The audio is similarly trimmed so that it stays synchronized.
#Remember AviSynth starts counting at frame 0.
#pad_audio (default true) causes the audio stream to be padded to align with the video stream.
#Otherwise the tail of a short audio stream is left so.
#When last_frame=0 and pad_audio=false the end of the two streams remains independant.
#Trim(1500, -500)
#Trim(500, -750)
#
# -------------------------------------------------------------------------------------
# --------- DEBLOCK THE INTERLACED SOURCE IF REQUIRED - BEFORE RESIZING ---------------
# -------------------------------------------------------------------------------------
#
# This link shows how to DEBLOCK AN INTERLACED SOURCE
#http://forum.doom9.org/showthread.php?p=1121574#post1121574
#
# Deblock before resize or it doesn't deblock
#SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
#SeparateFields().PointResize(LastW,LastH).Addborders(0,0,0,8)
#Deblock_QED_MT2().Cropbottom(8).AssumeFrameBased() #default quant1=20
#Deblock_QED_MT2(quant1=25).Cropbottom(8).AssumeFrameBased()
#Deblock_QED_MT2(quant1=30).Cropbottom(8).AssumeFrameBased()
#Deblock_QED_MT2(quant1=35).Cropbottom(8).AssumeFrameBased()
#Deblock_QED_MT2(quant1=40).Cropbottom(8).AssumeFrameBased()
#SeparateFields().SelectEvery(4,0,3).Weave()
#
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# --------- RESIZE THE INTERLACE CLIP -------------------------------------------------
# -------------------------------------------------------------------------------------
#
# This link shows how to resize interlaced
#http://forum.doom9.org/showthread.php?p=1115201#post1115201
#
# -------------------------------------------------------------------------------------
SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
bicubicresize(704,LAST.height())
tdeint(mode=1,order=1) # mode=0=same rate output mode=1=double rate output (bobbing) order=0=BFF order=1=TFF
bicubicresize(last.width(),576)
separatefields()
selectevery(4,0,3)
weave()
# -------------------------------------------------------------------------------------
#SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
#bicubicresize(704,LAST.height())
# see http://forum.doom9.org/showthread.php?p=1114448#post1114448
# tcritical plugins http://bengal.missouri.edu/~kes25c/
# for yadifmod tff Order=1 ; for nnedi field=-2 means assumeTFF is important
#yadifmod(mode=1, order=1, edeint=nnedi(field=-2)) #bob deinterlace it without stairstepping to 50
#bicubicresize(last.width(),576)
#separatefields()
#selectevery(4,0,3)
#weave()
# -------------------------------------------------------------------------------------
#
Converttoyv12(interlaced=true)
#
SetPlanarLegacyAlignment(True)
# Distributor() should only be used when loading the script into applications which talk to avisynth directly
# e.g. HC and MeGUI. If the program opens the .avs file as an avi file (like virtualdub/mod, x264, xvid_encraw etc.)
# then you don't need (and shouldn't have) the distributor call at the end.
# http://forum.doom9.org/showthread.php?p=1136518#post1136518
##### "HC uses custom avisynth routines, you have to add Distributor() to the end of the script."
Distributor() # use this when using HC and SetMTmode, per http://forum.doom9.org/showthread.php?p=1063622#post1063622
# http://forum.doom9.org/showthread.php?p=1067589#post1067589
# ChangeFPS(Last, Last, True) makes fast scripts faster and slow scripts slower !!
#ChangeFPS(Last, Last, True) # use this when using HC and SetMTmode, per http://forum.doom9.org/showthread.php?p=1064118#post1064118
HC .ini file for this script (1-pass)
*INFILE G:\HDTV\1\test-1080i-CQ2.5.avs
*OUTFILE G:\HDTV\1\test-1080i.mpv
*INTERLACED
*TFF
*LOGFILE G:\HDTV\1\test-1080i-HC-CQ2.5.log
*PROFILE BEST
*ASPECT 16:9
*BIAS 50
*BITRATE 9350
*MAXBITRATE 9450
*LASTIFRAME
*AUTOGOP 15
*PULLDOWN
*CLOSEDGOPS
*DBPATH G:\HDTV\1\
*LLPATH G:\HDTV\1\
*DC_PREC 10
*CQ_MAXBITRATE 2.5
*MATRIX MPEG
henryho_hk
15th August 2008, 11:30
Oh, I thought you were using nnedi() inside MT(). I had never managed to do it right coz it's always complaining the height not being mod 4 (or 2 ... dun remember).
halsboss
15th August 2008, 12:20
Oh, I'll give it a try on a sample ...
have you seen http://forum.doom9.org/showthread.php?p=1161524#post1161524 which does away with deinterlacing ? I wonder how that compares to the tdeint thingo. I don't know how to do the "differences" thing...
On the other hand I'm not surprised if you mean using MT rather than setmtmode on the basis MT chops up the input frames and farms it out. iirc the MT thread has a suggestion/request for addressing that which never got a bite from anyone. Which do you mean ?
halsboss
15th August 2008, 13:09
On a Q9450 4-core with EP45 motherboard and 4Gb Ram XP-sp3
SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
bicubicresize(704,LAST.height())
tdeint(mode=1,order=1) # mode=0=same rate output mode=1=double rate output (bobbing) order=0=BFF order=1=TFF
bicubicresize(last.width(),576)
separatefields()
selectevery(4,0,3)
weave()
yielded
pass 1 encoding time: 0:01:37 (96.64 s)
fps: 18.3
nr. of gops: 134
nr. of frames: 1765
nr. of I-frames: 134
nr. of P-frames: 612
nr. of B-frames: 1019
average bitrate: 5627
minimum bitrate: 2248
maximum bitrate: 9447
bytes in bitstream: 49673678
bits in bitstream: 397389424
average Quantizer: 2.901
total CPU time: 0:03:19 (96.64 s)
total elapsed time: 0:01:37 (97.36 s)
SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
bicubicresize(704,LAST.height())
tdeint(mode=1,order=1,edeint=nnedi(field=-2,threads=4)) # mode=0=same rate output mode=1=double rate output (bobbing) order=0=BFF order=1=TFF
bicubicresize(last.width(),576)
separatefields()
selectevery(4,0,3)
weave()
yielded
pass 1 encoding time: 0:04:07 (247.20 s)
fps: 7.1
nr. of gops: 134
nr. of frames: 1765
nr. of I-frames: 134
nr. of P-frames: 612
nr. of B-frames: 1019
average bitrate: 5640
minimum bitrate: 2269
maximum bitrate: 9400
bytes in bitstream: 49782993
bits in bitstream: 398263944
average Quantizer: 2.911
total CPU time: 0:13:32 (247.20 s)
total elapsed time: 0:04:07 (247.48 s)
Global NewHeight=576
Global NewWidth=704
SeparateFields()
Shift=(Height()/Float(NewHeight/2)-1.0)*0.25
Tf=SelectEven().LanczosResize(NewWidth, NewHeight/2, 0, -Shift, Width(), Height())
Bf=SelectOdd().LanczosResize(NewWidth, NewHeight/2, 0, Shift, Width(), Height())
Interleave(Tf, Bf)
Weave()
yielded EDIT: Darn it I forgot the SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
pass 1 encoding time: 0:01:49 (109.31 s)
fps: 16.1
nr. of gops: 134
nr. of frames: 1765
nr. of I-frames: 134
nr. of P-frames: 612
nr. of B-frames: 1019
average bitrate: 6077
minimum bitrate: 2287
maximum bitrate: 9442
bytes in bitstream: 53639890
bits in bitstream: 429119120
average Quantizer: 2.988
total CPU time: 0:02:20 (109.31 s)
total elapsed time: 0:01:50 (109.53 s)
Now ... how do I tell the results apart, better than my eyes ? To my tired old eyes, the last appeared a tad sharper, but they all looked too close to tell apart to me.
halsboss
15th August 2008, 13:34
With a different test clip - fast action sports footage in the last half of this 2nd test clip,
TDEINT alone yielded
pass 1 encoding time: 0:02:09 (128.73 s)
fps: 16.6
nr. of gops: 144
nr. of frames: 2134
nr. of I-frames: 144
nr. of P-frames: 796
nr. of B-frames: 1194
average bitrate: 8691
minimum bitrate: 5260
maximum bitrate: 9446
bytes in bitstream: 92743030
bits in bitstream: 741944240
average Quantizer: 3.656
total CPU time: 0:04:43 (128.73 s)
total elapsed time: 0:02:09 (129.01 s)
TDEINT+NNEDI yielded
pass 1 encoding time: 0:05:58 (358.05 s)
fps: 6.0
nr. of gops: 144
nr. of frames: 2134
nr. of I-frames: 144
nr. of P-frames: 798
nr. of B-frames: 1192
average bitrate: 8690
minimum bitrate: 5279
maximum bitrate: 9447
bytes in bitstream: 92737303
bits in bitstream: 741898424
average Quantizer: 3.687
total CPU time: 0:19:49 (358.05 s)
total elapsed time: 0:05:58 (358.31 s)
Separate-shift-resize-weave yielded EDIT Darn it I forgot the SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
pass 1 encoding time: 0:02:17 (136.92 s)
fps: 15.6
nr. of gops: 144
nr. of frames: 2134
nr. of I-frames: 144
nr. of P-frames: 806
nr. of B-frames: 1184
average bitrate: 8625
minimum bitrate: 6469
maximum bitrate: 9447
bytes in bitstream: 92040795
bits in bitstream: 736326360
average Quantizer: 4.047
total CPU time: 0:03:11 (136.92 s)
total elapsed time: 0:02:17 (137.14 s)
halsboss
15th August 2008, 13:54
Just for fun, with the same 2nd "action" source, changed the first 2 from bicubicresize to LanczosResize so
threads=2 TDEINT yielded
pass 1 encoding time: 0:02:15 (134.51 s)
fps: 15.9
nr. of gops: 144
nr. of frames: 2134
nr. of I-frames: 144
nr. of P-frames: 802
nr. of B-frames: 1188
average bitrate: 8628
minimum bitrate: 5608
maximum bitrate: 9408
bytes in bitstream: 92078060
bits in bitstream: 736624480
average Quantizer: 3.999
total CPU time: 0:04:56 (134.51 s)
total elapsed time: 0:02:15 (134.83 s)
and threads=2 TDEINT+NNEDI yielded
pass 1 encoding time: 0:06:07 (366.84 s)
fps: 5.8
nr. of gops: 144
nr. of frames: 2134
nr. of I-frames: 144
nr. of P-frames: 802
nr. of B-frames: 1188
average bitrate: 8625
minimum bitrate: 5619
maximum bitrate: 9442
bytes in bitstream: 92040840
bits in bitstream: 736326720
average Quantizer: 4.036
total CPU time: 0:20:24 (366.84 s)
total elapsed time: 0:06:07 (367.14 s)
Again, they looked close enough the same to me, maybe a tad "sharper" than bicubic. I'd be pleased for someone to show script code for a non-visual difference comparison of some kind and how to interpret the output.
halsboss
15th August 2008, 14:04
For the 2nd sports clip, now I remembered to put in the SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
Global NewHeight=576
Global NewWidth=704
SeparateFields()
Shift=(Height()/Float(NewHeight/2)-1.0)*0.25
Tf=SelectEven().LanczosResize(NewWidth, NewHeight/2, 0, -Shift, Width(), Height())
Bf=SelectOdd().LanczosResize(NewWidth, NewHeight/2, 0, Shift, Width(), Height())
Interleave(Tf, Bf)
Weave()
yielded
pass 1 encoding time: 0:01:46 (106.01 s)
fps: 20.1
nr. of gops: 144
nr. of frames: 2134
nr. of I-frames: 144
nr. of P-frames: 806
nr. of B-frames: 1184
average bitrate: 8625
minimum bitrate: 6469
maximum bitrate: 9447
bytes in bitstream: 92040795
bits in bitstream: 736326360
average Quantizer: 4.047
total CPU time: 0:03:09 (106.01 s)
total elapsed time: 0:01:46 (106.23 s)
halsboss
15th August 2008, 14:25
Oh why not ... Last and final, 2nd "sports clip" with all lanczos and this time all "SetMTmode(mode=2,threads=4)" instead of "SetMTmode(mode=2,threads=2)"
1. TDEINT
pass 1 encoding time: 0:01:53 (112.92 s)
fps: 18.9
nr. of gops: 144
nr. of frames: 2134
nr. of I-frames: 144
nr. of P-frames: 802
nr. of B-frames: 1188
average bitrate: 8628
minimum bitrate: 5608
maximum bitrate: 9408
bytes in bitstream: 92078060
bits in bitstream: 736624480
average Quantizer: 3.999
total CPU time: 0:05:05 (112.92 s)
total elapsed time: 0:01:53 (113.25 s)
2. TDEINT+NNEDI (nnedi call also has threads=4)
pass 1 encoding time: 0:05:21 (321.39 s)
fps: 6.6
nr. of gops: 144
nr. of frames: 2134
nr. of I-frames: 144
nr. of P-frames: 802
nr. of B-frames: 1188
average bitrate: 8625
minimum bitrate: 5619
maximum bitrate: 9442
bytes in bitstream: 92040840
bits in bitstream: 736326720
average Quantizer: 4.036
total CPU time: 0:20:43 (321.39 s)
total elapsed time: 0:05:22 (321.70 s)
3. Separate-shift-resize-weave
pass 1 encoding time: 0:01:51 (111.20 s)
fps: 19.2
nr. of gops: 144
nr. of frames: 2134
nr. of I-frames: 144
nr. of P-frames: 806
nr. of B-frames: 1184
average bitrate: 8625
minimum bitrate: 6469
maximum bitrate: 9447
bytes in bitstream: 92040795
bits in bitstream: 736326360
average Quantizer: 4.047
total CPU time: 0:03:23 (111.20 s)
total elapsed time: 0:01:51 (111.45 s)
Interesting CPU times VS elapsed times. As expected, fps threads=4 is mostly > fps threads=2 on a 4-core but not by a huge amount ? Unsure why the "Separate-shift-resize-weave" got worse with the same code but threads increased from 2 to 4...
NorthPole
15th August 2008, 16:16
@seraphic
I use the following generic script with dgindex to invert telecine all ntsc and atsc captures streams and output a video that is 23.976 fps.
#SetMemoryMax(512)
loadplugin("c:\program files\media\avisynth\plugins\tivtc.dll")
dgdecode_mpeg2source("__vid__",info=3)
hsize = string(height())
eval("f" + hsize + "()")
tdecimate(mode=1,hybrid=1,hint=true,concycle=1,nt=2,vidDetect=2,dupthresh=5,vidthresh=5)
# Notes
# -----
# Uncomment any of the following functions as needed
# Obviously do not use both rsize function at once
# Adjust the letterbox sizes as needed
# Do not use the letterbox function with the zoom function
# Instead make the necessary letterbox changes in the scripclip line
#greyscale()
#rsize16x9()
#rsize4x3()
#lbox()
#zoom()
#info()
# End of Main Script
# rsize16x9: Function for Resizing to 16x9 SD video
# --------------------------------------------------
function rsize16x9(v) {
wide = (704 == v.width()) ? 704 : 720
high = Select(ndx,360,720,1080)
start = Select(ndx,60,0,0)
v.lanczos4Resize(wide,480,0,start,v.width(),high)
720 == width() ? crop(8,0,704,480) : NOP
return last
}
# rsize4x3: Function for Resizing to 4x3 SD video
# ------------------------------------------------
function rsize4x3(v) {
wide = (704 == v.width()) ? 704 : 720
v.lanczos4Resize(wide,360,0,60,v.width(),v.height())
addBorders(0,60,0,60)
720 == width() ? crop(8,0,704,480) : NOP
return last
}
# lbox: Function for adding Letterboxes to video
# -----------------------------------------------
# Note the values after ndx are for 480p, 720p and 1080p respectively
function lbox(v) {
top = Select(ndx,60,0,0)
bottom = Select(ndx,60,0,0)
left = Select(ndx,0,160,240)
right = Select(ndx,0,160,240)
return v.letterbox(top,bottom,left,right)
}
# zoom: Function for removing Zoomed video sections
# --------------------------------------------------
# Set frame1 to the first moving frame in the zoomed or animated sequence
# Set frame2 to the first non-moving frame after the zoomed or animated sequence
# Set x1,y1 and x2,y2 to the crop values obtained from virtualDub.
# Note x1, y1, x2, y2 must be even numbers
# Note frame numbers should be at tdecimated 23.976 fps rate to avoid interlaced lines
function zoom(v) {
last = v
x1 = 8
y1 = 94
x2 = 272
y2 = 92
x = width()-x1-x2
y = height()-y1-y2
frame1 = 313
frame2 = 322
animate(frame1,frame2,"lanczos4resize",
\ width(),height(),x1,y1,x,y,
\ width(),height(),0,0,width(),height())
scriptclip("current_frame <= " + string(frame2) +" ? letterbox(2,2,8,8) : letterbox(2,2,8,8)")
return last
}
# f480: Function for 704 or 720 x 480i video
# -------------------------------------------
function f480(v) {
global ndx = 0
720 == v.width() ? v.crop(8,2,704,476) : v.crop(0,2,704,476)
addBorders(0,2,0,2)
return tfm(mode=4)
}
# f720: Function for 1280 x 720p video
# -------------------------------------
function f720(v) {
global ndx = 1
v.crop(2,8,1276,704)
addborders(2,8,2,8)
return selecteven()
}
# f1080: Function for 1920 x 1080i video
# ---------------------------------------
function f1080(v) {
global ndx = 2
v.crop(2,8,1916,1064)
addborders(2,8,2,8)
return tfm(mode=4)
}
halsboss
17th August 2008, 03:39
Thanks and a "virtual medal" to whoever came up with the separate-shift-resize-weave method of converting HD 1080i to SD (dvd-compatible) 567i (referred to here http://forum.doom9.org/showthread.php?p=1161524#post1161524). I'm now using a variation of this
SetMTmode(mode=5,threads=2) # start with mode=5 forAVIsource http://forum.doom9.org/showthread.php?p=1067216#post1067216
# --- snip, loaded plugins ---
MPEG2Source("G:\HDTV\1\hqq1.d2v",cpu=6) # cpu=6: DEBLOCK_Y_H, DEBLOCK_Y_V, DEBLOCK_C_H, DEBLOCK_C_V, DERING_Y, DERING_C
AssumeFPS(25)
AssumeTFF() ### THIS IS VERY IMPORTANT TO SET CORRECTLY
# http://forum.doom9.org/showthread.php?p=1161524#post1161524
SetMTmode(mode=2,threads=2) # mode=2 for temporal multi-threading (interleaved frames)
Global NewHeight=576
Global NewWidth=704
SeparateFields()
Shift=(Height()/Float(NewHeight/2)-1.0)*0.25
Tf=SelectEven().Spline36resize(NewWidth, NewHeight/2, 0, -Shift, Width(), Height())
Bf=SelectOdd().Spline36resize(NewWidth, NewHeight/2, 0, Shift, Width(), Height())
#Tf=SelectEven().Lanczos4resize(NewWidth, NewHeight/2, 0, -Shift, Width(), Height())
#Bf=SelectOdd().Lanczos4resize(NewWidth, NewHeight/2, 0, Shift, Width(), Height())
Interleave(Tf, Bf)
Weave()
Converttoyv12(interlaced=true)
SetPlanarLegacyAlignment(True)
Distributor() # use this when using HC and SetMTmode, per http://forum.doom9.org/showthread.php?p=1063622#post1063622
After using variations of TDEINT and NNEDI and MCBOB I am well satisfied, in FPS processing and and quallity tradeoff terms, with the result given the input is on large grass-field sports action with significant movement and camera panning. Whilst I can't really tell apart the outputs from spline36 and Lanczos4, for an undefinable reason Spline36 seems "nicer" somehow.
Anyway here's part of HCenc's logs from the identical source in case someone can point out something.
Spline36
nr. of gops: 3427
nr. of frames: 51204
nr. of I-frames: 3427
nr. of P-frames: 18806
nr. of B-frames: 28971
average bitrate: 8612
minimum bitrate: 2152
maximum bitrate: 9449
bytes in bitstream: 2205101772
bits in bitstream: 17640814176
average Quantizer: 4.097
Lanczos4
nr. of gops: 3426
nr. of frames: 51204
nr. of I-frames: 3426
nr. of P-frames: 18836
nr. of B-frames: 28942
average bitrate: 8596
minimum bitrate: 1928
maximum bitrate: 9449
bytes in bitstream: 2201137603
bits in bitstream: 17609100824
average Quantizer: 4.186
I've been using single-pass...
*INFILE G:\HDTV\1\hqq1-CQ2.5.avs
*OUTFILE G:\HDTV\1\hqq1.mpv
*LOGFILE G:\HDTV\1\hqq1-HC-CQ2.5.log
*INTERLACED
*TFF
*PROFILE BEST
*ASPECT 16:9
*BIAS 50
*BITRATE 9350
*MAXBITRATE 9450
*LASTIFRAME
*AUTOGOP 15
*PULLDOWN
*CLOSEDGOPS
*DC_PREC 10
*CQ_MAXBITRATE 2.5
*MATRIX MPEG
Can someone please post a 2-pass HC equivalent .ini which uses HC's "lossless" functionality ? :thanks:
halsboss
17th August 2008, 03:43
Um, I'm not sure if that post belongs over here http://forum.doom9.org/showthread.php?t=139102 instead, or maybe in the HDTV forum http://forum.doom9.org/forumdisplay.php?f=64 ?
IanB
17th August 2008, 04:39
@halsboss,
Why have you added this "SetPlanarLegacyAlignment(True)"? Are you running a very old Mpeg2Source()? If you were then it should be right after the filter that makes invalid assumptions about the in memory line pitch.
And you do realise this, Converttoyv12(interlaced=true), is a nop when the input is already YV12. And if the input was not YV12 then this is not the right place to do the conversion.
halsboss
17th August 2008, 05:00
Why have you added this "SetPlanarLegacyAlignment(True)"? Are you running a very old Mpeg2Source()?
Close to latest mpeg2source. Thanks, a hangover from old scripts... copy/edit and stuff propagates down the versions which use Dust, C3D, and a variety of older plugins. I'll remove it. :thanks:
And you do realise this, Converttoyv12(interlaced=true), is a nop when the input is already YV12. And if the input was not YV12 then this is not the right place to do the conversion. Yes, thanks. It's a hangover from multi-purpose scripts (copy/edit, again) where the source can be directshow, avisource, etc. In the multi-purpose scripts, some of the plugins only process YUY2 so I think I had to convert at the end before it feeds into HCenc or an error occurred is my recollection. Be happy for you to point out where the conversion should generally occur.
IanB
18th August 2008, 05:27
The best place to do the Converttoyv12() is while the video is still progressive. Remember the chroma positioning is the same for progressive and interlaced mpeg2 4:2:0 encoding, just the temporal instance of the samples change. The even luma lines with the even choma lines at this instant and the odd luma lines with the odd chroma lines at the next instant 1/60th (or 1/50th) of a second latter.
If nothing is moving in the image then there is no difference between progressive and interlaced.Frame 0 Frame 1 Frame 0
(60p) (60p) (30i)
x x x x X X X X x x x x
c c C C c c
X X X X x x x x x x x x
x x x x X X X X x x x x
C C c c c c
X X X X x x x x x x x x
# 60P YUY2 source
ConvertToYV12() # 60P YV12
SeparateFields()
SelectEvery(4, 0,3)
Weave() # 30i YV12 with optimal chroma sampling
In your case when doing 30i HD to 30i SD, do the Converttoyv12(interlaced=true) before the interlaced resize, i.e. when the choma resolution is maximum.
halsboss
18th August 2008, 10:12
Thanks IanB. I didn't quite follow the X's, so will have to do some reading. Cheerio from the city of churches and their tri-colour team.
halsboss
23rd August 2008, 16:41
For clarity, apparently the right thing to do is here http://forum.doom9.org/showthread.php?p=1174054#post1174054
florinandrei
30th August 2008, 05:13
I have tested the new (corrected) script:
Global NewHeight = 480
Global NewWidth = 720
DirectShowSource("hd.m2ts", audio=false)
# Pick one manually, DirectShow has no idea
AssumeTFF()
#AssumeBFF()
SeparateFields()
Shift = (GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0)
E = SelectEven() . Spline36Resize(NewWidth, NewHeight/2, 0, Shift)
O = SelectOdd() . Spline36Resize(NewWidth, NewHeight/2, 0, -Shift)
Echr = SelectEven() . Spline36Resize(NewWidth, NewHeight/2, 0, 2*Shift)
Ochr = SelectOdd() . Spline36Resize(NewWidth, NewHeight/2, 0, -2*shift)
Interleave(E, O)
IsYV12() ? MergeChroma(Interleave(Echr, Ochr)) : Last
Weave()
The input is 1080i AVCHD generated by a camcorder.
The output is fed to HC Encoder at pretty high quality, to create DVD-compatible MPEG2.
The computer is a 4-core AMD Phenom 9850.
The speed difference between the initial script and the corrected one is pretty small. I get 12.7 fps with the initial one, and 10.3 fps with the corrected one. So it's not a big deal, the speed decrease is small, it's fine by me.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.