VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 40
Thread
  1. I am using avisynth and HCencoder to encode an HD video file to DVD compliant MPEG with HCencoder.

    I'm not sure how to go about proper resizing to maintain the aspect ratio of the video file. The original video is 1280x688, 1:85 (or close to it) aspect ratio, wide screen. Does anyone have any suggestions on the lines of script i would need to add to an avisynth to properly resize the video without squashing the image etc.?

    Thanks in advance!
    Quote Quote  
  2. Originally Posted by Radio Radio View Post
    I am using avisynth and HCencoder to encode an HD video file to DVD compliant MPEG with HCencoder.

    I'm not sure how to go about proper resizing to maintain the aspect ratio of the video file. The original video is 1280x688, 1:85 (or close to it) aspect ratio, wide screen. Does anyone have any suggestions on the lines of script i would need to add to an avisynth to properly resize the video without squashing the image etc.?

    Thanks in advance!

    Is this NTSC DVD ? Framerate of source is 23.976 ? If not you might have to do other manipulations


    You can use something like fitcd to figure it out. But , one easy way is to add back the letterbox borders using AddBorders() (for 16:9 1280x720) , then resize it down to SD

    720-688 = 32

    32/2 = 16 pixels to top & bottom each

    The colormatrix line is to change the colors appropriate for SD (SD sources typically use Rec601 matrix for conversion for display)

    Code:
    WhateverSource()
    AddBorders(0,16,0,16)
    LanczosResize(720,480)
    Colormatrix(mode="Rec.709->Rec.601", clamp=0)
    Quote Quote  
  3. Is this NTSC DVD ? Framerate of source is 23.976 ? If not you might have to do other manipulations
    Yep it is.

    You can use something like fitcd to figure it out. But , one easy way is to add back the letterbox borders using AddBorders() (for 16:9 1280x720) , then resize it down to SD

    720-688 = 32

    32/2 = 16 pixels to top & bottom each

    The colormatrix line is to change the colors appropriate for SD (SD sources typically use Rec601 matrix for conversion for display)

    Code:
    WhateverSource()
    AddBorders(0,16,0,16)
    LanczosResize(720,480)
    Colormatrix(mode="Rec.709->Rec.601", clamp=0)
    Awesome, I'll give this resize a try and see how it looks. Thanks for the help poisondeathray, it's greatly appreciated.
    Quote Quote  
  4. I have a follow up question. I tried resizing using poisondeathray's recommendations. Everything worked fine with the exception of one thing, when comparing screen shots of the 1280x688 with the 720x480 resized video, the picture seems to be stretched a bit in the vertical dimension.

    I'm not sure what's causing the vertical stretch, or how to fix it (or if its to be expected with any kind of resizing).

    Any help would be appreciated.
    Quote Quote  
  5. How are you determining this? Are you viewing it 1:1 ?

    You need to encode in HCEnc with the 16:9 flag

    It's encoded at 720x480 dimensions, but the square pixel equivalent will be 854x480 . ie. the media player will "stretch" the picture upon playback . DVD's don't use "square pixels"

    If you view it 1:1, it will look horizontally "squished". Discounting the letterboxing, the AR of 720x480 is 1.5, not 1.778 (for 16:9) : because 720/480 = 1.5 . The square pixel equivalent, 854/480 =~ 1.778 (or 16:9)
    Quote Quote  
  6. I virtually never convert to DVD but if I had to work it out manually I'd probably do it like this due to a lack of knowing any better.

    A 16:9 NTSC DVD is 853x480 in square pixel dimensions when stretched to it's correct display aspect ratio.
    1280x688 gives you an aspect ratio of around 1.86.
    Next I'd resize the video to a width of 853, using 1.86 as the aspect ratio. That gives you 843x458.
    NTSC DVDs use a height of 480, so you'd need to add 22 pixels worth of black borders (say 12 top, and 10 bottom). Now the total height is 480, and including black borders, 853x480. Finally you'd resize that to 720x480 and use a 16:9 aspect ratio for the DVD.

    poisondeathray used AddBorders(0,16,0,16) in his script to add the borders before resizing, mine would use AddBorders(0,12,0,10) after resizing, but I assume when you take the resizing into account the end result should be pretty much the same.

    My guess on the "squished video" problem.....
    I've never used HC Encoder, but if it's designed for encoding DVD compliant video, maybe it automatically does the resizing and adding of borders etc if necessary so the user doesn't need to worry about it. If that's the case, and you resized yourself also, you might have effectively "double resized". ie if you gave it 720x480 video after adding borders and resizing, which has a 16:9 aspect ratio, the program might assume that's 720x480 worth of square pixels (1.5:1 aspect ratio) unless you tell it otherwise, so it resizes again while adding borders to the sides to it'll display correctly when it changes the aspect ratio to 16:9. I don't know what that program can do but I'd assume it'll do the resizing for you, or if you've already resized you probably need to be able to tell it the correct aspect ratio of the input video.
    Quote Quote  
  7. Originally Posted by poisondeathray View Post
    How are you determining this? Are you viewing it 1:1 ?

    You need to encode in HCEnc with the 16:9 flag

    It's encoded at 720x480 dimensions, but the square pixel equivalent will be 854x480 . ie. the media player will "stretch" the picture upon playback . DVD's don't use "square pixels"

    If you view it 1:1, it will look horizontally "squished". Discounting the letterboxing, the AR of 720x480 is 1.5, not 1.778 (for 16:9) : because 720/480 = 1.5 . The square pixel equivalent, 854/480 =~ 1.778 (or 16:9)
    Ahhh ok. I was comparing screenshots of the HD file with screen shots of sample I encoded per your instructions with HCencoder. But I was using WombleMPEGWizard to get the screenshots for the encoded MPEG.

    When I used VLC media player (it was set to default aspect ratio and I tried 16:9 and it was the same) and I took a screencap with VLC compared it to the screenshot of the HD file and nothing looked stretched.

    Also the Womble screenshots were 720x480, but these VLC screencaps say 853x480.

    I'll have to try stream copying the sample clip i encoded with HC, and see if Womble is doing something to the picture
    Quote Quote  
  8. Originally Posted by hello_hello View Post
    I virtually never convert to DVD but if I had to work it out manually I'd probably do it like this due to a lack of knowing any better.

    A 16:9 NTSC DVD is 853x480 in square pixel dimensions when stretched to it's correct display aspect ratio.
    1280x688 gives you an aspect ratio of around 1.86.
    Next I'd resize the video to a width of 853, using 1.86 as the aspect ratio. That gives you 843x458.
    NTSC DVDs use a height of 480, so you'd need to add 22 pixels worth of black borders (say 12 top, and 10 bottom). Now the total height is 480, and including black borders, 853x480. Finally you'd resize that to 720x480 and use a 16:9 aspect ratio for the DVD.

    poisondeathray used AddBorders(0,16,0,16) in his script to add the borders before resizing, mine would use AddBorders(0,12,0,10) after resizing, but I assume when you take the resizing into account the end result should be pretty much the same.

    My guess on the "squished video" problem.....
    I've never used HC Encoder, but if it's designed for encoding DVD compliant video, maybe it automatically does the resizing and adding of borders etc if necessary so the user doesn't need to worry about it. If that's the case, and you resized yourself also, you might have effectively "double resized". ie if you gave it 720x480 video after adding borders and resizing, which has a 16:9 aspect ratio, the program might assume that's 720x480 worth of square pixels (1.5:1 aspect ratio) unless you tell it otherwise, so it resizes again while adding borders to the sides to it'll display correctly when it changes the aspect ratio to 16:9. I don't know what that program can do but I'd assume it'll do the resizing for you, or if you've already resized you probably need to be able to tell it the correct aspect ratio of the input video.
    Thanks hello_hello ill also try resizing a sample using your suggestions.
    Quote Quote  
  9. I recommend you resize before adding boarders if you're going to use a sharpening resizer. Otherwise you'll get a row or bright pixels at the junction of the picture and the black borders. To calculate the right height for 16:9 DVD:

    720 / DAR * PAR

    where DAR is the display aspect ratio of your source (width/height assuming square pixel) and PAR is the pixel aspect ratio of 16:9 DVD (32:27, for 4:3 DVD use 8:9):

    720 / (1280 / 688) * (32 / 27)
    720 * (688 / 1280) * (32 / 27) = 459

    Then add borders to fill out the 720x480 frame. Try to keep at least one of the borders a multiple of 8 (for better compression and fewer artifacts). So instead of 10 an 11 for the borders use 8 and 13.

    Neither of these issues has a huge effect on the final video but you might as well spend a few extra seconds working them out.
    Last edited by jagabo; 27th Dec 2012 at 11:33.
    Quote Quote  
  10. Originally Posted by jagabo View Post
    I recommend you resize before adding boarders if you're going to use a sharpening resizer. Otherwise you'll get a row or bright pixels at the junction of the picture and the black borders. To calculate the right height for 16:9 DVD:

    720 / DAR * PAR

    where DAR is the display aspect ratio of your source (width/height assuming square pixel) and PAR is the pixel aspect ratio of 16:9 DVD (32:27, for 4:3 DVD use 8:9):

    720 / (1280 / 688) * (32 / 27)
    720 * (688 / 1280) * (32 / 27) = 459

    Then add borders to fill out the 720x480 frame. Try to keep at least one of the borders a multiple of 8 (for better compression and fewer artifacts). So instead of 10 an 11 for the borders use 8 and 13.

    Neither of these issues has a huge effect on the final video but you might as well spend a few extra seconds working them out.
    Thanks for the tips jagabo, I will give this a try. Quick question.: for this method, would should i still use Lanczos Resize and just put in (720, 459)? Or is there a different Resize filter you'd suggest I use? Thanks.
    Last edited by Radio Radio; 27th Dec 2012 at 11:45.
    Quote Quote  
  11. Lanczos4 and Spline36 are both a little sharper than Lanczos, I think, and they're fairly similar. I use Spline36 mainly, but it' all personal taste.

    Here's something you might want to try. There's a sharpening filter called asharp which I use every now and then when converting to standard definition. http://avisynth.org.ru/docs/english/externalfilters/asharp.htm
    I generally add the sharpening before the resizing and generally not enough so it makes a noticeable difference to the source video itself (when not resizing), but I find it can help retain detail when resizing. It's a pretty subtle effect (at least the way I use it) as I don't like obvious sharpening. Generally I use something like: asharp(0.9, 3) or asharp(1, 3)
    Quote Quote  
  12. Originally Posted by hello_hello View Post
    Lanczos4 and Spline36 are both a little sharper than Lanczos, I think, and they're fairly similar. I use Spline36 mainly, but it' all personal taste.

    Here's something you might want to try. There's a sharpening filter called asharp which I use every now and then when converting to standard definition. http://avisynth.org.ru/docs/english/externalfilters/asharp.htm
    I generally add the sharpening before the resizing and generally not enough so it makes a noticeable difference to the source video itself (when not resizing), but I find it can help retain detail when resizing. It's a pretty subtle effect (at least the way I use it) as I don't like obvious sharpening. Generally I use something like: asharp(0.9, 3) or asharp(1, 3)
    Nice, I'll play around with the asharp and the other filters. Thanks.
    Quote Quote  
  13. Sharper isn't always better. The more you sharpen the more you risk creating oversharpening halos and buzzing edges. And sharpening increases noise, increasing the bitrate requirement. If your source video is already very sharp you may want to use BilinearResize() or BicubicResize().
    Quote Quote  
  14. Originally Posted by jagabo View Post
    Sharper isn't always better. The more you sharpen the more you risk creating oversharpening halos and buzzing edges. And sharpening increases noise, increasing the bitrate requirement. If your source video is already very sharp you may want to use BilinearResize() or BicubicResize().
    Any pros or cons between Bilinear vs Bicubic?
    Quote Quote  
  15. bicubic is more neutral, bilinear is more soft in terms of resizing

    different resizing algorithms have different tradeoffs. You can see a visualization comparison here
    http://svn.int64.org/viewvc/int64/resamplehq/doc/kernels.html

    It's better idea to preview your script to get and idea of how sharp/soft or other artifacts caused by resizing on your particular source
    Quote Quote  
  16. Originally Posted by poisondeathray View Post
    It's better idea to preview your script to get and idea of how sharp/soft or other artifacts caused by resizing on your particular source
    For previewing an avs script i can just open it up in VirtualDub?
    Last edited by Radio Radio; 27th Dec 2012 at 15:53. Reason: typo, wrote "avi", meant "avs"
    Quote Quote  
  17. Originally Posted by Radio Radio View Post
    Originally Posted by poisondeathray View Post
    It's better idea to preview your script to get and idea of how sharp/soft or other artifacts caused by resizing on your particular source
    For previewing an avi script i can just open it up in VirtualDub?
    Yes you can, (You mean .avs script, not avi I assume)

    IMO it's difficult to compare versions of the same frame in vdub. I usually do it in avspmod. You can have different script versions in different tabs and use the number keys to flip back & forth to examine single frames .

    e.g
    tab 1 might have lanczos
    tab 2 might have bicubic
    tab 3 might have ....

    etc....

    just move the slider (or hit f5 to preview) and push the number keys to toggle the tabs . You can use the zoom feature (video=>zoom) for more close up look . Try it with Lanczos4 and you will see ringing (it produces very sharp, ringing/haloing, but you might choose it if that particular source was very soft to begin with)
    Quote Quote  
  18. Originally Posted by poisondeathray View Post
    Originally Posted by Radio Radio View Post
    Originally Posted by poisondeathray View Post
    It's better idea to preview your script to get and idea of how sharp/soft or other artifacts caused by resizing on your particular source
    For previewing an avi script i can just open it up in VirtualDub?
    Yes you can, (You mean .avs script, not avi I assume)

    IMO it's difficult to compare versions of the same frame in vdub. I usually do it in avspmod. You can have different script versions in different tabs and use the number keys to flip back & forth to examine single frames .

    e.g
    tab 1 might have lanczos
    tab 2 might have bicubic
    tab 3 might have ....

    etc....

    just move the slider (or hit f5 to preview) and push the number keys to toggle the tabs . You can use the zoom feature (video=>zoom) for more close up look . Try it with Lanczos4 and you will see ringing (it produces very sharp, ringing/haloing, but you might choose it if that particular source was very soft to begin with)
    Cool, I will compare with avspmod. Again, I appreciate all the help everyone has given me on this thread!
    Quote Quote  
  19. Originally Posted by poisondeathray View Post
    bicubic is more neutral, bilinear is more soft in terms of resizing
    In my opinion Bilinear is more like the human eye. Ie, cutting the resolution in half is like moving the original twices as far away. You don't get oversharpening halos when you do that.

    For comparing videos I usually use VirtualDub and an AviSynth script with Interleave():

    Code:
    WhateverSource()
    v1=BilinearResize(720,460).Subtitle("bilinear:) # used 460 instead of 459 because YV12 requires even frame sizes
    v2=BicubicResize(720,460).Subtitle("bicubic:)
    v3=LanczosResize(720,460).Subtitle("lanczos:)
    Interleave(v1,v2,v2)
    Then I use a screen magnifier like the one included with Windows. I use point resize (aka nearest neighbor) so it is obvious where pixels start and end.
    Quote Quote  
  20. For quick and easy previewing you can also open an avs script using MPC-HC. As I generally only create fairly simple scripts (I don't often use much filtering or editing etc) I've put a shortcut to MPC-HC in the Windows right click SendTo menu. That way I can leave the file associations for scripts untouched but still open one using MPC-HC quite easily. It'll display as it would after encoding, except for using the correct aspect ratio if the encode is intended to be anamorphic (it'll just display using square pixels), but that's usually no big deal.

    Once you open a script using MPC-HC and AVISynth is frame serving it'll remain unchanged regardless of any changes you make to the script, so you can modify the script, use the SendTo menu to open a second instance of MPC-HC, and compare the changes that way. If I want to change the script and view the changes using the same instance of MPC-HC, I just use MPC-HC's "File/Recent Files" menu to reload the script by selecting the currently open avs script (usually at the top of the list).

    You can also easily run the video full screen and zoom in and out using the numeric keypad as you normally would when playing video with MPC-HC. Of course if you ask it to resize or display fullscreen it'll use whichever resizer you've selected in MPC-HC's options, but generally that's okay with me as it's the resizer I'll be using for watching the video after encoding anyway (Bilinear for me).
    Last edited by hello_hello; 27th Dec 2012 at 21:24.
    Quote Quote  
  21. Yes, the SendTo context menu is very useful. In XP it's located in C:\Documents and settings\USERNAME\SendTo (just create shortcuts there). In Win7 it's in a different location but you can get to it easily by searching for "Shell:SendTo".
    Quote Quote  
  22. As well as comparing resizers using jagabo's suggestion, you can use the same type of script to compare other filters. For example to compare an unsharpened version of a video with a (overly) sharpened version using the same resizer each time:

    WhateverSource()
    v1=LanczosResize(640, 480).Subtitle("without sharp")
    v2=LanczosResize(640, 480).Subtitle("with sharp").sharpen(1.0)
    Interleave(v1,v2)
    Quote Quote  
  23. Oh, and use VirtualDub to compare the filter chains. Open the script and use the left/right arrow keys to step back and forth one frame at a time.
    Quote Quote  
  24. Thank you guys for all the suggestions. I have a lot of stuff to try out.
    Quote Quote  
  25. I had a play with dither today and did a little resizer comparing. I'm a little impressed so far.
    Resizing down a high quality HD source with lots of detail I couldn't really see a difference between spline36 and dither using it's default resizing settings. Resizing down a HD video with lots of banding was a different story. Spline36 just resized the banding, maybe made it a little more noticeable, whereas dither reduced it a bit.
    I gave bilinear and bicubic another look, but they're too soft for me. At least when resizing down.

    Just running dither's default GradFun3 debanding in a script to open my video without resizing reduced the banding quite substantially while to my surprise, having very little effect on detail.

    I guess the real idea of dither is to prevent banding problems in the first place, and I'm yet to use it for encoding, but given the results when using it in a script just to view video, I'll be doing so soon, so I thought I'd offer it as an alternative here given resizing was being discussed.
    Quote Quote  
  26. So I'm back again. I've been using AvsPmod to play around with comparing different filters (Bicubic, Bilinear, Spline36, and Lanczos). When I'm viewing at 100% it's nearly impossible to tell a difference. Maybe I just don't know what to look for. When I zoom in to 200% or 400% and look at the pixels as i toggle between the filters, Bicubic and Bilinear seem to be softer and Spline36 and Lanczos seem to be sharper. That's all the info this uneducated guy was able to glean from the comparison. But I'm pretty sure my source material is pretty sharp to begin with for what it's worth. I'm not sure where I should go from here though.
    Quote Quote  
  27. I can't see a huge difference between resizers on my PC monitor either but running detailed video full screen on my TV I can.

    I haven't used it a lot yet but I'm impressed with Dither's resizing so far. I mentioned it in my previous post. It's very easy to use. Just download the Dither zip file (link in post #3 here http://forum.doom9.org/showthread.php?p=1386559) and copy the required dlls and avis files to the AVISynth plugin folder so they'll load each time AVISynth runs. From there it's about as simple to add to a script as any other resizer.

    Dither_convert_8_to_16()
    Dither_resize16 (720, 400)
    DitherPost()

    The first line converts from 8 to 16 bit, the second does the resizing, and the third converts back to 8 bit. It seems as sharp as Spline36 but shouldn't cause any color banding when resizing. I haven't compared it closely to Spline36 yet in terms of the stuff you don't want a resizer to do..... oversharpening halos or jagged edges etc but I suspect it'll do a better job there too.
    Quote Quote  
  28. Originally Posted by hello_hello View Post
    I can't see a huge difference between resizers on my PC monitor either but running detailed video full screen on my TV I can.

    I haven't used it a lot yet but I'm impressed with Dither's resizing so far. I mentioned it in my previous post. It's very easy to use. Just download the Dither zip file (link in post #3 here http://forum.doom9.org/showthread.php?p=1386559) and copy the required dlls and avis files to the AVISynth plugin folder so they'll load each time AVISynth runs. From there it's about as simple to add to a script as any other resizer.

    Dither_convert_8_to_16()
    Dither_resize16 (720, 400)
    DitherPost()

    The first line converts from 8 to 16 bit, the second does the resizing, and the third converts back to 8 bit. It seems as sharp as Spline36 but shouldn't cause any color banding when resizing. I haven't compared it closely to Spline36 yet in terms of the stuff you don't want a resizer to do..... oversharpening halos or jagged edges etc but I suspect it'll do a better job there too.
    Nice, I'll try out Dither too. thanks.
    Quote Quote  
  29. Originally Posted by Radio Radio View Post
    When I zoom in to 200% or 400% and look at the pixels as i toggle between the filters, Bicubic and Bilinear seem to be softer and Spline36 and Lanczos seem to be sharper.
    Watch out for oversharpening halos with very sharp material:

    Click image for larger version

Name:	over.png
Views:	1616
Size:	1.9 KB
ID:	15529

    That was a sharp border between RGB=23 on the left and RGB=75 on the right. After downsizing with LanczosResize() (shown with a 16x point resize upscale here) it has developed a dark halo on the dark side, and a light halo on the light side.

    Sharpening also increases noise. More noise will require more bitrate to encode.

    Too much sharpness will result in more buzzing edges -- ie, as sharp edges move slightly you will see more obvious aliasing artifacts.
    Quote Quote  
  30. So I have another resizing (plus fps conversion) question, i figured id add it to this thread instead of making another one.

    I have a small video (AVC), that is 1920x1080, and 25fps. I'd like to resize it to 720x480 with fps of either 23.97 or 29.97. I'd still want to use an avisynth script and encode with HC Encoder.

    Wondering what kind of script I would need to write to accomplish this. Thanks in advance.
    Quote Quote  



Similar Threads