Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3802404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:12:12+00:00 2026-05-19T14:12:12+00:00

I need to take HTML5 canvas output as video or swf png sequence. I

  • 0

I need to take HTML5 canvas output as video or swf png sequence.

I found the following link on stackoverflow for capturing images.
Capture HTML Canvas as gif/jpg/png/pdf?

But can anyone suggest if we want the output to be video or swf of png sequence?

EDIT:

Ok now I understood how to capture the canvas data to store on server, I tried it and it is working fine if I use only shapes, rectangle or some other graphic, but not if I draw external images on canvas element.
Can anyone tell me how to capture canvas data completely whether we use graphic or external images for drawing on canvas?

I used the following code:

var cnv = document.getElementById("myCanvas");
var ctx = cnv.getContext("2d");

if(ctx)
{
  var img = new Image();

  ctx.fillStyle = "rgba(255,0,0,0.5)";
  ctx.fillRect(0,0,300,300);
  ctx.fill();

  img.onload = function()
  {
     ctx.drawImage(img, 0,0);
  }

  img.src = "my external image path";

  var data = cnv.toDataURL("image/png");
}

after taking the canvas data into my “data” variable I created a new canvas and draw the captured data on that, the red rectangle drawn on the second canvas but that external image doesn’t.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:12:12+00:00Added an answer on May 19, 2026 at 2:12 pm

    I would suggest:

    1. Use setInterval to capture the contents of your Canvas as a PNG data URL.

      function PNGSequence( canvas ){
        this.canvas = canvas;
        this.sequence = [];
      };
      PNGSequence.prototype.capture = function( fps ){
        var cap = this;
        this.sequence.length=0;
        this.timer = setInterval(function(){
          cap.sequence.push( cap.canvas.toDataURL() );
        },1000/fps);
      };
      PNGSequence.prototype.stop = function(){
        if (this.timer) clearInterval(this.timer);
        delete this.timer;
        return this.sequence;
      };
      
      var myCanvas = document.getElementById('my-canvas-id');
      var recorder = new PNGSequence( myCanvas );
      recorder.capture(15);
      
      // Record 5 seconds
      setTimeout(function(){
        var thePNGDataURLs = recorder.stop();
      }, 5000 );
      
    2. Send all these PNG DataURLs to your server. It’ll be a very large pile of data.

    3. Using whatever server-side language you like (PHP, Ruby, Python) strip the headers from the data URLs so that you are left with just the base64 encoded PNGs

    4. Using whatever server-side language you like, convert the base64 data to binary and write out temporary files.

    5. Using whatever 3rd party library you like on the server, convert the sequence of PNG files to a video.

    Edit: Regarding your comment of external images, you cannot create a data URL from a canvas that is not origin-clean. As soon as you use drawImage() with an external image, your canvas is tainted. From that link:

    All canvas elements must start with their origin-clean set to true.
    The flag must be set to false if any of the following actions occur:

    […]

    The element’s 2D context’s drawImage() method is called with an HTMLImageElement or an HTMLVideoElement whose origin is not the same as that of the Document object that owns the canvas element.

    […]

    Whenever the toDataURL() method of a canvas element whose origin-clean flag is set to false is called, the method must raise a SECURITY_ERR exception.

    Whenever the getImageData() method of the 2D context of a canvas element whose origin-clean flag is set to false is called with otherwise correct arguments, the method must raise a SECURITY_ERR exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to take a picture from a webcam into a webapp (PHP5/JQuery/HTML5) but
I got some graphic design that was made using JavaScript / Html5 Canvas. Take
Need to take a SELECT drop down list options and find if any of
I need to take offline and offline JOBS of schema B while I'm logged
I need to take a large file, with lines such as: member: cn=user0001,ou=people And
i need to take some row. They came from sql TARIH (sql column) is
I need to take a C++ vector with potentially a lot of elements, erase
I need to take the mouse click position in float or double, how can
I need to take rows from two separate tables, and arrange them in descending
I need to take a url, /ServiceSearch/r.php?n=blahblah, and have it go to /search/blahblah/ so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.