Created
April 26, 2014 17:48
-
-
Save on-three/11326444 to your computer and use it in GitHub Desktop.
AVI synth montage script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is the avisynth script ("montage.avs"): | |
--- | |
Setmemorymax(512) | |
SetMTMode(2,4) | |
grid=24 | |
a1=directshowsource("input1.webm",audio=false).converttorgb | |
l=ceil(float(a1.framecount)/(grid*grid)) | |
function HRepeat(clip c, int g, int l, int x, int y) { | |
x == g-1 ? c.trim(l*(g-1+g*y),-l) : StackHorizontal(c.trim(l*(x+g*y),-l), HRepeat(c, g, l, x+1, y)) | |
} | |
function VHRepeat(clip c, int g, int l, int x, int y) { | |
HR = StackHorizontal((x==0 && y==0)? blankclip(c.trim(0,-l)):c.trim(l*(g-1+g*(y-1)),-l), HRepeat(c, g, l, x, y)) | |
y == g-1 ? HR : StackVertical(HR, VHRepeat(c, g, l, x, y+1)) | |
} | |
VHRepeat(a1,grid,l,0,0) | |
animate(0, l, "crop", a1.width, 0, a1.width*grid, a1.height*grid, 0, 0, a1.width*grid, a1.height*grid) | |
converttoyv12 | |
--- | |
To do a static version just replace the HR = StackHorizontal(...) line with: | |
HR = HRepeat(c, g, l, x, y) | |
and also delete the animate line. | |
And this is the batch script: | |
--- | |
@echo off | |
ffmpeg -v verbose -i "%~1" -threads 4 -c:v libvpx -crf 4 -b:v 3000K -vf scale=80:36 -an input1.webm | |
ffmpeg -v verbose -i "montage.avs" -threads 4 -c:v libvpx -crf 4 -b:v 2360K -vf scale=1280:576 -an output1.webm -y | |
--- | |
I found re-encoding first to a small size worked better than just resizing in the script, but YMMV. You might need to adjust the scaling if the resized video would have odd-numbered height (as I've done there - using scale=80:-1 would result in a height of 35 and crash avisynth). Normally I just use scale=160:-1 (and 640:-1 for the final size) for making the smaller (12x12) grids. | |
Bit-rate calculation is (3*8*1024^2*grid^2/(length of original in seconds))* (fudge factor ~0.975) | |
Once you've edited the bat file, just drag and drop the target video onto it to start. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment