For now, I just wanted to note that if a site were created to edit someone's video, it would make sense to upload the images and process them in a RAM disk on the server, processing will be much faster that way.

Tilt-shift a video file with ImageMagick

  1. dump video to image files.
  2. create a mask.
  3. create a set of blurred images.
  4. create a set of composite images created from the blurs with the mask.
  5. recombine images to video file.

Steps:

  1. mplayer -vo jpeg myfile.mov (or mplayer -vo png:z=0 -ao pcm:file=file.wav file)
  2. convert -threshold 100% 00001.jpg -fill white -draw 'ellipse 160,160 300,40 0,360' -gaussian 35×35 +matte circle_mask.jpg;display circle_mask.jpg
  3. for i in *.jpg;do convert -gaussian 3×3 $i blur/$i;done
  4. for i in cropped*.jpg;do composite $i blur/$i circle_mask.jpg out/$i;done
  5. mencoder “mf:\/\/out\/cropped*.jpg” -mf fps=24 -o blur_output.avi -ovc lavc -lavcopts vcodec=mpeg4

That's it.

“That's it” nice. not quite-

To get better results, a simple ellipse just isn't appropriate. what is better may be a rotated ellipse. To get a rotated ellipse, SVG drawing is necessary.

M: move abosolute Z: end path A: draw an Arc

Specs are here: http://www.w3.org/TR/SVG/paths.html#PathDataGeneralInformation

something that is close:

convert -threshold 100% koytmp/00000600.png -fill white -draw "path 'M 330,240  A 45,5  187  1,0 340,320 A 45,5  187  0,0 330,240 Z '" -depth 8 -gaussian 35x35 +matte circle_mask.png;display circle_mask.png

A values: 45,5 = radii 187 = angle of rotation 1,0 = sweep and some other shit, not so important 340,320 = endpoint x,y

Another very decent shape:

convert -threshold 100% koytmp/00000600.png -fill white -draw "path 'M 352,340  A 10,1  187  1,1 350,260 A 10,1  187  1,1 352,340 Z '" -depth 8 +matte circle_mask.png;display circle_mask.png
convert -threshold 100% koytmp/00000600.png -fill white -draw "path 'M 352,340  A 10,1  187  1,1 350,220 A 10,1  187  1,1 352,340 Z '" -depth 8 +matte circle_mask.png

Less blur worked better, 3×3 gauss on Koyaanisqatsi video…

To extract audio:

mplayer -vc null -vo null -ss 2700 -frames 300 -ao pcm:file=koy300.wav Koyaanisqatsi.mkv  - frames doesn't seem to stop the dump at the appropriate place.  is there an end seconds arg?
mplayer -vc null -vo null -ss 2700 -endpos 300 -ao pcm:file=koy300.wav Koyaanisqatsi.mkv

endpos arg note in the man page: When used in conjunction with -ss option, -endpos time will shift forward by seconds specified with -ss. i.e. subtract ss from the absolute number of seconds for your end time.

Can't seem to combine, mplayer can at least play this one:

encoder "mf://out/*.png" -mf fps=24 -o koytest2.avi -audiofile koy300.wav -oac lavc -lavcopts acodec=mp2 -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=2400

Bezier's instead?

convert -threshold 100% train1.png -fill white -draw "path 'M100,200 C100,100 400,100 400,200 C400,300 100,300 100,200'" -depth 8 -gaussian 15x15 +matte circle_mask.png;display circle_mask.png

M is the starting point. First C field is first bezier control point, second field is second bezier control point, 3rd C field is the end point. So above, 100,200 is start, 100,200 is end, and 4 control points result in a nice ellipse in the center of an image 500x365px.

This one results in a tilted ellipse, changes of -80 in x value on top, +80 in x value below:

convert -threshold 100% train1.png -fill white -draw "path 'M100,200 C20,100 320,100 400,200 C480,300 180,300 100,200'" -depth 8 -gaussian 15x15 +matte circle_mask.png;display circle_mask.png
convert -threshold 100% train1.png -fill white -draw "path 'M50,200 C20,80 320,80 500,200 C420,300 180,300 50,200'" -depth 8 -gaussian 35x35 +matte circle_mask.png;display circle_mask.png

The second give a shapelier sort of shape.

Decent results on file “P1030435.jpg” with- 5×5 gauss blur, mask of path “'M-300,1050 C-10,500 1600,300 1520,300 C1600,700 400,1000 180,1400'”, mask blur gauss 25×25, and finally -contrast-stretch 1600×1038 -modulate 100,150,100 on the file output.

result mask

Would like to try changing the mask to inverted- let the background be in focus, the foreground out.

More decent results with:

convert -threshold 100% test.jpg -fill white -draw "path 'M100,1000 C200,600 1600,-200 1400,-200 C1400,700 400,1000 100,1000'" -depth 8 -gaussian 25x25 +matte circle_mask.jpg;open circle_mask.jpg 

and

convert -quality 100 -modulate 115,140,100 output.jpg outputhigh.jpg;open outputhigh.jpg &

Contrast- -contrast increases, +contrast decreases… can apply to different channels as well, need to do more reading. This one was interesting on the above image:

convert -quality 100 -modulate 105,160,100 +contrast output.jpg outputhigh.jpg;open outputhigh.jpg

Not bad:

convert -threshold 100% test.jpg -fill white -draw "path 'M-100,-150 C200,200 1400,600 1800,1000 C1800,1600 400,600 -100,100'" -depth 8 -gaussian 1x1 +matte circle_mask.jpg;open circle_mask.jpg
convert -gaussian 25x25 circle_mask.jpg circle_mask.jpg
composite test.jpg testblur.jpg circle_mask.jpg output.jpg;open output.jpg &
convert -quality 100 -modulate 110,160,100 output.jpg outputhigh.jpg;open outputhigh.jpg