digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Video Encoding and Conversion (http://www.digitalfaq.com/archives/encode/)
-   -   To crop or not to crop! (http://www.digitalfaq.com/archives/encode/1841-crop-crop.html)

kwag 12-14-2002 10:43 PM

To crap or not to crap =:O
 
Well, actually, to crop with a mask. Not to crap :D
How would you like to save now about another megabyte of space for every 90 seconds on your KVCDs :?: Well, here we go again 8)
Here are my findings, using KVCDx2 704x480 for test purpose, using three different techniques. The first one is the one we all use. That is, create a .avs script with FitCD, and encode with that.
My sample, using this method and a fixed CQ_VBR value of 12, came out to 15,948KB.

The second one is the same .avs script and same CQ_VBR, but before we encode, go into TMPEG/Settings/Advanced and check "Clip frame" and double click on it. Now scroll to some part of your movie where you can see a bright scene and the top, bottom, left and right are clearly visible.
Now check all four boxes "Top Mask" Bottom Mask" "Left Mask" and "Right Mask". Now change the top, bottom, left and right values until you see that you just started to clip into the picture. Back off to the point where you are masking your black area completely without cutting any part of the movie. You might ask, why do this if it's already black :?: Well, it is, but it also has stray noises that we cant see, but the encoder does see :!:
The sample with this method came out to 15,060KB.

The third sample involves commenting out the bilinear resize and add borders from the .avs script, and calculating the aspect to put it manually in TMPEG. Also, check that your masks are correct as in my second sample, because these will change once you remove the bilinear resize and add borders lines from your .avs script. This is what I did: My movie is 720x480, and my target is 704x480. So I use our friend FitCD, just to find out the values I need for my resize. When I open my .d2v, and I select XVCD (704x480) as destination with 2 blocks overscan, I see that the resize line is this: BilinearResize(672,352,16,0,688,480) so that means that I will use 672x352 in TMPEG under "Video arrange method: (Center custom size)" and use these values.
Result: 14,883KB

Sample #1: 15,948KB
Sample #2: 15,060KB
Sample #3: 14,883KB

So you see, there is a difference of 1,065KB per 90 seconds, and this means higher quality for the same size of media, or longer play time. Match this with the new GOP ( 1, 36, 3, 1, 36 ) and now you can put around 120 minutes with the KVCDx3 for a "never before seen" result :wink:

And of course, here's a small cut from sample #3: http://www.kvcd.net/red.m1v

Enjoy ( I know you will :lol: )
-kwag

black prince 12-15-2002 01:38 AM

Hi HKwag,

Kwag wrote:
Quote:

The second one is the same .avs script and same CQ_VBR, but before we encode, go into TMPEG/Settings/Advanced and check "Clip frame" and double click on it. Now scroll to some part of your movie where you can see a bright scene and the top, bottom, left and right are clearly visible.
Now check all four boxes "Top Mask" Bottom Mask" "Left Mask" and "Right Mask". Now change the top, bottom, left and right values until you see that you just started to clip into the picture. Back off to the point where you are masking your black area completely without cutting any part of the movie. You might ask, why do this if it's already black Well, it is, but it also has stray noises that we cant see, but the encoder does see
The sample with this method came out to 15,060KB.
It's helpful to change the color mask to a lighter color while cropping the
borders and changing back to black when done. The masked area is ignored
by Tmpgenc during encode, but uses a default color (black). This of
course decreases file size. I tried this and my test encode went from
9,811,498 kb to 9,647,271 for LBR. I'll try third process later today
after I get some sleep. ZZZzzzzzzzzz.

-black prince

kwag 12-15-2002 01:43 AM

Hi black prince,

Yes, indeed, with a lighter color you can zero in on the edges if you can't see the film. That's why I suggested to move to a bright frame, and then do the mask. But if the film is very dark, it's a good idea to change the color to a lighter one for the masking, and then change it back to black. :) Now go get some ZZZZZleeep :D

-kwag

Boulder 12-15-2002 05:56 AM

Hi Kwag,

I'm not sure if I understood correctly, but the third sample means resizing in TMPGEnc? I thought that was of less quality than resizing with Avisynth.

8O

jamesp 12-15-2002 09:47 AM

I don'y know if i did something wrong (i will give it another go) but here are my results (2 minute clip : resize to 544x576 PAL using long gop) Primal Fear:

Normal (avs script with resize/add borders) : 28,685 KB
AVS Resize + Clipped Borders : 28,724 KB
Resize in TMPEG + Clipped Borders etc : 28,707 KB :cry:

So as you can see, the normal method gives me best results, although there is hardly any difference to speak of. I don't know if your results have come from a fault in your version of avisynth, as i can't really imagine that there should be that much difference. Anyhow, i could have made a mistake so i'll try again and let you know.

Jim

kwag 12-15-2002 09:59 AM

Quote:

Originally Posted by Boulder
Hi Kwag,

I'm not sure if I understood correctly, but the third sample means resizing in TMPGEnc? I thought that was of less quality than resizing with Avisynth.

8O


That's what I thought too 8O , but the samples look basically the same, regardless if I resized with AviSynth or TMPEG. Maybe TMPEG has improved since the last time I resized with it. This was at 704x480, so maybe at 352x240 there's a difference :?:

@jamesp,

I'm using the latest version of AviSynth (2.07). I tried two times with two differenc movies, Red Planet and The Siege, and I got the same results. I will now try 352x240 and see if there's a difference. I'll post here my result.

-kwag

kwag 12-15-2002 10:38 AM

Ok, I just encoded the 100 second file prediction sample on K-Pax using the LBR (352x240) CQ_VBR=29, and here's my result:

Using this script:

LoadPlugin("C:\encoding\MPEG2DEC.dll")
LoadPlugin("C:\encoding\fluxsmooth.dll")
LoadPlugin("C:\encoding\blockbuster.dll")
LoadPlugin("C:\encoding\legalclip.dll")
mpeg2source("K:\KPAX\VIDEO_TS\movie.d2v")

LegalClip()
BilinearResize(336,192,45,0,630,480)
FluxSmooth()

BB_Resolution = 352*240

BB_StrengthConstant = 352 * 240 * 15 # Base strength
StrengthValue = round (BB_StrengthConstant / BB_Resolution)
Blockbuster( method="noise", detail_min=1, detail_max=10, variance=1, cache=1024 ) # Apply noise if complexity is <= 10%.
Blockbuster( method="sharpen", detail_min=20, detail_max=90, strength=StrengthValue) # Sharpen only if complexity is >= 20% AND <=90%.

AddBorders(8,24,8,24)
LegalClip()

IL = Framecount / 100 # interval length in frames
SL = round(Framerate) # sample length in frames
SelectRangeEvery(IL,SL)

Result = 9,250KB

Now resizing with TMPEG and masking black area using the same script above but removing the bilinear resize and the add border lines and using 336X192 as center custom size.

Result = 8,165KB.

Note: I can see that encoding is slower (way slower!) using TMPEG's internal resize, but I can also see that the increased amount of CQ_VBR pays off :wink:
I am currently encoding K-Pax with a CQ_VBR value of 50 on the LBR, for a single CD-R. Before, I had to use I believe a value of 30. So the difference in quality is gigantic.

-kwag

andybno1 12-15-2002 12:43 PM

will you be updating the templates with the new smaller file size settings?

kwag 12-15-2002 12:55 PM

Quote:

Originally Posted by andybno1
will you be updating the templates with the new smaller file size settings?

Yep!, later this evening.
The only change will be the GOP ( 1, 36, 3, 1, 36 ) on all templates, except the KDVD templates. Those can't use that GOP, because it's not part of DVD specifications, and that's a bummer :?

-kwag

mfb 12-15-2002 01:19 PM

Hi Kwag,

I don't get it - I did some tests for your crop-methods...

'Pearl Habour' 704x576plus CQ_VBR15 new GOP
all three 100 secs-clips (normal avs, clip frame/mask, clip frame/mask & TMPEG-resize) came out almost the same size* :?:

'Spiderman' 352x288plus CQ_VBR35 new GOP
all three 100 secs-clips (normal avs, clip frame/mask, clip frame/mask & TMPEG-resize) came out almost the same size* :?:

*means just a view bytes difference

any idea why i can't reproduce your results???

regards, ***mfb***

kwag 12-15-2002 01:24 PM

Hi mfb,

Strange :roll: , are you using any filters, Sansgrip's, etc., in your .avs script? Because I get a hell of a difference.

-kwag

kwag 12-15-2002 01:47 PM

I think I know what's happening. Using SansGrip filters, specially "Noise", the Blockbuster filter is sending noise to the complete frame, and that includes the black area. This is the reason why the file size is larger when we use the resizing with avisynth. If you don't use Blockbuster filters, then the file size drops. But when I use Blockbuster filters, and do the resize and mask with TMPEG, I'm cutting off the black area completely, so even if Blockbuster is used, it will only apply to the picture area and not to the black area, as I believe is what it's doing. That is why I get smaller files with this method. So before, when using Blockbuster sharpen and noise filters, the files were much larger. This way, we can use the filters, and the file size is dramatically reduced. If you are not using any filters, then there is barely any difference in file size.

-kwag

jamesp 12-15-2002 01:54 PM

Kwag,

I think it must be something to do with sangrips filters. I tried some more tests and got the same results again. I don't use any filters other than temporalsmoother for DVD rips.

I've been doing a lot of testing with tv captures lately and i noticed that fluxsmooth(10,10) increased my encodes by about 1mb per minute compared to just using temporalsmoother(2,1), which fits in with the results your getting. I couldn't understand why, because the end results were looking loveley but the file size increase ment i ended up using a combination of Peachsmoother and temporalsmoother. I now wonder if fluxsmooth is adding noise somewhere arounf the edges of the video, and your cropping is cutting the noise out.

James

mfb 12-15-2002 02:04 PM

Quote:

Hi mfb,

Strange , are you using any filters, Sansgrip's, etc., in your .avs script? Because I get a hell of a difference.
i used almost the same script as in your latest post (all the filters, same order). :!: The only thing i didn't use was the setting 'cache=1024' for blockbuster-noise...

regards, ***mfb***

kwag 12-15-2002 02:09 PM

Hi James,

I think we crossed posted :D
Yes, the thing is that for people using SansGrip filters, this is a benefit. Specially using the "Noise" method which kills the DCT blocks on dark scenes. Before, the file size would be much larger. But now, it's almost the same as if no filter is used, with the added bonus of making the filter work focused on the picture area. I also notice that the edge boundary of the pictures is somewhat a transition from black to "something" not to clear, and then to the actual pitcure area. This can be seen on the "Clip Frame" in TMPEG when doing the mask. And if we mask out this single fine line on all four edges, it makes a file reduction of several kilobytes on the final mpeg. This of course translates to some megabytes at the end of the encoding.

-kwag

black prince 12-15-2002 02:20 PM

Hi Kwag,

Here my results:

Tmpgenc Plus 2.59
Avisynth 2.07

LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\MPEG2DEC\MPEG2DEC.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\BlockBuster\BlockBuster.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\FluxSmooth\FluxSmooth.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\LegalClip\LegalClip.dll")
mpeg2source("D:\Temp\movie.d2v")
#
LegalClip()
BilinearResize(336,224,0,0,720,480)
FluxSmooth()
Blockbuster( method="noise", detail_min=1, detail_max=10, variance=1, cache=1024 )
Blockbuster( method="sharpen", detail_min=20, detail_max=90, strength=15)
AddBorders(8,8,8,8 )
LegalClip()
#
IL = Framecount / 100 # interval length in frames
SL = round(Framerate) # sample length in frames
SelectRangeEvery(IL,SL)


Movie Length = 8465 seconds
CQ_VBR = 30


First Process:
Avisynth - BilinearResize(336,224,0,0,720,480)
Avisynth - AddBorders(8,8,8,8 )
Tmpgenc - Clip Frame (off)
Tmpgenc - Video Arrange Method - Full Screen (keep aspect ratio)
Time = 5:46 (mm:ss)
Test File Size = 9,899,721

Second Process:
Avisynth - BilinearResize(336,224,0,0,720,480)
Avisynth - AddBorders(8,8,8,8 )
Tmpgenc - Clip Frame (top=66,bot=55,right=11,left=10)
Tmpgenc - Video Arrange Method - Full Screen (keep aspect ratio)
Time = 5:10 (mm:ss)
Test File Size = 9,121,216

Third Process:
Avisynth - BilinearResize(none)
Avisynth - AddBorders(none )
Tmpgenc - Clip Frame (on)
Tmpgenc - Video Arrange Method - Center Custom (336x224)
Time = 8:54 (mm:ss)
Test File Size = 9,265,556

I expected the Third Process to produce a smaller test file size. :?
I ran these processes 4 times and came up with approximately the
same results. Finally, I ran avi scripts without SansGrip's filter's and the
results were similar to your findings. :) Not sure what to do next, since
my results are not dramatic enough in saving file size to use this process.
Maybe you can see something I am doing wrong. :)

-black prince

kwag 12-15-2002 02:36 PM

Hi black prince,

You should have "Full Screen", not "Full Screen (Keep aspect)".
I believe your first and second processes will look slightly smaller video than the third process, and that is the reason why the third file size is larger. Your third process aspect is the correct one. I can see clearly the second process file size is smaller than the first. So check your aspect on playback, and compare process one and process two and see if they look different to process three. I believe it will.

-kwag

jamesp 12-15-2002 02:44 PM

I must admit i don't use Blockbuster myself, I tried it a few times with a 544x576 template (i don't use any other template) and i noticed no difference in quality - only a larger file size. I presumed it was only for lower resolution templates. In the cases i mentioned - i was only using Fluxsmooth.

I tried one more test (While you were sleeping), and I got pretty much the same results. Doing the resize in Tmpeg also takes a lot longer although it looked just as good. I suppose that really, it doesn't work for me so i'll carry on doing it the usual way. :(

Jim

black prince 12-15-2002 04:32 PM

Kwag,

You're right!! The Video Arrange Method should have been just "Full Screen"
for processes #1 and #2. The file sizes are 9,375,050 for #1 and
9,166,052 for #2 and 8,927,583 for #3. Seems at lower CQ_VBR there
is a greater file size difference between process #1 and #3. Now I have to
figure out how to automate this :D

thanks

-black prince

black prince 12-16-2002 12:08 AM

Hi Kwag,

Just finished my semi-automated process and the results are amazing :D
File size reduced enough so I could raise the CQ_VBR from 26.84 to
37.58. The picture quality has improved greatly and there is more room
for a higher audio bitrate. I paid special attention to FitCD resize of
336x192 and bilinearResize, Addborders are commented, since Tmpgenc
would now be resizing. I created a tmpgenc project file with all the fixed
settings and used "Autoit" to insert the variables that will change from
each encode (i.e. CQ_VBR, Clip Frame, and Video Arrange Method).
I tested clip frame for top, bot, left, and right masks and hardcoded the results
in my automated program. Now all I need to change is CQ_VBR and
when my file predictor recommends the new CQ_VBR. I also show the
percentage differance of Wanted vs Actual file size. I usually stop
within +-1% to 2%. I haven't tried KVCDx3, but that's next. :lol:
"Autoit" is very cool to work with once you learn to write macro scripts 8)

-black prince


All times are GMT -5. The time now is 10:10 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.