Log in

View Full Version : Turning Video mid-way in script


EpheMeroN
5th May 2012, 21:24
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:

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()

pbristow
5th May 2012, 21:42
Try this:


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:


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:

Border = BlankClip(Last,height = (W-H)/2)
StackVertical(Border,Last,Border)

To:

Border = BlankClip(Last,width = (H-W)/2)
StackHorizontal(Border,Last,Border)

Gavino
6th May 2012, 09:01
...
Border = BlankClip(Last,height = (W-H)/2)
StackVertical(Border,Last,Border)
...
Alternatively,
...
B = (W-H)/2
AddBorders(0, B, 0, B)
...

EpheMeroN
8th May 2012, 04:13
@pbristow: I tried your script and VDub returns the following error open attempting to open the script:

http://i45.tinypic.com/2wp0589.jpg

Gavino
8th May 2012, 09:11
@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?
If the source clip is actually taller than it is wide, then just change:

Border = BlankClip(Last,height = (W-H)/2)
StackVertical(Border,Last,Border)

To:

Border = BlankClip(Last,width = (H-W)/2)
StackHorizontal(Border,Last,Border)

IanB
8th May 2012, 22:33
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.

EpheMeroN
9th May 2012, 05:16
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.

http://i49.tinypic.com/6f9jc8.jpg


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

ajk
9th May 2012, 06:58
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 (http://www.sendspace.com/file/6n6yrp)

EpheMeroN
13th May 2012, 16:05
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 (http://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?

ajk
14th May 2012, 06:35
@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:

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()