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. |
21st November 2020, 19:32 | #1 | Link |
Registered User
Join Date: Sep 2016
Location: Rome, Italy
Posts: 18
|
Help with generating video from cropped images
Hello,
Probably stupid question, I try to explain what I'm trying to do (my english is quite bad, sorry) I have a folder with multiple images. I want to cut/split/crop them in 3 parts and then joining what I get to generate a video. For example let's say I have "picture1" and "picture2" in the folder (same height and width)... I want to generate a video from "top_picture1", "middle_picture1", "bottom_picture1", "top_picture2", "middle_picture2", "bottom_picture2". I looked in the forum and imitating other scripts (basically from Stainless, i think) I came to the point that i wrote a function which work for a single picture but I'm not able to make it work recursevely. The function is this, Code:
function croppaunisci(clip immagine) { larghezza=Width(immagine) #width altezza=Height(immagine) #height croppato=altezza/3 #height/3 sopra1=crop(immagine,0,0,0,croppato) #top of the picture centro2=crop(immagine,0,croppato,0,croppato) # middle of the picture sotto3=crop(immagine,0,croppato*2,0,croppato) # bottom of the picture sopra1++centro2++sotto3 # join the parts } Code:
IN_FILES = "C:\pathwithimages\*.jpg" # Added '|' Pipe separator for multiple Wildcard in Extensions ONLY. OUT_FILE = "FILE.List" # Dont need to change really, just a name. result=RT_WriteFileList(IN_FILES,OUT_FILE) # Create a listing file of Pic files Assert((result!=0), "No files found") FILELIST=RT_ReadTxtFromFile(OUT_FILE) # Get list of files FILES=RT_TxtQueryLines(FILELIST) # Query Number of lines in String ie number of files. For(i=0,FILES-1) { FN=RT_TxtGetLine(FILELIST,i) # Filename immagine=Imagesource(FN,end=0,fps=25) a=croppaunisci(immagine) return a + a } The part "return a+a" is obviously non-sense, i know, but how should i correct it? Using avisynth+ 3.61, windows 7 32 bit. Thx for the attention! Last edited by dark76; 21st November 2020 at 21:18. Reason: typo |
22nd November 2020, 10:46 | #5 | Link | |
Registered User
Join Date: Sep 2016
Location: Rome, Italy
Posts: 18
|
Quote:
Thx for attention, now i will try to understand if your advices can fix my script |
|
22nd November 2020, 12:08 | #6 | Link |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,496
|
As long as the images are numbered sensibly you can use ImageSource to load a folder's worth of images as one clip, and then interleave the three clips.
|
22nd November 2020, 12:17 | #7 | Link |
Registered User
Join Date: Sep 2016
Location: Rome, Italy
Posts: 18
|
Maybe i found a solution. I didn't change the function and i modified like this
Code:
IN_FILES = "C:\pathwithimages\*.*" # Added '|' Pipe separator for multiple Wildcard in Extensions ONLY. OUT_FILE = "FILE.List" # Dont need to change really, just a name. result=RT_WriteFileList(IN_FILES,OUT_FILE) # Create a listing file of Pic files Assert((result!=0), "No files found") FILELIST=RT_ReadTxtFromFile(OUT_FILE) # Get list of files FILES=RT_TxtQueryLines(FILELIST) # Query Number of lines in String ie number of files. tot=0 For(i=0,FILES-1) { FN=RT_TxtGetLine(FILELIST,i) # Filename immagine=Imagesource(FN,end=0,fps=25) v=croppaunisci(immagine) tot = (tot.IsClip) ? tot ++ v : v # If tot is a clip, then add splice v else replace with v } return tot EDIT: "Final version" using first image as model for resizing the others. Code:
IN_FILES = "c:\pathwithimages\*.*" # Added '|' Pipe separator for multiple Wildcard in Extensions ONLY. OUT_FILE = "FILE.List" # Dont need to change really, just a name. result=RT_WriteFileList(IN_FILES,OUT_FILE) # Create a listing file of Pic files Assert((result!=0), "No files found") FILELIST=RT_ReadTxtFromFile(OUT_FILE) # Get list of files FILES=RT_TxtQueryLines(FILELIST) # Query Number of lines in String ie number of files. primo=RT_TxtGetLine(FILELIST,0) primo_larghezza=Width(Imagesource(primo)) #width primo_altezza=Height (Imagesource(primo))#height pr_lar_mod4 = primo_larghezza - (primo_larghezza % 4) # Round Down pr_alt_mod6 = primo_altezza - (primo_altezza % 6) # Round Down tot=0 For(i=0,FILES-1) { FN=RT_TxtGetLine(FILELIST,i) # Filename immagine=Imagesource(FN,end=500,fps=25).BlackmanResize(pr_lar_mod4,pr_alt_mod6) v=croppaunisci(immagine) tot = (tot.IsClip) ? tot ++ v : v # If tot is a clip, then add splice v else replace with v } return tot ConvertBits(8) ConvertToYV12() Last edited by dark76; 22nd November 2020 at 15:35. |
22nd November 2020, 17:36 | #8 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Combination of previous posts suggestions.
First My Demo creating whotsit, Code:
# PIC folder MUST exist in current directory W=64 H=64 S=64 T=$808080 DIGITS=6 TYPE="JPG" ### A=BlankClip(Length=1,Width=W,Height=H*3,Color=$FF0000) B=A.BlankClip(Color=$00FF00) C=A.BlankClip(Color=$0000FF) A=A.Subtitle("1",y=0*H,Text_Color=T,Size=S).Subtitle("2",y=1*H,Text_Color=T,Size=S).Subtitle("3",y=2*H,Text_Color=T,Size=S) B=B.Subtitle("1",y=0*H,Text_Color=T,Size=S).Subtitle("2",y=1*H,Text_Color=T,Size=S).Subtitle("3",y=2*H,Text_Color=T,Size=S) C=C.Subtitle("1",y=0*H,Text_Color=T,Size=S).Subtitle("2",y=1*H,Text_Color=T,Size=S).Subtitle("3",y=2*H,Text_Color=T,Size=S) A++B++C NAME=".\PIC\slide_%0"+String(DIGITS,"%.0f")+"d"+"."+TYPE #RT_DebugF("NAME='%s",NAME,name="SomeInfo: ") ImageWriter(NAME, start=0,end=2,type=TYPE) Return last Creates in PIC dir slide_000000.JPG # Red slide_000001.JPG # Grn slide_000002.JPG # Blu eg 1st one slide_000000.JPG # Red Script for your use Code:
PATH = ".\PIC\Slide_" # PIC directory relative to current dir, base filename node "Slide_" TYPE = "jpg" DIGITS = 6 ### FIRST WANT FIND NUMBER OF IMAGE FILES FOR ImageReader(END) IN_FILES = PATH + "*." + TYPE # ".\PIC\Slide_*.jpg" OUT_FILE = ".\FILE.List" # TMP file FILES = RT_WriteFileList(IN_FILES,OUT_FILE) # Create a listing file of Pic files Assert((FILES!=0), "No files found") RT_FileDelete(OUT_FILE) # We Are done with it #RT_DebugF("IN_FILES='%s'\nFILES COUNT=%d",IN_FILES,FILES,name="SomeInfo: ") IR_FILE = RT_String("%s%%0%dd.%s",PATH,DIGITS,TYPE) # ".\PIC\Slide_%06d.jpg" # NOTE, "%%" required for Literal '%' in format str ImageReader(IR_FILE, end=FILES-1) #RT_DebugF("READER_FILE='%s",IR_FILE,name="MoreInfo: ") H=Height/3 T = CROP(0,0,0,H) M = CROP(0,H,0,H) B = CROP(0,2*H,0,0) Interleave(T,M,B) Return last (If dont start at 0 will require script fix for Start and End) EDIT: If you add this before Return from 2nd Script will produce this, with all frames stacked and shown as single image, where original frames as R, or G, or B, and 1=Top, 2=Mid, 3=Bot. Code:
C=0 For(i=0,8) { Z = Last.Trim(i,-1) C=(C.IsClip) ? StackHorizontal(C,Z) : Z } C
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 22nd November 2020 at 17:55. |
22nd November 2020, 20:27 | #9 | Link |
Registered User
Join Date: Sep 2016
Location: Rome, Italy
Posts: 18
|
Thx also to you Stainless I will try your script next days. The one i posted little above is quite slow on my old pc (3.81 fps processing images sized around 1800x2400) and i'm curious to see if using the interleave will be little faster I will let you know next days.
|
|
|