Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Nov 2002
Posts: 24
|
Idea (and a solution) for Speedup of Encoding (up to 20%)
First of all: many thanks to dvd2svcd for this great piece of software!
Now I will sketch my idea, which I already implemented in my own DVD->SVCD scripts some time ago, before using (the much more sophisticated) DVD2SVCD. Since I already tested it, I can report, that it works great. Up to 20% of speedup during encoding which is essential if you are using a slow computer like mine :-) 1) When clicking on "Rip & Convert", DVD2SVCD should show the preview window just like after clicking Preview. 2) There the user can mark the top and bottom boundaries of the black bars (if any). 3) The first thing in the AVS-Script is to cut away the black bars. All other transformations (like scale) on the video will act faster, because of the smaller input. 4) The last thing after scaling and anything else is to add appropriate borders. The image now just looks like it would look without that "trick". I know, this does not really speed up encoding, because the encoder has to encode the complete image, but the frameserving is much faster. What do you think of this idea? Of course, you can add some additional features like cutting away some pixels on the left and the right, scale the picture to a height being a multiple of 8, add borders being a multiple of 8. After that, the macro-blocks will either be completely black or completely part of the picture which leads to a better image quality using the same bitrate. If someone is interested in this idea, I would like to publish my formulas which I developed for my scripts. As this is just an idea, I would like to know what you all think about this procedure. Cheers, neopholus Last edited by neopholus; 24th November 2002 at 18:08. |
![]() |
![]() |
![]() |
#2 | Link |
Retired
Join Date: Nov 2002
Posts: 1,349
|
Well, you know that this screws up the aspect ratio of the movie, do you? To keep the original aspect ratio, you'd also have to crop an appropriate number of pixels from the left and right. You should notice a slight "egghead" effect in the encoded movie.
What I am doing for 2.35:1 movies (where black bars are already part of the original frames) is something similar that should also save a little encoding time by having only "one kind of black" for the black bars but preserves the correct aspect ratio: In the AVISynth script, after the Resize and AddBorders, I've added a Letterbox command that entirely "covers" the original and added borders. So for 2.35:1 PAL movies I've added the following custom AVISynth script to dvd2svcd.ini: [AVISYNTH_BicubicResize PAL 2.35:1] 0=BicubicResize(^TargetWidth,^TargetHeight,^b_value,^c_value) 1=AddBorders(0,^BorderTop,0,^BorderBottom) 2=Letterbox(^Top,^Bottom) ^b_value=0.0 ^c_value=0.6 ^Top=128 ^Bottom=128 (requires latest DVD2SVCD version, you can select such custom scripts on the Frameserver tab, see readme) I haven't run any speed comparisons but you could try that to see if it provides a similar performance gain. |
![]() |
![]() |
![]() |
#3 | Link | |
Registered User
Join Date: Nov 2002
Posts: 24
|
Quote:
Mmm, no, I don't think that it screws up the aspect ratio (and I don't see eggheads in my videos ![]() Let's use an example: With cropping black bars:
Without cropping black bars, it looks like that:
Advantages of cropping and adding borders afterwards:
You see, we scale the picture just as normal, but we know, how squeezed black bars look like: they look like black bars with 3/4 the height of the original bar. So we crop them, scale the rest and add the normal borders (as always) plus the cropped borders afterwards. This works with 4:3 movies as well, as long as there are black bars, but of course we must not scale the picture vertically, just horizontally. If there are no black bars, just work as always. I think, this can't be integrated in DVD2SVCD using a cusom AVISynth filter, can it? The formulas for height and width of the scaled cropped borders and the formulas for the height of the black bars to add after scaling depend on whether it is a 4:3 or it is a 16:9 anamorphic video. O.K., I could add two cusom filter, and depending on the format of the source, I could choose the right one. But, of course, I still have to know the height of the original black bars... I would like to use the preview windows to determine these heights. @RB: Where do you get the values for ^Top and ^Bottom for your script from? I hope, this text is comprehensible... Cheers, neopholus Last edited by neopholus; 18th November 2002 at 22:17. |
|
![]() |
![]() |
![]() |
#4 | Link | |
Retired
Join Date: Nov 2002
Posts: 1,349
|
OK, I see it now, you are correct. I thought you were resizing the cropped picture to 480x432. I'll try this out. Thanks!
Quote:
Also, I think your assumption that there are 42/43 lines of black bars in 2.35:1 anamorphic videos is not correct. I just verified with The Matrix: took a still picture from the DVD with WinDVD and there are 77 lines of black bars. Some movies even have slightly different black bars (Gladiator RC2 PAL: 73 top/67 bottom). So it doesn't seem to be a good idea to use a common crop/resize/addborders script for those movies. Maybe the best thing to do is use "Edit the AVISynth Script File" on the Frameserver tab, check "Use frame selection" on the Conversion tab. Then start encoding, go to a frame where the bars are well visible in Frame Selection, take a screenshot of the Frame Selection window, determine the area to crop to, cancel frame selection and finally edit the AVISynth script accordingly. |
|
![]() |
![]() |
![]() |
#5 | Link | ||
Registered User
Join Date: Nov 2002
Posts: 24
|
Quote:
Quote:
@RB: Thank you for the trick with the Frame Selection window. I will try this one. Its faster than using dvd2avi, I think. Cheers, neopholus |
||
![]() |
![]() |
![]() |
#6 | Link |
Registered User
Join Date: Jun 2002
Posts: 416
|
The easiest way is to load DVD2AVI project file in GKnot to crop and after that to recalculate the resizing "manualy". You can set the Hresize to 480, and recalculate the Vresize (and borders) folowing Question 62 from Q&A.
P.S. I'm doing it from some time, but didn't found speed increase. Last edited by Abond; 19th November 2002 at 14:26. |
![]() |
![]() |
![]() |
#7 | Link | |
Registered User
Join Date: Nov 2002
Posts: 24
|
Quote:
Cheers, neopholus |
|
![]() |
![]() |
![]() |
#8 | Link |
Registered User
Join Date: Jun 2002
Posts: 416
|
E-eh, well, sorry, I didn't say you should. I think it is very easy, but may be I should add "for me". In fact Gordian Knot is the same frontend program as DVD2SVCD, but for encoding DivX movies (.avi). I think it is easy because it has what you ask for DVD2SVCD - preview even with autocrop (or manual if you like), if you want for example to convert 2.35 to 1.85 it will crop automatically from left-right and so on. The program generates avs files and there is option for SVCD resolution - you can use directly the generated avs script. Well, it is up to you...
Greetings. |
![]() |
![]() |
![]() |
#9 | Link | |
Registered User
Join Date: Nov 2002
Posts: 24
|
Quote:
And, I see now, you are right, Gordian Knot might have some functionality which is helpful... I think, I will download this program and give it a try. Cheers, neopholus |
|
![]() |
![]() |
![]() |
#11 | Link | |
Retired
Join Date: Nov 2002
Posts: 1,349
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#13 | Link |
Retired
Join Date: Nov 2002
Posts: 1,349
|
What's FairUse?
Anyway, I think implementing an automatic cropping feature is almost impossible. What would be a nice future enhancement though is a check box like "Use manual crop" on the Conversion tab. It would work similar to "Use frame selection" in that it pops up a (selectable) frame from the movie where we can drag a selection box around the actual movie content. D2S would then modify it's default AVISynth script accordingly to first crop, then resize/addborders, taking into account the movies aspect ratio. DVD2SVCD, are you listening? ![]() |
![]() |
![]() |
![]() |
#14 | Link | |
Registered User
Join Date: Nov 2002
Posts: 24
|
Quote:
thanks for these facts. What aspect ratio was that movie? I think a lot of current movies are 2.35:1 with about 256 black lines altogether. So 44% of the original picture need not to be scaled, so there should be much more speed-up. (I had more speed-up with such movies, but this was one year ago...). I'll try a movie myself, because I used this trick before using DVD2SVCD with some older versions of avisynth, so it might be, that scaling is now much faster then before so that encoding is now the real hard part of the work. But when using some sophisticated filters on a movie (like DVD2SVCD and others seem to do on comic material?) the speed up should be more relevant. Some questions:
Ideas, comments? Cheers, neopholus |
|
![]() |
![]() |
![]() |
#15 | Link | ||
Retired
Join Date: Nov 2002
Posts: 1,349
|
Quote:
Quote:
No, I don't think a "heuristic scan" for black bars is possible. Just think about very dark scenes. How would you know, programmatically, which frame to pick so you can safely "identify" the black bars? We need a manual crop. |
||
![]() |
![]() |
![]() |
#16 | Link |
Registered User
Join Date: Nov 2001
Posts: 123
|
FairUse is a Divx encoding package you can find in the download section. It is a similar in style to DVD2SVCD but for Divx of course. It has a preview function that pops up after the DVD is ripped that allows you to auto crop the video or to manually do the same, and select frame range as well.
|
![]() |
![]() |
![]() |
#17 | Link |
Registered User
Join Date: Nov 2002
Posts: 24
|
I did some tests with my Lord of the Rings DVD (only one chapter):
Normal AVS-script: Code:
LoadPlugin("C:\PROGRA~1\SVCD\DVD2SVCD\MPEG2Dec\mpeg2dec.dll") LoadPlugin("C:\PROGRA~1\SVCD\DVD2SVCD\AVISYN~1.DLL") mpeg2source("D:\svcd\DVD2AV~1.D2V") BilinearResize(480,432) AddBorders(0,72,0,72) AvisynthSubtitler("D:\svcd\Subs\","permsubs.txt") ResampleAudio(44100) Alternate script, macroblock-optimized ![]() Code:
LoadPlugin("C:\PROGRA~1\SVCD\DVD2SVCD\MPEG2Dec\mpeg2dec.dll") LoadPlugin("C:\PROGRA~1\SVCD\DVD2SVCD\AVISYN~1.DLL") mpeg2source("D:\svcd\DVD2AV~1.D2V") Crop(6,78,709,420) BilinearResize(480,320) AddBorders(0,128,0,128) AvisynthSubtitler("D:\svcd\Subs\","permsubs.txt") ResampleAudio(44100) Speedup about 11%. With more sophisticated resize-filters and other filters, there could be even more speedup. And: real black bars And: More bitrate for the movie Cheers, neopholus |
![]() |
![]() |
![]() |
#18 | Link |
Registered User
Join Date: Nov 2002
Posts: 24
|
Hello there,
I think I can give you an almost automated solutions to the problem: Add these lines of codes to your dvd2svcd.ini (and modify it if you want another resizer or add temporal soften,...) Code:
[AVISYNTH_DetectBorders] 0=LoadPlugin(!AutoCrop.dll) 1=AutoCrop(true,1,1,0,0,0,0,40,10) 2=BilinearResize(^TargetWidth,^TargetHeight) 3=AddBorders(0,^TopBorder,0,^BottomBorder) !AutoCrop.dll=C:\Programme\SVCD\DVD2SVCD\Autocrop\AutoCrop.dll [AVISYNTH_BilinearResizeWithoutBlackBorders] 0=Is_16_9_movie=?16_9 1=Crop(^Crop_Left, ^Crop_Top, ^Crop_Width, ^Crop_Height) 2=AutoResize(Is_16_9_movie) 3=AutoAddBorders() 4=function AutoAddBorders(Clip c) { 5=aab_top = (Floor(((576 - c.height) / 2) / 16))*16 6=aab_bottom = (576 - aab_top) - c.height 7=return addBorders(c, 0, aab_top, 0, aab_bottom) 8=} 9=function AutoResize(Clip c, bool is_16_to_9) { 10=factor = (is_16_to_9 == true) ? 0.75 : 1.0 11=height = Round((720.0 / c.width) * c.height * factor) 12=return BilinearResize(c, 480, height) 13=} ?16_9=true ^Crop_Left=0 ^Crop_Top=0 ^Crop_Width=720 ^Crop_Height=576 1) Insert DVD into your drive 2) Start dvd2svcd 3) Press the DVD-icon on the Conversion tab 4) Notice the "Aspect ratio" of the movie (16:9 or 4:3) 5) Select Go->Preview Video (still picture) 6) Go to the frameserver-tab 7) Select the "DetectBorders" avisynth script 8) Note the autocrop info on the preview (if the borders are not detected very well, use "New Frame"-button!) On my test DVD the autocrop-info was Crop(4,76,713,423) 9) Select the "BilinearResizeWithoutBlackBars" avisynth script 10) Set the variable Is_16_9_movie to true (16:9 movie) or false (4:3 movie) 11) Edit the parameters of the Crop-line to match the ones of the autocrop information 12) ready!! Even if you cropped some pixels from left and right, the script calculates the correct size of the video, adds borders and the movie is ready to be converted. Some additional hints: - the script calculates the top and bottom borders to align the top of the picture to a multiple of 16 (macroblock optimisation). Thus, there can be different large borders on top and on bottom. If you do not like this behaviour, modify the BilinearResizeWithoutBlackBorders script: Code:
... 5=aab_top = Round((576 - c.height) / 2) ... - The autocrop-filter can be found here: here. - Some discussions on this filter can be found here. Cheers, neopholus Last edited by neopholus; 25th November 2002 at 10:54. |
![]() |
![]() |
![]() |
#20 | Link |
Registered User
Join Date: Nov 2002
Posts: 24
|
Hi,
just a question to DVD2SVCD: would it be possible to pass some more information from the gui to the avisynth-Scripts? Example: Information about the aspect ratio of a movie.... would eliminate a potential source of errors... just a question ![]() Cheers, neopholus |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|