View Full Version : cropping
shpanks
27th October 2003, 21:45
hi,
i have a movie ready for watching but it has burnt in french subtitles in the black matte and i want to edit them out (crop them out) cos they are annoying. i'd rather have english subtitles there instead of having to have them on the picture and having a confusing two sets of subtitles. Also at the end of the movie the aspect ratios get all screwy and it puts another set of black mattes within the already encoded black mattes and then a picture within the second set of black mattes! I wouldn't really care normally but it also happens to squeeze the picture and make it fat. my hypothesis is that its a 4:3 thats been stretched. I'd like to fix the aspect ratio and reattach it to the end of the movie so the whole movie is in perfect aspect ratio!!!
Is there any quick easy like preferably no rencoding way of cropping the stuffs or even if i have to rencode some easy way of configuring it so that i can retain as much quality as possible without too much headache.
I hope some1 out there has a solution for this problem of mine
I have enclosed linked picture references to both the scenarios.
http://geocities.com/cyanidespillromania/screenies/
jggimi
27th October 2003, 22:09
What are your source format(s) of video/audio/subtitle, what are your end formats, and, what processes are you using?
For example, if the french subtitles are burned into the video stream, then removal via cropping would require re-encoding. If the subtitles are in a separate stream, then one merely removes the stream. How that is done will depend, again, on the formats in, formats out, and your tools.
More information = better answers.
shpanks
28th October 2003, 13:22
sorry about that my bad :D
video:div3
audio:mp3:128kbps
i thought i cleared this up but neway it has subtitles that have been encoded into the stream it has burnt in french subtitles in the black matte . They appear in the black matte which has also been encoded into the stream. I cannot remove them unless i rencode; if the french subtitles are burned into the video stream, then removal via cropping would require re-encoding? Damn is that the only way,... ah well!
I don't really care what the end formats are as long as i can preserve as much quality as possible when i have to rencode. I have already encoded it so i presume that there no processes being used.
jggimi
28th October 2003, 16:00
...I have already encoded it...Your best solution is to return to your DVD source, and reencode it from that. That is my recommendatation.
You could re-encode from your DivX 3 backup, but your quality will degrade, and you will probably not like the results....so i presume that there no processes being used.To go from AVI -> AVI or AVI -> something else would necessitate encoding procedures, wouldn't it?
For example, if it was my task to redo this encode, and if I insisted on starting from this AVI rather than DVD, I would use AviSynth scripting to segment the two sections of the source and crop / resize separately, then rejoin them. I'd probably use Gordian Knot as my initial AviSynth script generator, and perhaps as my encoding manager, if my output was back to AVI. My output would either be back to AVI, or to SVCD, or XVCD, depending on my intended use. But that's just me, and that's just one example of the possibilities.
shpanks
29th October 2003, 02:17
To go from AVI -> AVI or AVI -> something else would necessitate encoding procedures, wouldn't it?
sorry if this sounds a bit blunt but what the hell does that mean?!! does that mean going from dvd to avi would include processes like ummm compression and stuff?
I would use AviSynth scripting to segment the two sections of the source and crop / resize separately, then rejoin them
how do i got about doing that. Do i just split the source into two avi files and run them through individually in gknot? Prob with that is how to make sure they'll join to make 700mb?
neway thanx for ur continuance in replies!
jggimi
29th October 2003, 03:39
Don't get tangled up in terminology. By "process", I mean the set of steps that include transcoding, re-encoding or any other transformation of audio, video, subtitles, and the like. If you are starting with an AVI audio/video file, and will be cropping, resizing, and re-encoding, then yes, a "process" would be chosen to accomplish that. The software tools you choose to use, and the processes you choose to use can vary widely to accomplish the mission.
You seem aware of Gknot. Are you comfortable with it? Did you know that .avi files or .avs files (AviSynth scripts) can be used as the source, not just .d2v files? You could use it to crop / resize your AVI video and remove the subtitles, and your output video could be DivX 3 again, or DivX 5, or XviD. But it wouldn't, by itself, be enough to give you a complete .avi file. You'd end up with video only. So you'd need to demux your current .avi file to extract the audio, and then mux it back into the finished product, using "just mux" in the Audio 1 tab within Gknot's Encoder tab. Comfortable with that? Have you ever used VirtualDubMod? It is part of the Gknot suite (used for encoding DivX 5 and XviD). And I would use it to demux the audio into a separate file, since it handles VBR MP3 without trouble.
But it's more complicated than that. You have two sections of your video which apparently will need different cropping / resizing steps. With Gknot/AviSynth, you have several choices for managing the different cropping/resizing requirements of your video. If you were familiar and comforatable with AviSynth scripting, you could edit the .avs script Gknot creates and, using Trim() commands, create different clips with different cropping/resizing values, and then concatenate them for a single encoding. You could use VdubMod to split the videos into two separate files at the appropriate point, and use Gknot to crop/resize them as needed for your final resolution. Then, create a relatively simple AviSynth script to concatenate the video from both Gknot created scripts into a single clip, and use that as input to Gknot.There are other processes that could be used. You could avoid AviSynth entirely, by manual steps with a variety of encoders, such as TMPGEnc or many of the Vdub variants.
But, when you're all done with the project, you'll have a video with poor quality, regardless of your tool or methodology choices. Do you understand why I recommend returning to the DVD for encoding?
shpanks
29th October 2003, 08:26
i am fairly comfortable with gknot, have vaguely used avisynth and am also relatively confident with vdub and its affiliates.
I think that 1, edit the .avs script Gknot creates and, using Trim() commands, create different clips with different cropping/resizing values, and then concatenate them for a single encoding. would be the best way because if i split with vdub then i can only split at keyframes and therefore it may be undesirablely offset.
I installed latest version of gknot and loaded up movie.avi set all the values cropping for the first part of the movie (the bulk of the movie) etc... but i don't understand how this trim thing worx what do i add in my .avs script how do i concatenate?
Why are u so against rencoding i don't c y it is such a bad idea. The way i see it is simply playing back the source into a new container. Can't be any worse than recompressing dvds to divx. Anyway's i can't rencode from DVD cos i lent it to friend weho i dont' c all too often so yea i'm just gonna have to stick with what i got.
jggimi
29th October 2003, 19:22
I have created a sample AviSynth script which turns your two screenshots into a single synthetic avi. If you copy and paste this text into an .avs file, changing the file names to match the two jpg images, you can "play" the .avs in Vdub or any AVI player as if it is an AVI. The first 1001 frames are the image with the subtitles removed, the second 1001 frames are the image with incorrect aspect ratio.
The two .jpgs were of different resolutions. Here's what the script looks like:imagereader("c:\z\oz-french.jpg")
# 1001 frames from the jpg, which is 588x450 in size
flipvertical()
# imagereader pulls the image in upside down, this flips it right side up
a=crop(0,74,0,-74)
# cropped 74 lines off top and bottom, image is now 588x302
#
imagereader("c:\z\oz-aspect.jpg")
# second jpg is 591x458
flipvertical()
# flip it right side up
Crop(0,110,0,-110)
# cropped 110 lines off top and bottom, image is now 591x238
b=LanczosResize(588,302)
# Makes b the same size as a
a+b
# concatenates both videos into 2002 frames
Obviously, I don't have your AVI file available, so I have also provided an untested script that should work with your AVI file as input. It uses the Trim() command to create two clips from the same AVI. You will have to edit in your file name, the crop values as appropriate, and the frame numbers where the breakpoint would be. Obviously, you'll want to test it with Vdub or an AVI player prior to encoding.AviSource("<your file here>")
#
# First, the avi video is broken into two separate clips, "a" and "b"
#
a=Trim(0,<last frame # in first section>)
b=Trim(<first frame # in second section>,0)
#
# Then, "c" and "d" are cropped versions of "a" and "b" to remove letterboxing
#
c=Crop(a,0,<lines on top of "a">,0,-<lines on bottom of "a">)
d=Crop(b,0,<lines on top of "b">,0,-<lines on bottom of "b">)
#
# Then section "e" is created by resizing "d" to match the size of "c"
#
e=LanczosResize(d,<resolution of "c" section -- "a" after cropping)
#
# The two clips are joined together
#
c+e
You asked:...Why are u so against rencoding i don't c y it is such a bad idea. The way i see it is simply playing back the source into a new container. Can't be any worse than recompressing dvds to divx...Ask anyone who's done it before, or search through the forum using keywords like "re-encoding."
MPEGs, including all MPEG-4s such as DivX 3, are lossy. Information is lost during the encoding. DVDs use MPEG-2, which is lossy, but they have a much much higher bitrate than your AVI. DVD combined bitrates can be close to 10 Megabits per second. Your AVI has greatly reduced content compared to the DVD, and has been resized (which also loses information).
If nothing I (or anyone else) could tell you would change your mind; you'll just have to see it for yourself. I selected Lanczos resizing in these scripts because it should retain the most detail (with some loss of compressibility). But even with that sharpest of common resizing methods, you probably won't like the results.
jggimi
29th October 2003, 20:26
Just so the syntax is clear, here is the script using made up names and numbers: The video source is myvideo.avi, in the same directory as the AviSynth script. The last frame # of the unresized section is frame # 10000. The first frame of the section that needs resizing is 10001. The first section has 60 lines removed from the top and bottom, to eliminate letterboxing and french subtitles. The second section has a total of 100 lines removed from the top and bottom. The second section will be resized to that of the cropped first section, which will be 400 x 200 (the source AVI is 400 x 320).AviSource("myvideo.avi")
#
# First, the avi video is broken into two separate clips, "a" and "b"
#
a=Trim(0,10000)
b=Trim(10001,0)
#
# Then, "c" and "d" are cropped versions of "a" and "b" to remove letterboxing
#
c=Crop(a,0,60,0,-60)
d=Crop(b,0,-100,0,-100)
#
# Then section "e" is created by resizing "d" to match the size of "c"
#
e=LanczosResize(d,400x200)
#
# The two clips are joined together
#
c+e
shpanks
30th October 2003, 11:52
whoa mega dude u really are a pro and a half and i am greatful for everyword of ur assistancE!!!
the first script is the edited script and i'm kinda confident this'll work. i've also attached the original script Beneath the edited one. i've added the shit u taught me however as u can c on the original there is two resolutions there's one in the crop which is the cropped resolution and then there is the one in the lanscoz resize which is another resolution which gknot reports will be the final resolution. NOw seeing as i am uncertain how to get the final resolution to be 576x336 i am just going to make the final resolution the cropped resolution until of course u can instruct me o great teacher how lol!
and another thing i've taken a screenie of my gknot resolution values as well so that u can c what i'm talking about and u can c whether i'm saying the right htings (in terms of terminology that is ;)).
http://geocities.com/cyanidespillromania/screenies/
#
# Created with Gordian Knot
#
# http://gknot.doom9.org
#
# PLUGINS
LoadPlugin("F:\PROGRA~1\GORDIA~1\mpeg2dec3.dll")
LoadPlugin("F:\PROGRA~1\GORDIA~1\undot.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\decomb.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\dgbob.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\Convolution3d.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\FluxSmooth.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\TomsMoComp.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\VSFilter.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\SimpleResize.dll")
#
# SOURCE
avisource("C:\Escaflowne the Movie.avi")
#
# TRIM
#
a=Trim(0,141190)
b=Trim(141191,0)
#
# IVTC
#Telecide(order=1,guide=1).Decimate()
# or use
#IVTC(44,11,95)
#GreedyHMA(1,0,4,0,0,0,0,0)
#
# CROPPING
c=crop(a,0,64,0,-66)
d=Crop(b,0,100,0,-100)
#
# DEINTERLACING (1)
#FieldDeinterlace()
#FieldDeinterlace(blend=false)
#TomsMoComp(1,5,1)
#
# DEINTERLACING (2)
#SeparateFields().SelectEven()
# or maybe
#DGBob(order=1,mode=0)
# DEINTERLACING (3) - special requests
#GreedyHMA(1,0,0,0,0,0,0,0)
#Telecide()
#SeparateFields()
#
#
# SUBTITLES
#VobSub("FileName")
#
# RESIZING
e=LanczosResize(d,576x302)
#
c+e
#
Undot()
#
# DENOISING: choose one combination (or none)
# 1) little noise
#Temporalsoften(2,3,3,mode=2,scenechange=6)
#mergechroma(blur(1.3))
#FluxSmooth(5,7)
#
# 2) medium noise
#Temporalsoften(3,5,5,mode=2,scenechange=10)
#Convolution3d("moviehq")
#FluxSmooth(7,7)
#
# 3) heavy noise
#Temporalsoften(4,8,8,mode=2,scenechange=10)
#Convolution3d("movielq")
#FluxSmooth(10,15)
#
# BORDERS
#AddBorders(left,top,right,bottom)
#
# COMPRESSIBILITY CHECK
# !!!!Snip Size now has to be 14 for use in GKnot!
#SelectRangeEvery(280,14)
#
# FOOL CCEnc
#empty = BlankClip()
#AudioDub(last,empty)
--------------------------------------------
#
# Created with Gordian Knot
#
# http://gknot.doom9.org
#
# PLUGINS
LoadPlugin("F:\PROGRA~1\GORDIA~1\mpeg2dec3.dll")
LoadPlugin("F:\PROGRA~1\GORDIA~1\undot.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\decomb.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\dgbob.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\Convolution3d.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\FluxSmooth.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\TomsMoComp.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\VSFilter.dll")
#LoadPlugin("F:\PROGRA~1\GORDIA~1\SimpleResize.dll")
#
# SOURCE
avisource("C:\Escaflowne the Movie.avi")
#
# TRIM
#trim(startframe,endframe)
#
# IVTC
#Telecide(order=1,guide=1).Decimate()
# or use
#IVTC(44,11,95)
#GreedyHMA(1,0,4,0,0,0,0,0)
#
# CROPPING
crop(0,64,576,302)
#
# DEINTERLACING (1)
#FieldDeinterlace()
#FieldDeinterlace(blend=false)
#TomsMoComp(1,5,1)
#
# DEINTERLACING (2)
#SeparateFields().SelectEven()
# or maybe
#DGBob(order=1,mode=0)
# DEINTERLACING (3) - special requests
#GreedyHMA(1,0,0,0,0,0,0,0)
#Telecide()
#SeparateFields()
#
#
# SUBTITLES
#VobSub("FileName")
#
# RESIZING
LanczosResize(576,336)
#
Undot()
#
# DENOISING: choose one combination (or none)
# 1) little noise
#Temporalsoften(2,3,3,mode=2,scenechange=6)
#mergechroma(blur(1.3))
#FluxSmooth(5,7)
#
# 2) medium noise
#Temporalsoften(3,5,5,mode=2,scenechange=10)
#Convolution3d("moviehq")
#FluxSmooth(7,7)
#
# 3) heavy noise
#Temporalsoften(4,8,8,mode=2,scenechange=10)
#Convolution3d("movielq")
#FluxSmooth(10,15)
#
# BORDERS
#AddBorders(left,top,right,bottom)
#
# COMPRESSIBILITY CHECK
# !!!!Snip Size now has to be 14 for use in GKnot!
#SelectRangeEvery(280,14)
#
# FOOL CCEnc
#empty = BlankClip()
#AudioDub(last,empty)
manono
30th October 2003, 13:14
Hi-
Sorry to butt in. I've been following this thread with some interest for awhile. Now you're finally beginning to appreciate jggimi's efforts. I thought you were a bit rude earlier in the thread (just my opinion, though). Here's a tip; the next time you include one of those GKnot generated .avs's, leave out the lines beginning with "#". It makes the post longer than necessary, and makes it harder to decipher the .avs. It's good you posted the pic. When you open an .avi, you make the Input Pixel Aspect Ratio 1:1 (you have it as 4:3). Here's how I would do it. It's just a slight variation on jggimi's method:
LoadPlugin("F:\PROGRA~1\GORDIA~1\mpeg2dec3.dll")
LoadPlugin("F:\PROGRA~1\GORDIA~1\undot.dll")
avisource("C:\Escaflowne the Movie.avi")
a=Trim(0,141190).Crop(0,64,0,-66).LanczosResize(576,302)
b=Trim(141191,0).Crop(0,100,0,-100).LanczosResize(576,302)
a+b
Undot()
See, much shorter. :)
Some other things; the figures will change slightly, because you're going to change from 4:3 to 1:1. That 302 in the LanczosResize is no good (only Mod 2). Reset the H Modul in the Resolution Tab to 16 (or at least 8). So your final resolution will probably be 576x304. Yes, it may mean cropping into the video a bit, in order to keep proper AR. Keep an eye on the Aspect Error. Even though you've got the IPAR as 4:3, you've got Aspect Error at 1.4%, which is high. Try and get it down to 0.5% or less (at 1:1). When done, and the .avs is saved, open the .avs in GKnot and scroll around and make sure it looks OK. Make sure the Trim is at the right place, and make sure that the previously bad AR part now looks alright. Then you should be ready for reencoding.
jggimi
30th October 2003, 15:00
Thank you, manono, for recalling the 1:1 adjustment for avi sources.
And yes, your script is shorter. :) But your "a=" line could leave off the resizing, since 576x432 after cropping would be 576x302 anyway. It doesn't hurt anything to have it there, though.
And thanks, shpanks, for showing us the Gknot resolution window.
One more thing. The .mp3 audio you extracted from your movie. To reinsert it you can 'just mux' it. But if you want to do bitrate calculations (and compression tests), you'll want to make sure the size is included in your bitrate calculations. On the Bitrate tab, in the Audio A section at the lower left, click the "Select" button and select the .mp3 file. It's size will the be used in bitrate calculations.
shpanks
31st October 2003, 00:46
wow u guys are really like pros and a halves! I've tested ur revised avs script manano (of course with ur pointers jggimi ;))and it works seamlessley upon previewing through wmp. Now all i gots tta do is encode which i don't think i'm gonna have ne problems with.
However,...... there is one thing i don't quite understand i've changed ar to 1:1 made sure my aspect ratio error is below .5% but that final resolution 576x304, isn't that useless cos i'm not resizing to that nemore; i mean the end file is going to b 570x300 is it not? I don't c where it says in the .avs script to resize 576x304?
ah well oh yea thanx jggimi but i already did the audio stuff made sure it was included in the calculations and i'm prob just gonna get gknot to auto mux the stream for me; i'm fairly sure it can do that in the audio tab in the final encoding screen.
well thanx guys neways for all ur assistance i dont even really need to encode it nemore since the avs plays fine and i could prob put subs over that as well; however i am going to for personal experience, since i'm never tried this trim thing or rencoded an avi b4.
ive inluded new gknot screenie at
http://geocities.com/cyanidespillromania/screenies/
manono
31st October 2003, 00:52
Hi-
Later I remembered that if you open the final .avs in GKnot to check it out, the crop values are still in there. Better to check it in VDubMod or in a player.
See, much shorter.
That wasn't directed to you, jggimi, but to shpanks, who had included 2 full length GKnot .avs's in his post. I wouldn't criticize you, jggimi. :) I'm constantly amazed by the effort you put into your posts. Having said that, here's a mild disagreement.
But your "a=" line could leave off the resizing
Yes, if the cropping left you with a valid resolution, which in this case it didn't. And of course, the 2 resolutions of the 2 Trims have to be the same or they can't be joined. He'll probably have to crop a few pixels more to get 576x304 with low Aspect Error, and it may involve cropping from the left and right sides, I don't know. I always figure it's safer, particularly when rookies are involved, to have a resizer in there.
Edit: shpanks answered while I was writing. Good work, shpanks.
manono
31st October 2003, 01:03
Hi-
After reading your post more carefully:
I don't c where it says in the .avs script to resize 576x304?
You shouldn't leave it at 570x300. Why not? Well read this:
http://forum.doom9.org/showthread.php?s=&threadid=42708
Particularly the paragraph beginning with And one more thing.
I had left my sample .avs at 576x302 because that's the way you had it. But I said that eventually you should resize to a proper resolution. The low Aspect Error you have is with a resize to 576x304, and not with just your crop values.
jggimi
31st October 2003, 16:12
Thanks, Manono, as usual, you're correct, the final resolution has to be legitimate.
shpanks
5th November 2003, 03:11
everything worked except for.... the end bit which i discovered has text that gets cut off :( .
I tried fixing this myself but if i crop more vertical it just goes more out of AR. Perhaps u have some other method like adding black bars where u've cropped or something.
i've put screenies in the usual spot
http://geocities.com/cyanidespillromania/screenies/
as u can c its ok for just the video but when they place text it gets cut out :'(; i included all the screenies from the original and the project both the text included scenes and 1 regular to show the difference.
********BREAKING NEWS********
for the last screenshot (the black screen with the white text) i used the original crop values and it loox perfect so u dont' have to worry abouthat 1 nemore!
manono
5th November 2003, 03:58
Hi-
I tried fixing this myself but if i crop more vertical it just goes more out of AR.
So you don't like the little bit cut from the the tops and bottoms? If I'm understanding you correctly, you want to crop less and not more, to fix it. So make the crop for the top and bottoms for that last part:
Crop(0 64,576,304)
********BREAKING NEWS********
You got it fixed. But I had already written this, and fooled around inside GKnot for a few minutes to try and help, so you have to read it. Hehe.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.