Log in

View Full Version : Crop from certain frame on


martino
18th November 2006, 18:06
Is there a possibility to crop a video from a certain frame on (not the whole video)?

Guest
18th November 2006, 19:00
The whole video has to have the same frame size. You could crop a portion and then resize it:

vid=avisource("clip.avi")
vid1=trim(vid,0,100)
vid2=trim(vid,101,200).crop(???).lanczosresize(???)
return vid1 ++ vid2

mitsubishi
18th November 2006, 19:07
I'm not saying it's right as I'm a total noob, but this seems to work:
clip1 = DirectShowSource("G:\simpsons 1.mpg")
return clip1.trim(0,50).crop(10,10,10,10).bilinearresize(704,576) + clip1.trim(51,200) + clip1.trim(201,0).crop(40,100,-40,-40).bilinearresize(704,576)
EDIT:
Lol, Neurons replied while I was tooling about, but yeah same in mine I resized to the original size, but I only used one variable, don't know how AviSynth optimizes these things.

martino
18th November 2006, 19:07
Yes, I know that...

Thanks! You helped me a lot!!!


vid=AVISource("xxx")
vid1=trim(vid,0,29999)
vid2=trim(vid,30000,35000).crop(0,2,0,0).lanczos4resize(640,480)
return vid1 ++ vid2

This is what I used...


UPDATE: I need to crop 3 lines, and I get the following error:
Crop: YV12 images can only be cropped by even numbers (top).
How could I make sure that I don't have to crop 4 lines?

Trixter
19th November 2006, 04:28
You don't. Crop by 2 or 4 lines.

foxyshadis
19th November 2006, 07:46
trim().lanczosresize(640,480,0,3.0,0,0)

It's a floating point crop, in case you need subpixel cropping.

martino
19th November 2006, 14:47
Cheers! Is there a specified number as to how many trim operations I can have max?

UPDATE: I suppose it's unlimited...

Anyway, I found some really ugly frames in this video. See link;
http://img291.imageshack.us/img291/3050/normalkn8.png
What filters should I try to remove these artifacts

Guest
19th November 2006, 16:22
What filters should I try to remove these artifacts What artifacts? Please be specific as we are not mindreaders.

martino
19th November 2006, 16:59
Sorry. I'll try to find the right words to describe it, since english isn't my first lingo...

There seems to be some graining (most visible at the bottom), and also where two different colours meets, the lines seem quite pixelated. This anime contains a lot of fast motion, but what concerns me the most is the graining on the colours...

t1dUs
19th November 2006, 17:40
The graining is called dotcrawl, degrainmedian should fix it. And for the rest of the noise, just smooth it a little.
There are few jags in the edges, probably from a bad postprocessing of the frame.

Didée
19th November 2006, 17:52
a=last
b=a.vinverse(1.6,4).separatefields().vinverse(2.7,2).weave()
c=mt_lutxy(b,b.removegrain(4),"x 5 + y < x 2 + x 5 - y > x 2 - x x y - 4.4 5 / * - ? ?",U=3,V=3)
b.repair(c,1)
spline36resize(640+320,480+240)
assumetff()
merge(SeparateFields().SelectEven().eedi2(field=1),SeparateFields().SelectOdd().EEDI2(field=0),0.5)
turnleft()
assumetff()
merge(SeparateFields().SelectEven().eedi2(field=1),SeparateFields().SelectOdd().EEDI2(field=0),0.5)
turnright()
limitedsharpenfaster(ss_x=1.0,ss_y=1.0) .mt_lutxy(last,"x y < x 1 + x y > x 1 - x ? ?",U=2,V=2)
spline36resize(640,480)


http://img295.imageshack.us/img295/5246/someprocessingvd5.th.png (http://img295.imageshack.us/my.php?image=someprocessingvd5.png)


For sure there are (much) faster ways to make it look like this ... I'm not used to processing Anime, just threw some things together, step by step.
Also, this is just some spatial filtering, and temporal filtering is always indicated ... but that's a hard thing to do on just one single Jpeg. ;)

martino
19th November 2006, 19:30
Nice one! But I couldn't get it to work with AviSynth, I'm probably missing some filters...

Here's 2 minutes of the anime (cca 40MB) if anyone is interested and wants to have a play...
~link removed

martino
19th November 2006, 23:59
I did some experimenting, and I found some really nice settings that work pretty well;

Without MSharpen:
AVISource("F:\Guardian Hearts project\ep3_video_only_24fps_2min.avi")
fft3dfilter(sigma=4, plane=4)
DeGrainMedian(limitY=2,limitUV=3,mode=1)
DeGrainMedian(limitY=2,limitUV=3,mode=1)

With MSharpen:
AVISource("F:\Guardian Hearts project\ep3_video_only_24fps_2min.avi")
fft3dfilter(sigma=4, plane=4)
DeGrainMedian(limitY=2,limitUV=3,mode=1)
DeGrainMedian(limitY=2,limitUV=3,mode=1)
MSharpen(strength=50, highq=true)
strength=xx changed to 70

See pics (please ignore "msmooth" in filename, it's supposed to be msharpen):
http://i118.photobucket.com/albums/o117/martino2k6/GHPUTP/1500_msmooth70.png
http://i118.photobucket.com/albums/o117/martino2k6/GHPUTP/1500_msmooth50.png
http://i118.photobucket.com/albums/o117/martino2k6/GHPUTP/1500_out.png
http://i118.photobucket.com/albums/o117/martino2k6/GHPUTP/1500_source.png
http://i118.photobucket.com/albums/o117/martino2k6/GHPUTP/1350_msmooth70.png
http://i118.photobucket.com/albums/o117/martino2k6/GHPUTP/1350_msmooth50.png
http://i118.photobucket.com/albums/o117/martino2k6/GHPUTP/1350_out.png
http://i118.photobucket.com/albums/o117/martino2k6/GHPUTP/1350_source.png

Any suggestions as to what could be improved, and which MSharpen do you think is better.

Thanks!

Didée
20th November 2006, 09:16
Don't forget to make some tests how it looks after encoding ...
You're creating some nice over-sharpening with MSharpen there ... DCT-based encoders love that :D

martino
20th November 2006, 14:46
I ran an encode overnight with msharpen set at 70, and the video looked really good compared to the source even through some scenes would have benefited from a bit more sharpening but I'm afraid to do this since I might loose some really thin lines...

I also wanted to give hqdn3d a try, but I can't find a download link anywhere...


UPDATE:
How would I apply
fft3dfilter(sigma=4, plane=4)
DeGrainMedian(limitY=2,limitUV=3,mode=1)
DeGrainMedian(limitY=2,limitUV=3,mode=1)
MSharpen(strength=70, highq=true)
To
vid=AVISource("F:\Guardian Hearts project\ep3_video_only_24fps.avi")
vid1=trim(vid,0,554)
vid2=trim(vid,555,571).lanczos4resize(640,480,0,3.0,0,0)
vid3=trim(vid,572,11138)
vid4=trim(vid,11139,11582).lanczos4resize(640,480,0,3.0,0,0)
vid5=trim(vid,11583,11917)
vid6=trim(vid,11918,12912).lanczos4resize(640,480,0,3.0,0,0)
vid7=trim(vid,12913,13230)
vid8=trim(vid,13231,13872).lanczos4resize(640,480,0,3.0,0,0)
vid9=trim(vid,13873,14804)
vid10=trim(vid,14805,16773).lanczos4resize(640,480,0,3.0,0,0)
vid11=trim(vid,16774,17229)
vid12=trim(vid,17230,17411).lanczos4resize(640,480,0,1.0,0,0)
vid13=trim(vid,17412,18817)
vid14=trim(vid,18818,18936).lanczos4resize(640,480,0,3.0,0,0)
vid15=trim(vid,18937,19287)
vid16=trim(vid,19288,19568).lanczos4resize(640,480,0,3.0,0,0)
vid17=trim(vid,19569,21810)
vid18=trim(vid,21811,22462).lanczos4resize(640,480,0,4.0,0,0)
vid19=trim(vid,22463,22464)
vid20=trim(vid,22465,22535).lanczos4resize(640,480,0,4.0,0,0)
vid21=trim(vid,22536,22623)
vid22=trim(vid,22624,26435).lanczos4resize(640,480,0,4.0,0,0)
vid23=trim(vid,26436,26468).lanczos4resize(640,480,0,3.0,0,0)
vid24=trim(vid,26469,29133).lanczos4resize(640,480,0,4.0,0,0)
vid25=trim(vid,29134,29213).lanczos4resize(640,480,0,3.0,0,0)
vid26=trim(vid,29214,30902).lanczos4resize(640,480,0,4.0,0,0)
vid27=trim(vid,30903,30905)
vid28=trim(vid,30906,30926).lanczos4resize(640,480,0,4.0,0,0)
vid29=trim(vid,30927,30932).lanczos4resize(640,480,0,3.0,0,0)
vid30=trim(vid,30933,45191).lanczos4resize(640,480,0,4.0,0,0)
vid31=trim(vid,45192,47368)
vid32=trim(vid,47369,49755).lanczos4resize(640,480,0,4.0,0,0)
return vid1 ++ vid2 ++ vid3 ++ vid4 ++ vid5 ++ vid6 ++ vid7 ++ vid8 ++ vid9 ++ vid10 ++ vid11 ++ vid12 ++ vid13 ++ vid14 ++ vid15 ++ vid16 ++ vid17 ++ vid18 ++ vid19 ++ vid20 ++ vid21 ++ vid22 ++ vid23 ++ vid24 ++ vid25 ++ vid26 ++ vid27 ++ vid28 ++ vid29 ++ vid30 ++ vid31 ++ vid32
?

Thanks!

foxyshadis
21st November 2006, 01:28
Take out the return, and just add your filter set below the whole script. Tada! It'll take the entire joined-up video as the default input in that case.

martino
21st November 2006, 18:37
Thanks!

Would the script without the return work even if there was nothing after it?

foxyshadis
22nd November 2006, 02:48
Yup, there's always an implicit "Return last" as the end of the script. Last being the implicit current video, which is what everything gets assigned to (and read from) if another clip variable isn't explicitly stated.

martino
22nd November 2006, 19:34
Thanks! I also keep getting a green frame at the start of the video. When I use DirectShowSource this disappears, but then the video is out of sync with grey frames at some points. Using MPEG4Modifier didn't help either. How can I get rid of this frame?

foxyshadis
22nd November 2006, 20:28
Get mpeg4modifier, and resave the file with packed bitstream turned on. (The green frame is known as b-frame lag, packed bitstream is one kludge to work around it while keeping full audio sync.)

martino
22nd November 2006, 20:43
But I can't select "Pack". It's blanked out in grey...

Also, it seems like the output video is 2 frames behind the source...
Scene change in source video at frame 67 and on output video at 69...

More about this "green frame" issue: It happens every single time I try open an AVI file through an AviSynth script using the "AviSource()" tag. I have AVS 2.5.7 RC1 [160906] installed. If I use "DirectShowSource()" then the green frame disappears, but the output video is out of sync and grey frames appear.