supplierdeeply

Smoothing time-lapse videos with AviSynth

  • 40 Replies
  • 9106 Views
*

Offline Paco

  • **
  • 77
Smoothing time-lapse videos with AviSynth
« on: 22 / November / 2013, 16:29:13 »
Advertisements
I've recently installed CHDK on my old Canon PowerShot A530 and the first thing I did was to make a time-lapse video of the scene outside the window next to my computer, using the default intervalometer. I tried different intervals and found that 10 sec (6 fps) was optimal to catch cloud movement. In the resulting video I made, using AviSynth, a frame rate of 6 fps was too slow but 12 fps was to my liking. The video was choppy so I learned how to smooth it out. I found just the right plug-in for the job, AviSynth MSU Frame Rate Conversion Filter . There are others but none of them is as easy-to-use or as flexible as this one. You can vary the number of interpolations between frames and the quality of the output. The usage is simple:

Quote
ConvertToYV12().AutoCrop(0, wMultOf=16, hMultOf=16).MSU_FRC(# of interpolated frames, "fast|medium|slow")
with slow giving the highest quality. The ConvertToYV12 and AutoCrop filters are necessary for this plug-in as it only works on the YV12 color space and on frames that are a multiple of 16.

Here is the code I used to create the smoothed video:

Code: (TimeLapse007.avs) [Select]
fps_ = 12
# Create video from images
v = ImageSource("IMG_%04d.JPG", 1106, 1643, fps=fps_) + ImageSource("IMG_%04d.JPG", 1656, 2038, fps=fps_)
# Smooth resulting video
v = v.ConvertToYV12().AutoCrop(0, wMultOf=16, hMultOf=16).MSU_FRC(4, "fast")
return v
The resulting video is 48 fps but is the same relative speed as the original 12 fps video, it just has 4 x the number of frames per second, 3 of them being interpolated between the original neighboring frames.

Here are the original choppy video and the smoothed video side-by-side for comparison:

TimeLapse007 fps=12 AutoCrop 16x16+MSU FRC4, fast ConvertFPSv2, zone=0 horiz filters 2 trim

Since YouTube's servers are slow, it is better to download the highest quality (720p) video and play it in a decent player to see the difference. It may not be that discernable in the embedded player or at the YouTube page.

To do this yourself, get the latest version of AviSynth and VirtualDub. Install them both and then unzip AviSynth MSU Frame Rate Conversion Filter into the AviSynth plugins directory. Copy the above script into a text file with the avs extension, modifying the source and MSU_FRC parameters. Open it in VirtualDub. Use the Xvid MPEG-4 Codec for Compression and save the video to disk.

These programs are Windows programs but can be used on OS X (which I use) or linux. Instructions can be found at Running AviSynth and VirtualDub under Mac OS X via WINE or HOWTO: AviSynth video processing with WINE (ubuntu).

If you have not tried AviSynth and VirtualDub, you are in for a treat. They have many pro-level capabilities and are absolutely free with lots of examples of their uses in many forums. Of course, as with any script-based software, there is a somewhat steep learning curve, but it is well worth the effort. If you install the 3 components above and use the above code, it should work instantly.
« Last Edit: 22 / November / 2013, 17:31:28 by Paco »

Re: Smoothing time-lapse videos with AviSynth
« Reply #1 on: 23 / November / 2013, 07:31:51 »
Thanks for that.

I have been using AviSynth to pan a panorama that is 108,000 pixels wide and divided into four 27,000 wide panoramas.

Such pans are jerky because there is no motion blurring.
I did try some motion-blurring filters but did not like the results.

Maybe this filter will work better ?

I also have a 155x digital zoom sequence taken with the SX50hs.
How can I use this to slow it down by a factor of 4x ?

AviSynth can be quite complicated.


David
« Last Edit: 23 / November / 2013, 10:16:47 by Microfunguy »

*

Offline Paco

  • **
  • 77
Re: Smoothing time-lapse videos with AviSynth
« Reply #2 on: 23 / November / 2013, 10:55:40 »
Thanks for that.

I have been using AviSynth to pan a panorama that is 108,000 pixels wide and divided into four 27,000 wide panoramas.

Such pans are jerky because there is no motion blurring.
I did try some motion-blurring filters but did not like the results.

Maybe this filter will work better ?

Thanks for your post. If I understand correctly, you are stitching together sequential images to form a moving panorama. Right? I'm a little confused about the four individual panoramas. Is each of these panoramas composed of many individual images or is each one a single large image? If the former, this plug-in is exactly what you want if you are looking for SMOOTH panning because it will interpolate frames. If you want to deliberately create motion blur, there are other filters and plug-ins for that that may be combined with this one. They are somewhat difficult to understand how to use but they do work well once you do. There's that learning curve! If it's the latter, you could do a sequential crop of the large images, sliding the window along, and applying the interpolation and motion blur filters. Let me know which it is so I can make recommendations.

Quote
I also have a 155x digital zoom sequence taken with the SX50hs.
How can I use this to slow it down by a factor of 4x ?

Again, it depends on the source. If this is a sequence of images, you can do exactly what I did. Set the fps in ImageSource to 1/4 the current frame rate. This will slow it down by a factor of 4. Then set the interpolation factor in MSU_FRC to 4 to compensate. But that may still be choppy if the original sequence was choppy. If so, increase the factor. If this is a video, there are ways of manipulating the frame rate. Let me know so I can make recommendations.

Quote
AviSynth can be quite complicated.


David

It can be indeed. The documentation is SOME help but it is very technical and dry and the examples are often too simplistic. You do have to Google what you're trying to do and find examples in forum posts. The best place to begin is to look through the official documentation, Internal filters and External filters. Then "Google is your friend." (If I had a nickel for every time I saw that phrase in a post, I'd be as rich as Larry Page. :))

Re: Smoothing time-lapse videos with AviSynth
« Reply #3 on: 23 / November / 2013, 11:44:38 »
If I understand correctly, you are stitching together sequential images to form a moving panorama.

I have 104 overlapping images each 4000x3000.
Using Autopano Pro I can combine many of them to create a number (fourteen I think) of full-resolution panoramas no wider than about 30,000 pixels so that photo-editing software can process them.
They are reduced in height to about 1100 pixels for eventual cropping to 1080.
A number of those reduced-size panoramas are combined again into about seven overlapping panoramas
each no more than 30, 000 pixels wide.

Using AviSynth Cortona sequence a movie is created using a  1920x1080 area that pans from left to right on the pano, taking about seventy seconds in all.
Finally, VDub combines the movies into a ten-minute panning sequence.
The panorama was shot at 1200mm focal length and show objects up to 110 Km (70 miles) away !

Quote
this plug-in is exactly what you want if you are looking for SMOOTH panning because it will interpolate frames.

So, is that confirmed ?

Quote
I also have a 155x digital zoom sequence taken with the SX50hs.
How can I use this to slow it down by a factor of 4x ?

This is just a movie straight out of the camera.


David


*

Offline Paco

  • **
  • 77
Re: Smoothing time-lapse videos with AviSynth
« Reply #4 on: 24 / November / 2013, 01:13:02 »
I have 104 overlapping images each 4000x3000.
Using Autopano Pro I can combine many of them to create a number (fourteen I think) of full-resolution panoramas no wider than about 30,000 pixels so that photo-editing software can process them.
They are reduced in height to about 1100 pixels for eventual cropping to 1080.
A number of those reduced-size panoramas are combined again into about seven overlapping panoramas
each no more than 30, 000 pixels wide.

Using AviSynth Cortona sequence a movie is created using a  1920x1080 area that pans from left to right on the pano, taking about seventy seconds in all.
Finally, VDub combines the movies into a ten-minute panning sequence.
The panorama was shot at 1200mm focal length and show objects up to 110 Km (70 miles) away !

I've been trying to do this off and on for most of the day. I can't find anything about AviSynth Cortona. I am familiar with Cortona but didn't know there was an avisynth plug-in for it. In any case I was able to create a smooth video from a single panoramic image. Here's the script:

Code: [Select]
#SetMemoryMax(5120) # set max memory to use in MB

fps = 60
duration = 20 # seconds
frames = fps * duration

fwidth  = 1280  # output width
fheight =  720  # output height

ImageSource("Iguazu_D├ęcembre_2007_-_Panorama_7.jpg", end=frames, fps=fps)

# LanczosResize(clip clip, int target_width, int target_height)
LanczosResize(width()*fheight/height(),fheight)

# FreezeFrame(clip clip, int first-frame, int last-frame, int source-frame)
# Speeds up rendering rate by ~6x by reusing a single resized image instead of resizing for each frame
FreezeFrame(1, frames, 1)

# Animate(clip clip, int start_frame, int end_frame, string filtername, start_args, end_args)
# Create frames by 'sliding' crop window from start to end of image
Animate(0,frames,"Crop", 0,0,fwidth,fheight, width()-fwidth,0,fwidth,fheight)

#ConvertToYV12().AutoCrop(0, wMultOf=16, hMultOf=16).MSU_FRC(2, "fast")

return(last)

This should be fairly self-explanatory. Just adjust the frame rate to get smooth video. I found 60 fps to be adequate but YMMV. You can adjust the clip duration as well so this script is quite flexible.

Here's the resulting video:

Iguazu Decembre 2007 Panorama 7 60 fps FreezeFrame

Download the 720p version and play on standalone player. YouTube player is horrible and makes it look choppy. It isn't.

Quote
Quote
this plug-in is exactly what you want if you are looking for SMOOTH panning because it will interpolate frames.

So, is that confirmed ?

I tried this with and without using MSU_FRC and, for the same final frame rate, the results look similar but FRC takes much longer to render and the file size is 6x bigger! There's no point in using it if you are panning a single image because you can just adjust the fps parameter until you get smooth results and the results will be better because you are not creating 'artificial' frames. This filter is only useful when you need to create new frames between existing frames.

Quote
Quote
I also have a 155x digital zoom sequence taken with the SX50hs.
How can I use this to slow it down by a factor of 4x ?

This is just a movie straight out of the camera.


David

Try using AssumeFPS or ConvertFPS.

Quote
The AssumeFPS filter changes the frame rate without changing the frame count (causing the video to play faster or slower). It only sets the framerate-parameter.
Quote
The [ConvertFPS] filter attempts to convert the frame rate of clip to new_rate without dropping or inserting frames, providing a smooth conversion with results similar to those of standalone converter boxes. The output will have (almost) the same duration as clip, but the number of frames will change proportional to the ratio of target and source frame rates.

ConvertFPS is a better choice IMO. You could also use FRC to improve the smoothness if necessary.
« Last Edit: 24 / November / 2013, 14:01:23 by Paco »

Re: Smoothing time-lapse videos with AviSynth
« Reply #5 on: 24 / November / 2013, 07:24:52 »

I've been trying to do this off and on for most of the day. I can't find anything about AviSynth Cortona.

Please check your personal messages.


David

Re: Smoothing time-lapse videos with AviSynth
« Reply #6 on: 25 / November / 2013, 07:30:34 »

Here's the resulting video:

That is a nice smooth pan viewed on my large TV.

Quote
I tried this with and without using MSU_FRC

This is FAR better (and faster to convert) than my Cortona version  .... thanks.
Quote

ConvertFPS is a better choice IMO. You could also use FRC to improve the smoothness if necessary.

I will try that next.

Re: Smoothing time-lapse videos with AviSynth
« Reply #7 on: 25 / November / 2013, 12:23:21 »
Well, I tried ConvertFPS with a 1920x1080 H264 video and AviSource gives error "The source image format is not acceptable".
I tried resizing to 1280x720 but same problem.

I suspect you edited a previous post because I thought you referred to seamless panning of multiple images.

Did you have 'second thoughts' ?

If so, how would you do it ?

The images can have overlapping areas if necessary.


David


*

Offline Paco

  • **
  • 77
Re: Smoothing time-lapse videos with AviSynth
« Reply #8 on: 25 / November / 2013, 13:13:49 »
This is FAR better (and faster to convert) than my Cortona version  .... thanks.
Glad to hear it. I thought it would be. Can you upload it to YouTube and post it here? I'd really like to see it.

Quote
Quote
ConvertFPS is a better choice IMO. You could also use FRC to improve the smoothness if necessary.

I will try that next.
If you have any trouble with that I may be able to help. I have used these filters too.

Another filter you may want to try is TemporalSoften. It can create very nice motion blur effects. It needs to be used along with SelectEvery, AssumeFPSTimeStretch, and Blur. You have to play around with all the parameters to get good results. Steep learning curve. Google: avisynth TemporalSoften motion blur - Google Search.

Re: Smoothing time-lapse videos with AviSynth
« Reply #9 on: 25 / November / 2013, 14:00:01 »
If you have any trouble with that I may be able to help. I have used these filters too.

I think you must have missed my last post.

David

 

Related Topics