- image sequence to video - Creative Uses of CHDK - CHDK Forum supplierdeeply

- image sequence to video

  • 25 Replies

Offline yair

  • *
  • 34
  • A620, A640, A530
- image sequence to video
« on: 17 / June / 2009, 04:56:55 »
so, you made a timelapse image sequence.
now what.
there are several ways to make your image sequence to a video. it depends on your operating system (not your budget). i'll be focusing on windows as this is my OS.

we will be using avisynth which is imagemagick for video, an amazingly capable open sourced scripting platform for video frame serving.

1. download avisynth (get the 2.5.8 version)
2. download the imagesequence filter from the filter page
  • 2a. extract the imagesequance plugin to the avisynth\plugin directory (plugin and filters have the same meaning)

3. on installation aviSynth will add an option to add itself to the rightClick>new context menu. so do it. or open a txt file and change its extension to avs.

4. open your newly created foo.avs script in notepad

5. copy and paste this code
Code: [Select]
CoronaSequence("E:\adva\new1\2009\06\04\*.jpg", sort=2,textmode=1)
  • CoronaSequence - is the name of the imageSequence filter, have no idea why
  • "E:\adva\new1\2009\06\04\*.jpg" - folder containing the seqaunce, note the *  
  • sort=2 - sort the files by filename
  • textmode=1 - print the filename, i use timelapse for research so this helps (i use wia-loader to make the filename the date picture was taken + enumeration
see the previously downloaded  C:\Program Files\AviSynth 2.5\plugins\ImageSequence.htm for indepth info on options

6. drag and drop this file into your media player, VLC, media player classic, virtualdub or even windows media player, your  timelapse will play.

7. now we can get creative, lets add the following line to the script

Code: [Select]
Crop(10, 10, 1590, 1190).BilinearResize(800, 600)i hope you get the syntx, we just cropped our source by 10 pixels and resized it to 800x600. more here

8. the complete script, with more grammar
Code: [Select]
#this is a comment
clip1=CoronaSequence("E:\adva\new1\2009\06\04\*.jpg", sort=2,textmode=1)
clip2=CoronaSequence("E:\adva\new1\2009\06\05\*.jpg", sort=2,textmode=1)
vid=clip1+clip2 #this is how we append files
vid.Crop(10, 10, 1590, 1190).BilinearResize(800, 600) #crop and resize, note the dots

i usually end it here, you get a fake video, if you want the real thing, continue at your own risk.

9. now we need to "bake" it into video.  i use meGui for this stage which transcodes the script to H264. its a fornt-end for tons of opensource projects that will hopefully allow you to transcode.
  • download meGUI from sourceforge
    install and let it update itself.
  • open and drag your script to the input bar
  • click the autoEncode button at bottom right, we'll use the default encoding prifile (x264 *scratchpad*)
  • file will be added to Queue and after a couple of minutes we we'll get a good video for youtube
next time you can check the log of meGUI for the commandline parameters and use it in a batch file
Code: [Select]
"C:\Program Files\megui\tools\x264\x264.exe" --bitrate 1200 --partitions p8x8,b8x8,i4x4 --threads auto --thread-input --sar 1:1 --progress --no-psnr --no-ssim --output "imageSource.mp4" "imageSource.avs" i would appreciate input on this stage as i am not 10% happy about my workflow in this regard.

there are good tutorials on aviSynth usage on the net.

note0-note- make sure your images are in the same folder and have correct number enumeration, if you need a good photo downloader i recommend WIA-loader, which has many options and should get a HOWTO of its own (but the docs are fine).
note1 - there is an internal filter for reading images but it complains about jpeg so i use this external filter.
note2-  i'm no aviSynth expert you can find those at doom9 a great community for video junkies. the development forum is also hosted there.

see Alex Pliov blog post on using mencoder for doing this, more details here.
this method is cross platform but i like aviSynth

you can use quicklime (PRO) for doing this, very easy, but $.
file>image sequence
file > export for web
« Last Edit: 17 / June / 2009, 05:40:39 by yair »


Offline barret

  • ***
  • 125
  • S3 & a550
Re: - image sequence to video
« Reply #1 on: 17 / June / 2009, 05:09:50 »
you can also use virtualdub under windows to make a movie from image sequence - just 3 simple steps:
1. open first image of sequence (file > open video file)
2. choose one of available codecs to compress your video (video > compression, default is uncompressed, so output file might be huge!)
3. save as avi (file > save as avi)

this method might be more easy for beginning user, since it does not involve any command line parameters, or scripting.apart from that, you can also do lots of other nice things like rotate your video (when your image sequence is rotated), change fps, add sound, effects, and so on.

also, when you have a lot of images, canon cameras split them in directories every 2000 images. copying them to the computer might take some time, so it is more time effective to work on them directly on card. you can make a video for each directory, and then easly connect every segment of movie, without the need to recompress. to do this first you need to make avis out of each directory (you can put those jobs into queue, and launch it later), and after it:
1. open first movie (file > open video file)
2. append other avi segments (file > append avi segment, also tick 'autodetect additional segments by filename' option)

this way, you can easily append lots of avi segments together, as long as their names are sequential (for example mov1, mov2, etc.).
« Last Edit: 17 / June / 2009, 05:19:11 by barret »


Offline yair

  • *
  • 34
  • A620, A640, A530
Re: - image sequence to video
« Reply #2 on: 17 / June / 2009, 05:12:37 »
defiantly, completely forgot about virtualdub in that regard. please ignore this thread :)

but seriously, using the method i suggest you dont need to create intermediate huge video files (getting a good compression from virtualDub is complex, u usualy have to compress twice. inside Vdub (uncompressed or fastCodec or hwatever) and again outside, no?).

your fine suggestion about appending files straight from the camera is also valid to aviSynth.

« Last Edit: 17 / June / 2009, 05:35:39 by yair »


Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: - image sequence to video
« Reply #3 on: 17 / June / 2009, 06:53:39 »
in my last project i batch-renamed the 26.000 images so they would be named like sequence_#####.jpg (and moved them into ONE folder).
i then used virtual dub to create a movie. by using the filters/plugins you can easily resize, add logos and other effects (btw a lot of these things already are included in the download). usually i have a specific length of the movie in mind, be it for example because i have a certain song i want to play along or because of the 90 second limit on flickr. in order to calculate the fps i just do for example number of frames divided by the number of seconds the final movie should be.
usually i encode to xvid format, which is very fast on my box and has nice results.
but last time i wanted to edit the outcoming movie in adobe premiere, which doesnt like xvid so i had to encode the timelapse as avi without compression at all.


Offline barret

  • ***
  • 125
  • S3 & a550
Re: - image sequence to video
« Reply #4 on: 17 / June / 2009, 10:02:43 »
but seriously, using the method i suggest you dont need to create intermediate huge video files (getting a good compression from virtualDub is complex, u usualy have to compress twice. inside Vdub (uncompressed or fastCodec or hwatever) and again outside, no?).

i don't know where did you get such experiences, but in virtualdub, you can choose from almost all installed codecs that you have installed on your system. So, if you have divx, xvid or h264 installed, you can compress directly to those formats. no need to compress twice (why would you do that?).

second thing: you don't need to use uncompressed, huge files - you get compressed files ready for upload straight from virtualdub.

third: intermediate files? right, but only if you want to avoid moving thousands of files aroud directories - obviously (as PhyrePhox said) you don't need to do this - you can move&rename all your files into single directory, and then create a movie in virtualdub with just a few clicks. I use intermediate files only to save time, that's all. and linking many segments in virtualdub doesn't require any additional operations - just load, and save in different file (direct stream copy, no copression necessary, since media is already compressed).

fourth: "getting a good compression from virtualDub is complex". what? where? just choose your codec, change it's quality settings (move a slider from "good quality" to "smaller file"), and you're done.

is it so hard? :)

Re: - image sequence to video
« Reply #5 on: 17 / June / 2009, 12:56:11 »
I have an image (of a TV transmitter mast)  that is 25,000 pixels in height

Using ImageJ, I can create 800x600 frames as we pan from bottom to top of image.

Any idea how the individual images could be frame-sreved to AviSynth ?

That would avoid me generating gigabytes of frames, just one at a time which are then deleted.

(a friend has used Bryce to do this for me but apparently it is a bit complicated).


Offline yair

  • *
  • 34
  • A620, A640, A530
Re: - image sequence to video
« Reply #6 on: 17 / June / 2009, 21:23:39 »
barret- i love Vdub! before aviDemux it was my lightweight cut/split/merge tool.
i still use vDub as its support avisynth like no other :)

PhyrePhoX - you can frameserve from aviSynth to Premiere, and many other NLE's to0.

Code: [Select]
Animate(0,1500,"Crop", pan,0,0,600,800, pan,0,pan.height,600,800)
this should work, but i sense a disturbance in the force, i'll ask the counsel for assistance.


Offline yair

  • *
  • 34
  • A620, A640, A530
Re: - image sequence to video
« Reply #7 on: 18 / June / 2009, 05:41:27 »
this works great, i used avs2avi for quick command line encoding
the Animte filter will take another filter (in this case on of many resize filters) and do a linear curve between its parameters.

Code: [Select]
Animate(0,length,"BicubicResize", pan,600,800,0.33,0.33,0,24200,600,800, pan,600,800,0.33,0.33,0,0,600,800)
#BicubicResize (clip, int target_width, int target_height, float "b", float "c", float "src_left", float "src_top", float "src_width", float "src_height")

Re: - image sequence to video
« Reply #8 on: 18 / June / 2009, 17:01:43 »
Very, very interesting !

I have tried it on a smaller JPG first.

I do not know how you worked-out what parameters were needed for CoronaSequence and Animate, the documentation is a little unclear.

Could you explain each parameter of Animate ?

In particular, I do not see why resize is needed, we are 'cutting-out' part of the image for each frame, not resizing.

« Last Edit: 18 / June / 2009, 19:27:04 by Microfunguy »


Offline yair

  • *
  • 34
  • A620, A640, A530
Re: - image sequence to video
« Reply #9 on: 19 / June / 2009, 02:03:16 »
the params for avisynth can be a bit messy. but most of them share the same structure. avs has a couple of allowed syntax structure so check the syntex section for more.
i used avsP, an IDE to experiment. luckily debugging with avs is easy as the error usually show on the video with line number and cause.

the resize params are explained here, in short:
BicubicResize(clip clip, int target_width, int target_height, float b, float c, float src_left, float src_top, float src_width, float src_height)
note we use the expanded syntax which does a cropping and resizing in a single filter.

clip = see below, we still need to specify the clip, (even if we called it before thru animate)
target_width, target_height = this is the target size, in our case its not animated, we want a set size and anyways, avs will complain as you can not animate the size of the master video frame.
b, c = this are internal arguments for the resize filter, its math for the interpolation of the pixels, i consolte the documentation and leave them at default.
src_left, src_top = this is what we animate, the src_top will change from 24200 to 0 over the length of the video.
src_width, src_height = also frozen, same as target size. we only care for the src_top.

and so we get the two following extreams. animte will move linearly between them
BicubicResize(pan,600,800,0.33,0.33,0,0       ,600,800)

the animate params are explained here, in short:
Animate(clip clip, int start_frame, int end_frame, string filtername, start_args, end_args)

clip = is the clip we are working on, in my example i dont specify it as avs will use the last clip by default. there is even a reserved word for it, last. so for example, if you want to get one of its properties you can use last.height or last.width.

start_frame, end_frame = the range on which we work on, also will set the speed of the transition. i set it to zero for start_frame and length (a user defined var) for the end_frame.

filtername = this is the filter we use, like "resize" or "crop" or whatever, i originally tried using crop, but i was advised to use resize as it uses different kinds of pixel interpolation for smoother, better looking result.

start_args, end_args = this are the start arguments and end arguments for the filter we animate. i usually comment out the Animate filter and first try applying the filter by its own, then i just copy the params into this field.

CoronaSequence is an external filter so its not covered in the wiki, see original post for more on its syntex, in my orginal script i didn't set anything apart from the clip name, which proved to be a problem as the default length of CoronaSequence clip is 1501 and i couldn't understand why all my efforts ended in a video with that length, so i explicitly set its length to whatever speed i want the effect to run, using the stop var.

note- i used media player classic for preview as virtualdub couldn't handle the original 25,000 height.
note2- the smooth effect of this pan cannot be experienced on a video preview, you have to "bake" it to video as my machine couldn't handle it unless i veiwd it on a frame by frame basis. ymmv

Steve David, if you have any more questions, please, your work has been invaluable to me, and to the community!
« Last Edit: 19 / June / 2009, 07:44:39 by yair »


Related Topics