View Full Version : Proper processing of 25i for Blu Ray authoring?
MadMonkey57
1st January 2009, 17:05
Hi,
First time in avisynth Forum, maybe a noob question, I don't know.
All right. I have a PAL camcorder that produces SD AVI (DV) files 720x576 aspect ratio 4:3. Those AVIs happen to have top and bottom black borders I can crop in order to get a 720x432 (4:3), which can easily be resized to 720x576 (16:9). The thing is the AVIs are interlaced. Thus I need to deinterlace them before cropping and resizing. I have come up with these 2 scenarios :
25i(4:3) to 25i(16:9)
---------------------
AVISource("camcorder_25i_4-3.avi", audio=false)
separatefields()
bob(0.0,1.0)
crop( 0, 68, 0, -76)
spline16resize(720,576)
separatefields()
SelectEvery(4,0,3)
Weave()
# audio untouched
25i(4:3) to 23.976p(16:9)
-------------------------
AVISource("camcorder_25i_4-3.avi", audio=false)
Load_Stdcall_Plugin("C:\Program Files\megui\tools\yadif\yadif.dll")
Yadif(order=0) # deinterlacing
AssumeFPS("ntsc_film")
crop( 0, 68, 0, -76)
spline16resize(1280,768)
# audio will be slowed down outside of avisynth
In the end, my purpose is to encode the videos to Blu Ray (using x264).
Are these scenarios any good ?
What are the advantages/drawbacks of both approaches (quality, efficiency of encoding, ...) ?
Are there any better approaches ?
Thanks guys.
MadMonkey57
2nd January 2009, 17:01
I googled a bit more and I found a possible third alternative. I had rejected this one right away at first but still it seems to be a interesting choice (and I'm no expert...). So here it is :
25i(4:3) to 23.976p(16:9)
-------------------------
AVISource("camcorder_25i_4-3.avi", audio=false)
Load_Stdcall_Plugin("C:\Program Files\megui\tools\yadif\yadif.dll")
Yadif(order=0) # deinterlacing
ConvertFPS("ntsc_film")
crop( 0, 68, 0, -76)
spline16resize(1280,768)
# audio untouched
Guest
2nd January 2009, 17:09
In the end, my purpose is to encode the videos to Blu Ray (using x264).
I think you have the Avisynth part down pretty good and your question is more suited for the BuRay authoring forum. So I'm moving it for you. I also edited the title. :)
n0mag!c
2nd January 2009, 22:05
@MadMonkey57
I suggest you to not reencode you captures, but mux it with tsMuxer to AVCHD. First, you can convert your AVI captures to MKV using GraphEdit+Haali Muxer, 'cause tsMuxer can't accept AVI-files as input. Lay all the dirty work for resample to your Blu-Ray-Player+TV.
Do you see any disadvantages in this way?
MadMonkey57
3rd January 2009, 00:49
@MadMonkey57
I suggest you to not reencode you captures, but mux it with tsMuxer to AVCHD. First, you can convert your AVI captures to MKV using GraphEdit+Haali Muxer, 'cause tsMuxer can't accept AVI-files as input. Lay all the dirty work for resample to your Blu-Ray-Player+TV.
Do you see any disadvantages in this way?
I think you have misread my initial post. My camcorder is SD. The AVI file is DV.
n0mag!c
3rd January 2009, 12:12
Yes, I thought it's SD but MPEG-2. DV definitely needs to be reencoded, so I like your first scenario most.
MadMonkey57
3rd January 2009, 13:47
Yes, I thought it's SD but MPEG-2. DV definitely needs to be reencoded, so I like your first scenario most.
Yes, I thought it's SD but MPEG-2. DV definitely needs to be reencoded, so I like your first scenario most.
At first, I'd go for the first one too, but I'm having second thoughts...
Scenario 1 : 25i(4:3) to 25i(16:9)
--------------------------------
1. AviSynth : deinterlacing --> properly done, doubling framerate
2. AviSynth : cropping
3. AviSynth : resizing --> I like Spline16Resize, still hesitating with Lanczos4Resize
4. AviSynth : re-interlacing --> properly done, framerate back to normal
5. x264 : encoding --> ouch... encoding interlaced source
6. BD Player : decoding
7. BD Player : deinterlacing
8. BD Player/LCD : resizing (720x576 16:9 to 1920x1080)
Advantages : Audio untouched, only resizing height
Drawbacks : Encoding interlaced, deinterlacing/interlacing/deinterlacing/resizing...
Scenario 2 : 25i(4:3) to 23.976p(16:9)
-------------------------------------
1. AviSynth : deinterlacing --> using yadif (any alternatives ?)
2. AviSynth : slowing down fps to 23.976
3. AviSynth : cropping
4. AviSynth : resizing --> I like Spline16Resize, still hesitating with Lanczos4Resize
5. x264 : encoding --> encoding progressive source
6. BD Player : decoding
7. BD Player/LCD : resizing (1280x720 to 1920x1080)
Advantages : Frames altered to the minimum, encoding progressive
Drawbacks : Less proper deinterlacing (still pretty good to my eyes), audio has to be slowed down
Scenario 3 : 25i(4:3) to 23.976p(16:9)
-------------------------------------
1. AviSynth : deinterlacing --> using yadif (any alternatives ?)
2. AviSynth : converting fps to 23.976
3. AviSynth : cropping
4. AviSynth : resizing --> I like Spline16Resize, still hesitating with Lanczos4Resize
5. x264 : encoding --> encoding progressive source
6. BD Player : decoding
7. BD Player/LCD : resizing (1280x720 to 1920x1080)
Advantages : Encoding progressive, audio untouched
Drawbacks : How does changefps perform 25 to 23.976, I don't know..., less proper deinterlacing (still pretty good to my eyes)
I'm actually wondering between scenarios #2 and #3...
Atak_Snajpera
3rd January 2009, 15:14
Can you upload sample?
MadMonkey57
3rd January 2009, 20:38
Can you upload sample?
http://www.sendspace.com/file/3dakvz
scharfis_brain
3rd January 2009, 21:49
IMO BluRay should support 50p SD video, eg
720x576p50 anamorphic 16x9.
this means for you:
xxxsource("blah.xxx")
crop(0,72,0,-72) #crop 576 down to 432 for 16x9
tempgausmc() # motion compensated bob deinterlace to 50fps
bicubicresize(width, 576) #anamorphic upscale
Atak_Snajpera
4th January 2009, 02:11
Blu-ray supports 720x480@60p and 720x576@50p (at least my PS3 does not complain)
This what you should do:
OpenDMLSource("D:\_Video_Samples\avi\camcorder_25i_4-3.avi",audio=false)
#Deinterlace
LoadCplugin("...\Yadif.dll")
yadif(mode=1,order=0)
#Color correction (TV -> PC levels)
Levels(16, 1, 235, 0, 255, coring=false)
don't forget to add --sar 1067:1000 to x264 command line
BTW. Upscaling to higher resolution is pointless
Result -> http://www.mediafire.com/?oy42jwjgyke
scharfis_brain
4th January 2009, 11:56
1) I recommend a better deinterlacer than yadif alone. at least yadifmod with nnedi
2) PAL PAR is 1094:1000
3) upscaling in AVISynth will be better than the players or the TVs one
Atak_Snajpera
4th January 2009, 12:23
1) I recommend a better deinterlacer than yadif alone. at least yadifmod with nnedi
maybe...
2) PAL PAR is 1094:1000
1.067 * 720 = 768
768 / 576 = 1.333 (4:3)
Math does not lie :)
3) upscaling in AVISynth will be better than the players or the TVs one
Blu-Ray players have very good upscaling algorithms. Besides his footage has very bad quality. It really does not matter what upsaling algorithm is used because it will always look ugly.
MadMonkey57
4th January 2009, 12:58
@scharfis_brain and Atak_Snajpera
Thanks guys, I like the 50p approach as it has all the advantages (encoding progressive, a proper deinterlacing, audio untouched). The only "drawback" I can see against the other alternatives is the use of a higher bitrate to support 50p, but really, it isn't a drawback, my goal is max quality.
The choice for a deinterlacing method is a matter of personal liking ? Time to process ? Encodability with x264 ? Depends on the content itself ?
...don't forget to add --sar 1067:1000 to x264 command line...
...2) PAL PAR is 1094:1000...
I would have forgotten the --sar option, thanks for reminding me of that, but i would personaly have gone --sar 16:15...
...BTW. Upscaling to higher resolution is pointless...
Yeah I would have upscaled only in the 23.976p scenario... (BD compliancy)
...Besides his footage has very bad quality. It really does not matter what upsaling algorithm is used because it will always look ugly...
I chose a footage in a way it would preserve my privacy. The rest of my captures are much better quality.
Atak_Snajpera
4th January 2009, 13:35
but i would personaly have gone --sar 16:15...
Actually it does not matter if you use my version or yours. 768.24 will be rounded down according to math rules :) But indeed your sar value is more accurate.
MadMonkey57
4th January 2009, 15:22
I've read several pages on the use of yamodif and nnedi but really I'm not into state of the art deinterlacing...
I figured I'd go something like :
YADIFMod(order=0, mode=1, edeint=NNEDI(...))
But really I wouldn't mind a little help with NNEDI (and the overall yadifmod + nnedit filter combination just to make sure...).
Thanks.
MadMonkey57
4th January 2009, 16:20
YADIFMod(order=0, mode=1, edeint=NNEDI(field=2))
Is that correct ? (bottom field first, double frame rate)
MadMonkey57
4th January 2009, 17:50
Hey, we lost something along the way... The script is supposed to give an output 720x576 AR 16:9, so the --sar option should be --sar 64:45.
So to sum it up, the script to convert 720x576x25i (4:3, with top/bottom black bars) to 720x576x50p (16:9) will be :
AVISource("camcorder_dv.avi", audio=false)
YADIFMod(order=0, mode=1, edeint=NNEDI(field=2))
crop(0, 68, 0, -76)
spline36resize(720, 576)
which will be encoded with x264 with --sar 64:45 --min-keyint 50.
scharfis_brain
4th January 2009, 19:05
Atak_Snajpera:
active image area according to ITU.601 spec is 702 (seven-zero-two) pixels == 768 pixel => PAR of 1.094:1
720pixels have to be stretched to 788 pixels.
Math doesn't lie ;)
btw.: happy reading:
http://lipas.uwasa.fi/~f76998/video/conversion/
MadMonkey57
4th January 2009, 20:46
...active image area according to ITU.601 spec is 702 (seven-zero-two) pixels == 768 pixel => PAR of 1.094:1
720pixels have to be stretched to 788 pixels....
The script will output at 16:9. If I understand correctly :
702 --> 1024 ==> PAR of 1.458:1 (more precisely 512:351)
So 720 pixels would be stretched to 1050.
Am I correct ?
AVISource("camcorder_dv.avi", audio=false)
YADIFMod(order=0, mode=1, edeint=NNEDI(field=2))
crop(0, 68, 0, -76)
spline36resize(720, 576)
Any comment on the script itself ? (esp. the deinterlacing part)
n0mag!c
5th January 2009, 20:29
Blu-Ray players have very good upscaling algorithms.
Sadly, PS3 doesn't upscale BD/AVCHD, but perfectly upscales all other sources :(
PS3 doesn't complain on 25p sources on BD/AVCHD, maybe all others stand-alone-BD-players treat it as 50i as well? So there is no need for 24p transcoding.
MadMonkey57
6th January 2009, 14:19
Web page after web page, post after post, making progress everyday... :)
#
# Input is 720x576x25i (4:3)
# Output is 720x576x50p (16:9)
#
# Loading with AVISource so Cedocida VFW DV Codec is used
AVISource("camcorder_dv.avi", audio=false)
#
# Choosing the appropriate field order
#
AssumeBFF() # or AssumeTFF(), check with Info() or by hand
#
# Bob deinterlacing (thus doubling framerate)
#
# Motion Adaptation Deinterlacers (Pretty good)
# - YADIFMod(mode=1, edeint=NNEDI(field=2))
#
# Motion Compensation Deinterlacers (Even better)
# - TempGaussMC_beta1()
# - MCBob()
TempGaussMC_beta1()
#
# Cropping top/bottom black borders
#
crop(0, 68, 0, -76)
#
# Resizing so that Aspect Ratio becomes 16.9
#
# Resizers:
# - BlackmanResize(taps=4)
# - spline36resize()
# - HybridFupp()
spline36resize(720, 576)
scharfis_brain
6th January 2009, 14:38
you may crop before deinterlace in order to speed up the deinterlacing.
but ensure to only crop by mod4 numbers.
MadMonkey57
6th January 2009, 14:44
you may crop before deinterlace in order to speed up the deinterlacing...
I wanted to but I was afraid it might screw the deinterlacing...
...but ensure to only crop by mod4 numbers.
I know I can now.:)
:thanks:
MadMonkey57
12th January 2009, 15:11
All right, I tried to feed MEGui with one single avs file, but I keep on gettings errors. The workaround I have found is to split the AVS in 2 :
#
# Input is 720x576x25i (4:3)
# Output is 720x432x50p (4:3)
#
# Loading with AVISource so Cedocida VFW DV Codec is used
AVISource("camcorder_dv.avi", audio=false)
#
# Choosing the appropriate field order
#
AssumeBFF() # or AssumeTFF(), check with Info() or by hand
#
# Bob deinterlacing (thus doubling framerate)
#
# Motion Adaptation Deinterlacers (Pretty good)
# - YADIFMod(mode=1, edeint=NNEDI(field=2))
#
# Motion Compensation Deinterlacers (Even better)
# - TempGaussMC_beta1mod()
# - MCBob()
TempGaussMC_beta1mod()
#
# Cropping top/bottom black borders
#
crop(0, 68, 0, -76)
#
# Input is 720x432x50p (4:3)
# Output is 1280x720x50p (1:1)
#
AVISource("720x432x50p_4-3.avi", audio=false)
#
# Resizers:
# - BlackmanResize( 1280, 720, taps=4 )
# - spline36resize( 1280, 720 )
# - HybridFupp( 1280, 720, preset="HybridQ" )
HybridFupp( 1280, 720, preset="HybridQ" )
I process the first AVS with VirtualDub and encode into an AVI using Lagarith Codec (Lossless YV12).
Then I feed MEGui with the second AVS (that gets as input the AVI file produced by the first AVS).
As you can see, I went 1280x720x50p instead of 720x576x50p. Indeed, the latter doesn't play in my SAP. As a matter of fact, 720x576x50p is not AVCHD compliant (but still it is BD compliant, guess why...) whereas 1280x720x50p is.
I also tried 1920x1080x23.976p :
...
TempGaussMC_beta1mod().SelectEven()
crop(0, 68, 0, -76)
HybridFupp( 1920, 1080, preset="HybridQ" )
Assumefps("ntsc_film")
...
But the 1280x720x50p look better to my eyes, and gives me the best out of my bitrate (less data to encode : 1280x720x50 < 1920x1280x25).
btw, in MEGui, I use Sharktooth's Blu Ray profile customized with :
--vbv-bufsize 15000 --vbv-maxrate 15000 --keyint 50
PS : And a High Profile@4.0
n0mag!c
13th January 2009, 20:56
But the 1280x720x50p look better to my eyes
720@25i will look the same in case the encoder properly treats interlaces files (I'm not familiar with x.264). You're resizing fields to frames but players/TVs can do the same not worse. This way the same bitrate will give you more picture quality. Would you like to try this?
crop(0, 68, 0, -76)
SeparateFields()
LanczosResize(1280,360)
weave()
scharfis_brain
13th January 2009, 21:17
@n0mag!c:
1) There is no 720i !
2) you method for interlaced scaling is flawd. It'll introduce a vertical misalignment of the fields.
n0mag!c
13th January 2009, 22:08
1) There is no 720i !
What is the difference in stream, which I suggested, with 720@50i?
2) you method for interlaced scaling is flawd. It'll introduce a vertical misalignment of the fields.When misalignment started and how to avoid it?
MadMonkey57
14th January 2009, 00:04
720@25i will look the same in case the encoder properly treats interlaces files (I'm not familiar with x.264)...
As scharfis_brain said, 1280x720x25i is neither BD nor AVCHD compliant...
... You're resizing fields to frames but players/TVs can do the same not worse. This way the same bitrate will give you more picture quality. Would you like to try this?
crop(0, 68, 0, -76)
SeparateFields()
LanczosResize(1280,360)
weave()
Check the first post, you'll see a working script that'll do 720x576@25i (4:3) to 720x576@25i (16:9) but I ruled out this scenario coz :
- the process of interlacing the resized frame tends to "loose" information (mixing two half frames together), which IMO is not a good idea, especially since I'm using using a pretty good resizer (HybridFupp). Going 50p, I keep all the information. I could have gone 720x576@50p (BD compliant but not AVCHD compliant), but my SAP rejects it. That's why I chose 1280x720x50p
- encoding interlaced is less efficient than encoding progressive
scharfis_brain
14th January 2009, 00:15
1) there is NO interlacing for the 720 lines HDTV!
So NO 720i25, NO 720i50, NO 720i30 NOR 720i60.
2) read the numerous threads about re-interlacing video properly
one is: http://forum.doom9.org/showthread.php?t=88116&highlight=vertical+misalignment
MadMonkey57
14th January 2009, 00:28
1) there is NO interlacing for the 720 lines HDTV!
So NO 720i25, NO 720i50, NO 720i30 NOR 720i60...
You have misread my post... I was mentioning SD 576 25i...
2) read the numerous threads about re-interlacing video properly. one is: http://forum.doom9.org/showthread.php?t=88116&highlight=vertical+misalignment
Thanks. I'll check this thread.
As of now, I am not 100% sure in my case HD 720 50p is more appropriate than SD 576 25i (16:9)...
scharfis_brain
14th January 2009, 00:39
oh, I didn't meant you. I delayed my post without seeing you posted in the meantime.
MadMonkey57
14th January 2009, 09:55
oh, I didn't meant you. I delayed my post without seeing you posted in the meantime.
All right, no problem.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.