Skip to main content
Inspiring
April 16, 2008
Answered

Time-lapse video

  • April 16, 2008
  • 2 replies
  • 387 views
I'm trying to to capture time-lapse images. I'd like to capture a new image each second. Each image should appear for a fraction of a second (e.g.1/10 sec.), so after 10 seconds I'd have a recording lasting 1 second that displays 10 separate images. However, the result of the code below is to capture a single image and to hold that image in place for a full second. After 10 seconds, I have a 10 second video containing 10 different images. What am I doing wrong?

flashcom = "rtmp:/simon";
myCamera = Camera.get();
pipeline = new NetConnection();
pipeline.onStatus = function() {
myInterval = setInterval(playIt, 1000);
myStream = new NetStream(pipeline);
myStream.publish("test","append");
function playIt() {
myStream.attachVideo(myCamera,0);
}
};
pipeline.connect(flashcom);
    This topic has been closed for replies.
    Correct answer
    As long ast the stream is open time information is being recorded, so taking a frame every second will just change the image ten times over ten seconds. You should attach the camera with the record time of 100ms, publish the stream, then close it.

    so:

    myStream.onStatus = function (info) {
    if (info.code == "NetStream.Buffer.Empty") {
    this.close();
    }
    }

    function playIt() {
    myStream.attachVideo(myCamera, 100);
    myStream.publish("test", "append");
    }

    This should publish 100 ms then close the stream as soon as the buffer clears.

    2 replies

    Correct answer
    April 16, 2008
    As long ast the stream is open time information is being recorded, so taking a frame every second will just change the image ten times over ten seconds. You should attach the camera with the record time of 100ms, publish the stream, then close it.

    so:

    myStream.onStatus = function (info) {
    if (info.code == "NetStream.Buffer.Empty") {
    this.close();
    }
    }

    function playIt() {
    myStream.attachVideo(myCamera, 100);
    myStream.publish("test", "append");
    }

    This should publish 100 ms then close the stream as soon as the buffer clears.
    Participating Frequently
    April 16, 2008
    I cannot comment on your particular approach but I'd like to draw your attention to a completely different solution.

    With BitmapData.draw() in ActionScript you can make screenshots (of what your camera shows). You can hold a limited number of screenshots in memory or you can use Air to access the hard disk for an unlimited number of screenshots.

    Use a timer for your screenshot interval.

    The screenshots are in raw data, similar to uncompressed *.bmp. You can convert them with free JPEGEncoder.as class, but you better do that later because conversion is slow (several seconds per image).

    Well, if you got your 'slides' you convert them into a movie. There are (free) tools for that available.

    You do not need the Fms for that project. ActionScript is sufficient.