PDA

View Full Version : Unable to Get "ImageSource" to Work in Simple Script


rkr1958
13th August 2005, 17:12
I'm using 2.55 build:Sep 1 2004

Here is my script

a = ImageSource("G:\DVD_Wallets_DVD\Images\Walt_Disney_Wallet\%d.jpeg", 1, 24, 29.97) When I try to open this in VirtualDub I get the error that the script's return value is not a video clip. I've been working on trying to read these images since last night and done several searches here. I know I'm overlooking something very simple ... sorry for the rookie question ... thanks in advance.

sh0dan
13th August 2005, 17:48
Add "return a" to the end of the script, or simply delete "a ="

rkr1958
13th August 2005, 18:22
sh0dan,

Thanks. I put a "return a" at the end of the script and now I get a different error message,

'Could not open file' in DevIL.library

rkr1958
14th August 2005, 19:07
OK ... I'm now learning I've gotten the script below in the second quotes to work ... I'm so proud of myself ... I know it's very basic stuff for most of you here but I'm learning ... My question & I'll keep searching for the proper synatx ... I'd like to do
#
# Descriptive Text Only ... Not a Working Script
#
a = make_jpeg_clip("G:\DVD_Wallets_DVD\Images\Walt_Disney_Wallet\1.jpg",frame_rate,time)
for n = 2:24
b = make_jpeg_clip(["G:\DVD_Wallets_DVD\Images\Walt_Disney_Wallet\%d.jpg",n],frame_rate,time)
a = a + b
end
return a


#
# Main Program ==> Working Script
#
frame_rate = 29.97
time = 4
#
# Read Jpeg #1
#
a = make_jpeg_clip("G:\DVD_Wallets_DVD\Images\Walt_Disney_Wallet\1.jpg",frame_rate,time)
b = make_jpeg_clip("G:\DVD_Wallets_DVD\Images\Walt_Disney_Wallet\2.jpg",frame_rate,time)
a = a + b

return a

#
# function make_jpeg_clip
#
function make_jpeg_clip(image_name,frame_rate,time)
{
# This function reads in an image == image_name and makes it a clip of length == time & frame rate == frame_rate
frames = round(frame_rate * time)
clip = imagesource(image_name).trim(0,-1).loop(frames).assumefps(frame_rate)
w = width(clip)
w1 = int((720-w)/2)
w2 = 720 - w - w1
h = height(clip)
h1 = int((480-h)/2)
h2 = 480 - h - h1
clip = addBorders(clip,w1,h1,w2,h2)
return clip
}

stickboy
14th August 2005, 21:59
I think your non-working script is closer to correct.
ImageSource("G:\DVD_Wallets_DVD\Images\Walt_Disney_Wallet\%d.jpg", 1, 24, framerate)

rkr1958
15th August 2005, 00:34
Got this working ... My Final Script ... I'm quite pleased with myself

#
# DVD Wallet Collection Slideshow
#
figure_path = "G:\DVD_Wallets_DVD\Images\"
clip = dvd_wallet_slideshow(29.97,4,figure_path+"Walt_Disney_Wallet\",".jpg",22,2,"Walt Disney","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"Children_1\",".jpg",20,0,"Children #1","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"Children_2\",".jpg",25,0,"Children #2","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"Children_3\",".jpg",10,14,"Children #3","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"Christmas_Holiday\",".jpg",13,13,"Christmas & Holiday","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"US_Girls_1\",".jpg",22,0,"US & Girls #1","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"US_Girls_2\",".jpg",22,0,"US & Girls #2","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"US_Girls_3\",".jpg",10,13,"US & Girls #3","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"Guys_1\",".jpg",17,0,"Guy Movies #1","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"Guys_2\",".jpg",20,0,"Guy Movies #2","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"Guys_3\",".jpg",4,15,"Guy Movies #3","DVD Collection")
clip = clip + dvd_wallet_slideshow(29.97,4,figure_path+"Sci_Fi_Fantsy_1\",".jpg",11,4,"Sci Fi & Fantasy #1","DVD Collection")
return clip
#
# function dvd_wallet_slideshow(frame_rate,time,figure_path,figure_ext,number_of_clips,number_of_slots,text_top,text_bottom)
#
function dvd_wallet_slideshow(frame_rate,time,figure_path,figure_ext,number_of_clips,number_of_slots,text_top,text_bottom)
{
clip = make_blank_clip(frame_rate,1,text_top,text_bottom)
clip = make_slideshow(clip,figure_path,figure_ext,1,number_of_clips,frame_rate,time,text_top,text_bottom)
clip = make_empty_slot_clip(clip, 1, number_of_slots, frame_rate, 1., text_top, text_bottom)
return clip
}
#
#
# function make_empty_slot_clip
#
function make_empty_slot_clip(clip, slot_number, number_of_slots, frame_rate, time, text_top, text_bottom)
{
return (slot_number > number_of_slots) ? clip : \
make_empty_slot_clip(clip + make_dvd_slot(frame_rate,ceil(frame_rate*time),text_top ,text_bottom,slot_number), \
slot_number + 1, number_of_slots, frame_rate, time, text_top, text_bottom)
}
#
# function make_dvd_slot
#
function make_dvd_slot(frame_rate,frames,text_top,text_bottom,slot_number)
{
clip = blankclip(length=frames, width=720, height=480, fps=frame_rate, color=$000000, audio_rate=0).converttoYUY2()
clip = subtitle(clip, "Available DVD", text_color=$ffff00, x=-1, y=200, size=76)
clip = subtitle(clip, "Slot # "+string(slot_number), text_color=$ffff00, x=-1, y=300, size=76)
clip = subtitle(clip, text_top, text_color=$ffffff, align=7, x=4, y=16, size=18)
clip = subtitle(clip, text_bottom, text_color=$ffffff, align=7, x=4, y=32, size=18)
return clip
}
#
# function make_blank_clip
#
function make_blank_clip(frame_rate,frames,text_top,text_bottom)
{
clip = blankclip(length=frames, width=720, height=480, fps=frame_rate, color=$000000, audio_rate=0).converttoYUY2()
clip = subtitle(clip, text_top, text_color=color_limegreen, x=-1, y=200, size=76)
clip = subtitle(clip, text_bottom, text_color=color_limegreen, x=-1, y=300, size=76)
return clip
}
#
# function make_slideshow
#
function make_slideshow(clip,figure_path,figure_ext,clip_number,number_of_clips,frame_rate,time,text_top,text_bottom)
{
return (clip_number > number_of_clips) ? clip : \
make_slideshow(clip + make_image_clip(figure_path+string(clip_number)+figure_ext,frame_rate,time,text_top,text_bottom), \
figure_path,figure_ext,clip_number+1,number_of_clips,frame_rate,time,text_top,text_bottom)
}
#
# function make_image_clip
#
function make_image_clip(image_name,frame_rate,time,text_top,text_bottom)
{
# This function reads in an image == image_name and makes it a clip of length == time & frame rate == frame_rate
frames = ceil(frame_rate * time)
clip = imagesource(image_name).trim(0,-1).loop(frames).assumefps(frame_rate)
w = width(clip)
h = height(clip)
scale_factor = 448. / h
w = round(w * scale_factor)

h = round(h * scale_factor)
clip = clip.bilinearresize(w,h)
w1 = int((720-w)/2)
w2 = 720 - w - w1
h1 = int((480-h)/2)
h2 = 480 - h - h1
clip = addBorders(clip,w1,h1,w2,h2).converttoYUY2()
clip = subtitle(clip, text_top, text_color=$ffffff, align=7, x=4, y=16, size=18)
clip = subtitle(clip, text_bottom, text_color=$ffffff, align=7, x=4, y=32, size=18)
return clip
}