# Save as video from sketch

**URL:** <https://discourse.processing.org/t/save-as-video-from-sketch/40072>\
**Category:** Libraries\
**Tags:** homework\
**Created:** [December 8, 2022, 6:40pm UTC](https://discourse.processing.org/t/save-as-video-from-sketch/40072 "2022-12-08T18:40:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vrtx](https://avatars.discourse-cdn.com/v4/letter/v/e99b99/32.png) [@vrtx](https://discourse.processing.org/u/vrtx)\
**Post date:** [December 8, 2022, 6:40pm UTC](https://discourse.processing.org/t/save-as-video-from-sketch/40072/1 "2022-12-08T18:40:47Z")

</div>

Hi,  
i have being searching for days and i can not save my sketch as a video.  
Any help, please!

here is the code:  
the sound has about 20 seconds. and there is a lots of lines as coment and code i’ve been tryed… I can not clean yet…

```auto

import processing.sound.*;
SoundFile soundfile;
PImage et;
float opacity = 0;
PImage img; //here
PImage txt;
PImage trc;
boolean overButton = false;

boolean backwards=false;
int timeLapse=400;
int timeTrack;

void setup() {
  size(600, 600);

  soundfile = new SoundFile(this, "fabFX.mp3");
  soundfile.loop();

  //capa = loadImage("esfera1600.jpg");

  //rect move
  /*
  img = createImage(100, 100, ARGB); // here
   for (int i = 0; i < img.pixels.length; i++) { // here
   float a = map(i, 0, img.pixels.length, 255, 0); //here
   img.pixels[i] = color(255, 204); //here
   }
   */

  //images
  trc = loadImage("Trance3.png");
  txt = loadImage("TextoTecFXpng.png");
  et = loadImage("etFXpng.png"); // Load the image into the program
  et.resize(258, 458);
}

void draw() {
  background(0); // total canva black

  // float playbackSpeed = map(mouseX, 0, width, 0.25, 4.0);
  //soundfile.rate(playbackSpeed);

  // Map mouseY from 0.2 to 1.0 for amplitude
  // float amplitude = map(mouseY, 0, width, 0.2, 1.0);
  // soundfile.amp(amplitude);

  // Map mouseY from -1.0 to 1.0 for left to right panning
  // float panning = map(mouseY, 0, height, -1.0, 1.0);
  // soundfile.pan(panning);

  // rect flahing/blinking

  int m = millis();
  fill(m % 200); // velocity of flashs **not working good** maybe my computer..
  rect(25, 25, 555, 555, 30);
  //image(et, 130, 125 );
  // image(txt, 50, 40);

  //rgb
  tint(20, 17, 247, 100); // Alpha to 102 without changing the tint
  image(et, 140, 125 );
  tint(255, 0, 0, 80); // Tint to yellow, alpha to 153
  image(et, 120, 125 );

  //opacity
  if (opacity < 255) { // When less than the maximum,
    opacity += 0.5; // increase opacity
  }
  tint(255, opacity);
  image(et, 130, 125 );
  image(txt, 50, 40);
  image(trc, 85, 130);

  noFill();
  stroke(255);

  ellipse(mouseX, mouseY-55, 200, 200);

  //button link to web page

  if (overButton == true) {
    int m4 = millis();
    fill(m4 % 150);
    circle(260, 230, 30);
    cursor(CROSS);
  } else {
    noStroke();
    noFill();
    cursor(HAND);
  }
}

//circle(260, 230, 30);

void mousePressed() {
  if (overButton) {
    link("file:///C:/Users/Usuario/Documents/Processing/Estudos/processing_benfrypdf.pdf");
    link("file:///C:/Users/Usuario/Documents/Pd/externals/Gem/GemPrimer.pdf");
  }
}

void mouseMoved() {
  checkButtons();
}

void mouseDragged() {
  checkButtons();
}

void checkButtons() {
  if (mouseX > 200 && mouseX-40 < 300 && mouseY+35 > 200 && mouseY <300) {
    overButton = true;
  } else {
    overButton = false;
  }
}

```

i also have ffmpge, not sure if its working. Brend new to me, just intalled.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 11, 2022, 11:25am UTC](https://discourse.processing.org/t/save-as-video-from-sketch/40072/2 "2022-12-11T11:25:27Z")

</div>

Hi @vrtx,

Have you looked at VideoExport libraries which supports also audio.

> **[GitHub - hamoid/video\_export\_processing: Processing library that interfaces...](https://github.com/hamoid/video_export_processing)**
>
> Processing library that interfaces with ffmpeg to export video files - hamoid/video\_export\_processing

Or the method using [safeFrame] ([saveFrame() / Reference / Processing.org](https://processing.org/reference/saveFrame_.html))  
[https://youtu.be/G2hI9XL6oyk](https://youtu.be/G2hI9XL6oyk)

With safeFrame and ffmpeg you can also add audio manually…

[https://ffmpeg.org/ffmpeg.html](https://ffmpeg.org/ffmpeg.html)

Cheers  
— mnse
