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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th September 2015, 00:22   #1  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 289
Automatic Moving Crop (4:3 -> 16:9)

Hi everyone,
I have to deal with an old 4:3 DVD and I would like to crop it into 16:9 (please, don't kill me for this) and restore it.

The source is interlaced and with a lot of crap such as raimbow/dot crawl, a lot of static grain and other stuff, but I can get rid of everything.

Anyway, I'm here just to ask you about this crop because I remember that, time ago, when we used to watch things on our 4:3 TVs, sometimes the pan & scan function was used in order to do a moving cropping.

Silly example:

Amorphic source


16:9


4:3 with PAN & SCAN


So, I was looking for a filter that is able to perform a PAN & SCAN automatically; "Animate" is a good one, but I have to specify the starting and ending frames.
Is there a way to make this process automatic?
If not, is there an editing software to use as replacement to avisynth? (so I can create a lossless with that software and then filter everything with avisynth and x264).

Thank you ^_^

Last edited by FranceBB; 6th September 2015 at 00:25.
FranceBB is offline   Reply With Quote
Old 6th September 2015, 00:48   #2  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
KenBurnsEffect
http://forum.doom9.org/showthread.php?t=135776
raffriff42 is offline   Reply With Quote
Old 6th September 2015, 01:03   #3  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Posts: 2,163
Hi FranceBB,

do I understand you right: You want to convert a 4:3 source to 16:9 without pillar boxes (black borders left and right)? And you know that you will crop off information from the top and the bottom of your source?

If so then it is much simpler than using the Ken Burns Effect. Here is an old AviSynth script which I used a lot in the good old 4:3 days:

4-3to16-9.avs
Code:
# Requires stickboy's jdl-util.avsi and jdl-interlace.avsi
# Encoder Aspect Ratio must be set to 16:9 Anamorphic

# Interlaced = true
DestinationIsPAL = (DestinationHeight % 288 == 0) || (DestinationHeight % 216 == 0)
DestinationIsPAL ? Crop(0,72,-0,-72) : Crop(0,60,-0,-60)
Interlaced==true ? (DestinationIsPAL ? JDL_InterlacedResize(DestinationWidth,576,"Spline36Resize") : JDL_InterlacedResize(DestinationWidth,480,"Spline36Resize")) : (DestinationIsPAL ? Spline36Resize(DestinationWidth,576) : Spline36Resize(DestinationWidth,480))
For interlaced sources it requires Stickboy's interlaced tools. It will handle PAL and NTSC, and remember that the encoder must be set to 16:9 anamorphic. And of course the crop and resize values are for DVD only...


Cheers
manolito

Last edited by manolito; 6th September 2015 at 01:10.
manolito is offline   Reply With Quote
Old 6th September 2015, 02:17   #4  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 289
@manolito... yep, I want to crop, but "moving" the "camera" (the crop) in order to avoid cutting important information.

@raffriff42... I'll try KenBurnsEffect tomorrow. Thank you.
FranceBB is offline   Reply With Quote
Old 6th September 2015, 02:22   #5  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
I can't say I completely understand KenBurnsEffect, as I've only used it for the odd zoom. It's very powerful. But to be honest, your task would be a lot easier in Premiere or Vegas.
raffriff42 is offline   Reply With Quote
Old 6th September 2015, 02:42   #6  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Posts: 2,163
Quote:
Originally Posted by FranceBB View Post
@manolito... yep, I want to crop, but "moving" the "camera" (the crop) in order to avoid cutting important information
Alright, but there is no way to automate this task. How can a software tool know where the important information is located?

I remember when the 16:9 format was already established, but most content was still broadcast at 4:3. At that time the 4:3 productions made sure that they were 16:9 safe. Which meant that no important information was in the top or bottom area which would eventually be matted or cropped.


Cheers
manolito
manolito is offline   Reply With Quote
Old 6th September 2015, 10:40   #7  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 289
@manolito... I thought there was some built-in facial recognition or something like that. Anyway, some scenes of the DVD are in 16:9, which means that there are black borders up and down.
Another problem is made by the credits that are made at the very top or at the very bottom, so I need a precise crop etc.
It would be helpful if the software is able to recognize at least the black borders and the credits in order to avoid cutting stuff like the title etc.
As to the rest, I can set the crop values myself, it's not really a big deal since there shouldn't be a lot of "dangerous" scenes ^_^
FranceBB is offline   Reply With Quote
Old 7th September 2015, 10:40   #8  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,145
Quote:
Originally Posted by FranceBB View Post
I thought there was some built-in facial recognition or something like that.
When the silly pan-and-scan versions of films are created, the scanner requires very heavy human intervention. There is no automatic way to do what you want.

https://en.wikipedia.org/wiki/Pan_and_scan
manono is offline   Reply With Quote
Old 7th September 2015, 12:33   #9  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 3,595
I've panned and scanned 4:3 to 16:9 a few times, and to do it properly it can be a lot of work, especially using Avisynth.
If you crop a little less from the top than the bottom you might get lucky and it'll be acceptable (often the focus tends to be mostly centred a little above the middle of the frame), but if you really want to do it properly, there'll probably be a lot of adjusting.

I usually crop to 16:9 dimensions and resize to square pixels. Occasionally, there might be a single shot where the focus starts at the top of the frame and finishes at the bottom etc, in which case you might need to find a way to zoom or pan down, but for live action stuff I found 99% of the time changing the cropping on a scene change is usually all that's needed to keep the important stuff in the 16:9 frame. Like this (that particular script was concert footage where almost every scene change needed a cropping adjustment, so it was time consuming):

trim(0, 3367).crop(16, 2, -16, -10).Spline36Resize(576,432).AddBorders(96, 0, 96, 0)\
++ trim(3368, 3487).crop(12, 74, -12, -74).Spline36Resize(768,432)\
++ trim(3488, 3973).crop(12, 104, -12, -44).Spline36Resize(768,432)\
++ trim(3974, 4223).crop(12, 14, -12, -134).Spline36Resize(768,432)\
++ trim(4224, 4353).crop(12, 104, -12, -44).Spline36Resize(768,432)\

The 4:3 videos I've panned and scanned so far had distinct opening and closing sequences containing the credits, but they couldn't be cropped without cropping the text, so rather than stretch to 16:9, I left the credits as 4:3 and added pillarboxing (as per the above example). A sudden switch to 16:9 when the episode starts adds a bit of effect.

There might be an easier way to add the panning and scanning to scripts (I just kept copying and pasting and changing the frame numbers and cropping as I went), but I can't imagine there'd be a substitute for doing it manually. One downside might be due to the video qiality. 4:3 DVD isn't always that great, and by cropping so it'll fill a 16:9 screen you're effectively zooming in, so it might look like the quality has dropped.

Last edited by hello_hello; 7th September 2015 at 12:36.
hello_hello is offline   Reply With Quote
Old 7th September 2015, 23:03   #10  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
It's always gonna be complicated trying to do this in Avisynth; usually it's better to use some good editing software. But sometimes it isn't better, so here is a demo of animated "pan & scan."


centered


pan left


pan right

Code:
#Last==assumed > 4:3 aspect ratio

## optional: show original frame numbers
ShowFrameNumber(x=Width/2, y=Height/2, scroll=false)  

PLT   = -1.0  ## pan full left
PRT   =  1.0  ## pan full right
CTR   =  0.0  ## center

## cropping to 4:3
hgt   =  Height
wid   =  Round(Float(hgt) * 4.0 / 3.0)
wid   =  wid - (wid % 2)

info  =  true ## set to true to show debugging info
curfrm = 0 

## start center, pan left
R = Trim(0, 329).Animate(
\           300,  [* first frame for motion *]
\           329,  [* last frame for motion *]
\           "PanScan", 
\           CTR, wid, hgt, info, [* pan <= first frame *]
\           PLT, wid, hgt, info) [* pan  > last frame *]
\ .clip_id("clip A", info)
curfrm = curfrm+330

## start left, pan right
R = R++Trim(curfrm, -120).Animate(
\           60,  [* first frame for motion *]
\           120, [* last frame for motion *]
\           "PanScan", 
\           PLT, wid, hgt, info,  [* pan <= first frame *]
\           PRT, wid, hgt, info)  [* pan  > last frame *]
\ .clip_id("clip B", info)
curfrm = curfrm+120

## start right, pan center
R = R++Trim(curfrm, -240).Animate(
\           60,  [* first frame for motion *]
\           90,  [* last frame for motion *]
\           "PanScan", 
\           PRT, wid, hgt, info, [* pan <= first frame *]
\           CTR, wid, hgt, info) [* pan  > last frame *]
\ .clip_id("clip C", info)
curfrm = curfrm+240

## cut to pan left
R = R++Trim(curfrm, -120)
\ .PanScan(PLT, wid, hgt, info)
\ .clip_id("clip D", info)
curfrm = curfrm+120

## cut to pan 3/4 right
R = R++Trim(curfrm, -60)
\ .PanScan(PRT*0.75, wid, hgt, info)
\ .clip_id("clip E", info)
curfrm = curfrm+60

## cut to pan center
R = R++Trim(curfrm, 0)
\ .PanScan(CTR, wid, hgt, info)
\ .clip_id("clip F", info)

return R

###############################
function clip_id(clip C, string s, bool info)
{
    return (info) 
    \ ? C.Subtitle(s, align=7, size=C.Height/24)
    \ : C 
}

###############################
function PanScan(clip C, float pan, int wid, int hgt, bool info)
{
    C = C.UUCrop2(wid, hgt, pan, 0.0)

    return (info) 
    \ ? C.Subtitle(
    \       "pan="+String(pan, "%0.2f"), 
    \       x=C.Width/2, y=0, size=C.Height/24)
    \ : C 
}

##################################
### crop to size with smooth animated pan & tilt
##
## @ pan   -1=left, 0=center, +1=right; [default 0]
## @ tilt  -1=up,   0=center, +1=down;  [default 0]
##
function UUCrop2(clip C, int wid, int hgt, float "pan", float "tilt")
{
    bdrWid = (wid - C.Width)
    bdrHgt = (hgt - C.Height)

    xctr  = Min(Max(-1.0, Default(pan, 0.0)), 1.0)
    yctr  = Min(Max(-1.0, Default(tilt, 0.0)), 1.0)

    bdrLt = Abs(Float(bdrWid) / 2.0)
    bdrLt = bdrLt + bdrLt * xctr
    bdrLt = Sign(bdrWid) * bdrLt
    
    bdrTp = Abs(Float(bdrHgt) / 2.0) 
    bdrTp = bdrTp + bdrTp * yctr
    bdrTp = Sign(bdrHgt) * bdrTp
    
    (bdrLt<=0 && bdrTp<=0) ? Nop
    \ : Assert(false, "UUCrop2: clip too small for target size")

    return C.Spline36Resize(wid, hgt, -bdrLt, -bdrTp, wid, hgt)
}

Last edited by raffriff42; 17th March 2017 at 00:07. Reason: (fixed image links)
raffriff42 is offline   Reply With Quote
Old 10th September 2015, 06:38   #11  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 289
Thank you all guys, really.
I'm actually doing it in two different ways: the proper one first and a light cut plus panorama tool as the second one.

I'm going to compare 'em this afternoon and I'll decide how I will proceed.
Thank you everyone, really. ^_^
FranceBB is offline   Reply With Quote
Old 14th September 2015, 04:23   #12  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,860
I did the inverse and used some tools to find the pan box relative to the 2.35:1 version of the film. It moved around a lot. It's really a director's choice, with some thought on artistic decisions. If there's two talking heads, do you show one, both but parts of faces, mostly one, or quick cut between them?
jmac698 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:19.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.