Log in

View Full Version : Multiple cropping in 1 video?


8-BaLL
28th May 2015, 00:45
Hello,

is there a way to use multiple+different cropping in 1 video?

Lets say I have a video with 2 different black bars, like 1 part has 4+10 pixel black bars and the 2nd part has 8+6 pixel black bars.

Is there a way to crop both parts accordingly?

StainlessS
28th May 2015, 01:42
Not completely sure what you wanted (4+10, 8+6) but maybe this will do.

SomeSource("Whatever.xxx")

A=Trim(0,Part1_EndFrm) # 1st make two separate clips
B=Trim(Part1_EndFrm+1,0)

A=A.Crop(0,4,0,-10) # Have guessed by 4+10 you mean 4 off top and 10 off bottom.
B=B.Crop(0,8,0,-6) # Have guessed by 8+6 you mean 8 off top and 6 off bottom.

Return A++B # glue them back 2gether again.


If interlaced can only crop vertical in multiples of 4 (YV12), also both cropped clips must result in same size
otherwise must make same size (crop more/less [or resize only if not interlaced]).

EDIT: Having seen your other post in another thread, have changed to below (4+10, 8+6 being left and right).

SomeSource("Whatever.xxx")

A=Trim(0,Part1_EndFrm) # 1st make two separate clips
B=Trim(Part1_EndFrm+1,0)

A=A.Crop(4,0,-10,0)
B=B.Crop(8,0,-6,0)

Return A++B # glue them back 2gether again.


However, 720 - 14 is 706 and not a valid horizontal DVD resolution

8-BaLL
28th May 2015, 02:10
OK thank you , looks like what I need, 4+10, 8+6 is left bar and right bar.

Also why is B=Trim(Part1_EndFrm+1,0)

and not B=Trim(Part1_EndFrm+Part2_EndFrm) ? What does 1,0 mean?

Yes video is same pixel size ofcourse its 1 dvd video.

StainlessS
28th May 2015, 02:22
B=Trim(Part1_EndFrm+1,0)

The start position for the 2nd part is 1 higher than the end frame for the 1st part.
And, End Frame of 0, means 'to the very last frame'.
Also, a -ve End Frame means '-ve this many frames' ie -1 means 1 frames and -20096 means 20096 frames.

But, as in edit above, 706 width is not valid for NTSC DVD (EDIT: 720 or 704 only, I think [not counting half width versions]).

8-BaLL
28th May 2015, 02:36
Thanks for the info, well you can check the image out yourself:

after cropping it is 708 pixels:

http://107.imagebam.com/download/LbkqkAbj8GgFRvT7AJZIFg/41215/412146194/00%20example.png

StainlessS
28th May 2015, 02:46
720 - (4+10) and 720 - (8+6) are both 706.
I would just chop off another 2 pixels from one side or other (for both parts) and have it at 704x480 which
is I believe still valid, perhaps someone could verify that 704 is valid NTSC dvd width.

EDIT: Would have to be 2 additional pixels from one or other side, and not 1 pixel from left and 1 from right, ie can only
crop horizontal multiples of 2 pixels in YV12.

EDIT: For that particular frame, I would just chop off 8 pixels either side = 704 wide.

EDIT: Ignore above, seen in other thread that your destination is x264 and not DVD.

hello_hello
28th May 2015, 13:13
I do it like this, but the end result is the same.

Trim(0,500).crop(4,0,-10,0)/
++Trim(501,1000).crop(8,0,-6,0)/
++Trim(1001,0).crop(4,0,-10,0)

(when you use zero as the second number for Trim it means "keep going to the end")

If you're resizing, you're free to crop completely differently if you like.

Trim(0,500).crop(6,2,-10,-4).Spline36Resize(640,480)/
++Trim(501,1000).crop(18,8,-6,-6).Spline36Resize(640,480)/
++Trim(1001,0).crop(12,4,-6,-4).Spline36Resize(640,480)

Each section needs to be the same dimensions whether you do it by cropping or resizing or both.
Obviously you'd still crop to achieve the correct display aspect ratio when resizing each section (the above wouldn't necessarily be 1.3333 as I just made up numbers) but if you're resizing it lets you crop different sections completely differently if need be.
And of course you're not just limited to different cropping or resizing. You can apply any filtering to sections of video using the above method.

8-BaLL
28th May 2015, 13:59
@hello_hello-

thank you! It was exatly what I was looking for. This helped me realize how to separately edit scenes.

hello_hello
30th May 2015, 10:58
That's kind of why I was saying in the other thread I tend not to over-think the cropping too much, especially as I resize to square pixel dimensions anyway, so as long as each section is cropped cleanly to 4:3, even if it means cropping a little picture, the end result is a nice, clean 4:3 output.

When resizing to square pixels in a perfect world you wouldn't resize the height. You'd crop the black and resize the width to give you the correct aspect ratio, but I find I'm often cropping a little more here and resizing a little more there..... and even if I was using anamorphic encoding sometimes I still resize a bit here and there..... for me even a single encode is often a collection of little compromises.

Oh..... and eventually you might discover you can effectively crop an odd number of pixels (not just multiples of two) if you're resizing, and when you do if you're anything like me your cropping/resizing/aspect ratio OCD tendencies will ramp up another gear, occasionally requiring medication. :)

Because the resize filters can crop an odd numbers of pixels, if you wanted to crop 9 pixels from the left, 2 from the top, 4 from the right and 7 from the bottom, you could do this:

Crop(8, 2, -4, -6)
Spline36Resize(640,480,1,0,0,-1)