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 5th May 2012, 21:24   #1  |  Link
EpheMeroN
EphMan
 
Join Date: May 2004
Posts: 737
Turning Video mid-way in script

I have a cell phone video of my daughter learning how to ride her bike for the first time. The first 1/3 or so of the video is recorder vertically, and then I turned the phone horizontally for a wider shot and proceeded to record the remainder of the video that way. In my script if I add "TurnLeft()" it corrects the video for that, but how can I keep the beginning video as is and adjust the video mid-way within 1 script?

So far I have this:

Code:
LoadPlugin("C:\Program Files\AviSynth\Plugins\ffms2.dll")
Import("C:\Program Files\AviSynth\Plugins\FFMS2.avsi")

FFmpegSource2("C:\Users\User1\Desktop\VIDEO0007.mp4",atrack=-1)

Trim(730,1543)

TurnLeft()
EpheMeroN is offline   Reply With Quote
Old 5th May 2012, 21:42   #2  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 263
Try this:

Code:
LoadPlugin("C:\Program Files\AviSynth\Plugins\ffms2.dll")
Import("C:\Program Files\AviSynth\Plugins\FFMS2.avsi")

FFmpegSource2("C:\Users\User1\Desktop\VIDEO0007.mp4",atrack=-1)

Trim(0,729) ++ Trim(730,1543).TurnLeft()

This outputs frames 0 to 729 unchanged, followed by frames 730 to 1543 rotated.

Ah, hang on though... You won't be able to join the clips directly like that, as they now have completely opposite aspect ratios. So, you somehow have to conform them to the same aspect ratio and *then* use the "++" to concatenate them.


Try:

Code:
LoadPlugin("C:\Program Files\AviSynth\Plugins\ffms2.dll")
Import("C:\Program Files\AviSynth\Plugins\FFMS2.avsi")

FFmpegSource2("C:\Users\User1\Desktop\VIDEO0007.mp4",atrack=-1)

# This assumes the source clip is wider than it is tall:
W = width()
H = height()
Border = BlankClip(Last,height = (W-H)/2)
StackVertical(Border,Last,Border)
# We should now have a square clip, where width and height are both equal to W

Trim(0,729) ++ Trim(730,1543).TurnLeft()

If the source clip is actually taller than it is wide, then just change:
Code:
Border = BlankClip(Last,height = (W-H)/2)
StackVertical(Border,Last,Border)
To:
Code:
Border = BlankClip(Last,width = (H-W)/2)
StackHorizontal(Border,Last,Border)

Last edited by pbristow; 5th May 2012 at 21:53.
pbristow is offline   Reply With Quote
Old 6th May 2012, 09:01   #3  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,433
Quote:
Originally Posted by pbristow View Post
Code:
...
Border = BlankClip(Last,height = (W-H)/2)
StackVertical(Border,Last,Border)
...
Alternatively,
Code:
...
B = (W-H)/2
AddBorders(0, B, 0, B)
...
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 8th May 2012, 04:13   #4  |  Link
EpheMeroN
EphMan
 
Join Date: May 2004
Posts: 737
@pbristow: I tried your script and VDub returns the following error open attempting to open the script:

EpheMeroN is offline   Reply With Quote
Old 8th May 2012, 09:11   #5  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,433
Quote:
Originally Posted by EpheMeroN View Post
@pbristow: I tried your script and VDub returns the following error open attempting to open the script
What are the dimensions of your source clip?
Did you follow this part of pbristow's post?
Quote:
Originally Posted by pbristow View Post
If the source clip is actually taller than it is wide, then just change:
Code:
Border = BlankClip(Last,height = (W-H)/2)
StackVertical(Border,Last,Border)
To:
Code:
Border = BlankClip(Last,width = (H-W)/2)
StackHorizontal(Border,Last,Border)
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 8th May 2012, 22:33   #6  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Looks like BlankClip() and friends need some id10t error protection for negative attributes. Oops!


And really the AddBorders method should be preferred here, it has no need for the static blank clip and the copy of it's pixels.

The Stack method would be appropriate if you wanted to fill the borders with some form of texture.

Last edited by IanB; 8th May 2012 at 23:07.
IanB is offline   Reply With Quote
Old 9th May 2012, 05:16   #7  |  Link
EpheMeroN
EphMan
 
Join Date: May 2004
Posts: 737
Quote:
Originally Posted by Gavino View Post
What are the dimensions of your source clip?
Did you follow this part of pbristow's post?
See below, and yes I followed that part of pbristow's post.




Also, I uploaded the MP4 video from my phone to SendSpace so you guys could help me out. The entire video is 20mb.

http://www.sendspace.com/file/3bo14x
EpheMeroN is offline   Reply With Quote
Old 9th May 2012, 06:58   #8  |  Link
ajk
Registered User
 
Join Date: Jan 2006
Location: Finland
Posts: 134
Code:
FFMpegSource2("VIDEO0007.mp4",atrack=-1)

AddBorders(160,0,160,0) # 160+480+160 = 800

Trim(0,729) ++ Trim(730,1543).TurnLeft()
160 because you need to add a total of 320 to pad the clip to square proportions, as already explained in the earlier posts.

Resulting video here www.sendspace.com/file/6n6yrp
ajk is offline   Reply With Quote
Old 13th May 2012, 16:05   #9  |  Link
EpheMeroN
EphMan
 
Join Date: May 2004
Posts: 737
Quote:
Originally Posted by ajk View Post
Code:
FFMpegSource2("VIDEO0007.mp4",atrack=-1)

AddBorders(160,0,160,0) # 160+480+160 = 800

Trim(0,729) ++ Trim(730,1543).TurnLeft()
160 because you need to add a total of 320 to pad the clip to square proportions, as already explained in the earlier posts.

Resulting video here www.sendspace.com/file/6n6yrp
That works for the first part of the video, but then when I turn the camera to film widescreen, I don't want the borders there. I want it to be full widescreen. Am I going to have to chop this clip into 2 separate clips to achieve this?
EpheMeroN is offline   Reply With Quote
Old 14th May 2012, 06:35   #10  |  Link
ajk
Registered User
 
Join Date: Jan 2006
Location: Finland
Posts: 134
@EpheMeroN

A video can only have one resolution. If you want the output resolution to match the second part of the video, you will need to scale the first part down by a lot (or crop a lot, which would leave very little of the original content). Try:

Code:
FFMpegSource2("VIDEO0007.mp4",atrack=-1)

# 480 / (800/480) = 288
# (800 - 288) / 2 = 256

Trim(0,729).BilinearResize(288,480).AddBorders(256,0,256,0) ++ Trim(730,1543).TurnLeft()
ajk is offline   Reply With Quote
Reply

Tags
angle, aspect, rotate, turn

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 06:45.


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