Video Export library


I created this library to export video directly from Processing.

Does it look alright? First time I try publishing a library.

Now that I think about it... I could easily add the option to add sound to the produced movie. Ok, next version :)



  • hello Hamoid, I tried your library today and after a lot of trouble installing ffmpeg. I produced my first video, your basic example. The video is created, but the mediaplayer does not recognize the codex. I'm using a windows 64-bits computer. Can you give me a hint, how I can solve this problem?

    gr. Ria

  • edited June 2015

    Hi! I haven't used Windows in a very long time, but as I remember the media player always had trouble playing lots of formats.

    I recommend VLC which plays hundreds of video formats, is open source and works in Windows, Linux and Mac.

    If you want to still use mediaplayer, I think there's a way to install codecs, but someone more experienced with Windows should explain how that works. Maybe this helps:

  • BTW. Can you describe the trouble installing ffmpeg? Then I could share the instructions with others :)

  • I installed VLC but no result, only a black screen.

    Trouble installing ffmpeg: At the end I downloaded an build from After a zip download. you can click a batch file, wich creates the ffmpeg.exe

  • hamoid,

    this is the result txt file:

    ffmpeg version N-72598-gaede1a1 Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.9.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib libavutil 54. 26.101 / 54. 26.101 libavcodec 56. 41.101 / 56. 41.101 libavformat 56. 34.100 / 56. 34.100 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 16.101 / 5. 16.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, rawvideo, from 'pipe:': Duration: N/A, start: 0.000000, bitrate: 259200 kb/s Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 600x600, 259200 kb/s, 30 tbr, 30 tbn, 30 tbc No pixel format specified, yuv444p for H.264 encoding chosen. Use -pix_fmt yuv420p for compatibility with outdated media players. [libx264 @ 000000000303cd80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [libx264 @ 000000000303cd80] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit [libx264 @ 000000000303cd80] 264 - core 146 r2538 121396c - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=15.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'C:\Users\RIia\Mijn Projecten\processing-3.0a5\modes\java\libraries\VideoExport\examples\basic\basic.mp4': Metadata: comment : Exported using VideoExport for Processing - encoder : Lavf56.34.100 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 600x600, q=-1--1, 30 fps, 15360 tbn, 30 tbc Metadata: encoder : Lavc56.41.101 libx264 Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) [swscaler @ 000000000301b120] Warning: data is not aligned! This can lead to a speedloss frame= 33 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A
    frame= 64 fps= 62 q=21.0 size= 2kB time=00:00:00.20 bitrate= 67.6kbits/s
    frame= 95 fps= 62 q=21.0 size= 7kB time=00:00:01.23 bitrate= 44.4kbits/s
    frame= 125 fps= 61 q=21.0 size= 12kB time=00:00:02.23 bitrate= 45.0kbits/s
    frame= 155 fps= 61 q=21.0 size= 18kB time=00:00:03.23 bitrate= 45.4kbits/s #:-S

  • That's odd. What's the video file size? Is it more than zero bytes?

    Did it not work to download a ready to use static ffmpeg from ?

    Could you share the video so I can try play it myself? (dropbox link, your own server link, or something else...)

    Thanks for testing! :)


    Hamoid, thank you for your help!! you can find the basic.mp4 file in this test directory

    Did it not work to download a ready to use static ffmpeg from ? That's what I used now to make this basic.mp4

    gr. Ria

  • Thanks. That mp4 is for some reason not valid. I'm going to try the library with some of my colleagues using Windows and I hope we find a way to make it work. I'll be back :)

  • Thanks man! I will wait ...

  • Does this file play fine? I produced that one on my computer (Arch Linux) with ffmpeg 2.6.3.

  • I released version 0.0.6 that I hope fixes the playback issues in Mac and Windows. Does it work any better?

  • No, just a black screen.

  • Strange there are missing a some posts. I wrote earlier that your was playing well in VLC, but not in Media player.

  • Hi hamoid! I'm very excited to use test your library. I've tried the 'basic' example and failed. I'm on ubuntu 14.04 and when i'vewas prompted to locate the ffmpeg i didn't know what to do. Then i downloaded the ffmpeg most recent release, unziped and when the prompt asked for the ffmpeg i gave the location of some ffmpeg.c file. Then it crashed and didn't even asked for the ffmpeg location again. Any thoughts on that? Looking forward to render some animations :D

  • edited June 2015

    Hi! ffmpeg.c is the c language source code of ffmpeg. That's not an executable program. So first thing you should do is tell the video export library to forget the ffmpeg location. You can do that by calling videoExport.forgetFfmpegPath().

    In Ubuntu you don't need to manually download ffmpeg. You can use the Ubuntu software center to install ffmpeg (if it's not already installed). You can test on a terminal by typing ffmpeg and pressing enter. Does it complain that ffmpeg is not found? In some Linux distributions it might be located at /usr/bin/ffmpeg


  • Brilliant! I've called the videoExport.forgetFfmpegPath() on the void setup() first but it didn't worked, then called in the void draw() and worked. WIth the ffmpeg package installed from this ppa i could generate the mp4. Thanks a lot hamoid. Soon i'm posting some results

  • Hello hamoid!

    I'm on a Mac (Yosemite 10.10.3) and have installed ffmpeg. But when I run the examples I get these errors: Cannot run program "/Users/andreasrefsgaard/Downloads/ffmpeg-73211-g30e9ebb.7z": error=13, Permission denied

    Do you know how to fix this?

  • Hi, 7z files are compressed files. Similar to zip files. So that file is not a program you can run, you have to uncompress the 7z file first. I'll try to write detailed install instructions for ffmpeg during the following days (I need to try the process on different operating systems).

  • Okay, thanks :). Please provide a link to the install instructions if you find the time

  • hey. thanks for the nice library. i have the problem that the colors in the exported are less saturated. any idea how to change that?

    is use these settings: videoExport.setFrameRate(30); videoExport.setQuality(100);

    running uner windows 7.

    screenshot processing application 2016-01-08_153403

    screenshot video 2016-01-08_153515

  • I found this link possible solution:

    I'll create an issue on GitHub and try it when I get some time.

  • Hi Hamoid! I'm new to this forum(not to processing), so forgive me if this comment is pointless/too late. I tried your library. It does not work on windows PC. The video it exports cannot be opened. If i use other video players, a blank screen appears for the correct amount of time(i think). Any ideas why? Thanks

  • Hi! Could you please try to close the sketch in these three different ways and tell me if the resulting video is in all three cases broken? 1. Press ESC 2. Click STOP button on the IDE. 3. Click close icon on the sketch window. Also, which version of Processing? If not the latest, could you try on 3.0.2?

  • edited April 2016

    Hi @hamoid, did you add the sound-export option in the end? In order to export video files with working sound to it. Thanks

  • i have been trying to export the video and then set it again together with the sound in an external software, but it is not working, as I can't set up the frameRate right. It seems it needs to be exported together...

  • hi hamoid, I tried to combine audio and video via cmd. but it gives the same result then with adobe premiere (I tried before). I can't manage to bring the frameRate of the video together with the Hz of the audio. i manage to almost have it synchronized, but not really. i guess that processing has some delay... probably it needs to done in processing, frame per frame?

  • edited April 2016

    I see, so you're not just adding some background music, but you need it to be tightly in sync. Does this help? You could do some experiments, for instance by creating a clock video. Every second you have an audible and visible click, and render 1 minute of this. Then you could see if there's just a constant offset, or if the offset increases over time.

  • thanks i will try it, for better understanding: I load some music file, analyze it via "sound". and then make some visualization triggered by the sound spectrum. the result is a sound visualizer. then when I export the visual, it doesn't fit with the audio if I try to link it in some external software.

    I managed to adjust the frameRate, it looks like it produces a constant offset. But still, I have to test it. and then what happens, if the visual is a bit heavy and processing can't calculate the fps right? then every visual will have a different offset and delay...impossible to control.

  • I now understand the problem, but that's not an issue of the video export library. You should probably split the process in two parts (that's what I've done in the past). One, analyze the video without drawing anything. Just export the audio analysis data to a file on disk, including timing information. Second, in a different program, you use that data to draw frames matching the right times from your data. That way your graphics will be in sync with your audio. It's very unlikely that it will work if you analyze, render and save video frames on real time, because the time it takes to do these 3 steps is unpredictable, and it won't happen exactly at 30.000 fps.

  • edited April 2016

    You mean something like this Or do you have any other hints/or code pieces? It seams a good idea, i will try it. thanks

  • edited April 2016

    Yes, something like that. I would use createWriter(), which did not exist when she made that video. It would be nice to create a Processing Tool for this purpose, for creating a CSV file at a specific FPS including amplitude and FFT from an audio file. Some day when I have time...

  • Hello hamoid!

    First of all congratulations for this nice and useful library.

    Said that, I have a problem when I try to export a video and I am using pixelDensity(displayDensity());

    The error message is: ArrayIndexOutBoundsException:2832392

    How could I fix it? Thank you

  • Hi & thanks. I've never used that function, so I'm not sure. Could you post a link to your code?

  • I just realized I am also following your tutorials on Youtube! I appreciate so much your help in every channel!

    Your library works perfectly without pixelDensity() function so I guess the problem is about pixel rendering for retina.

    import com.hamoid.*;
    VideoExport videoExport;
    color i1, i2, f1, f2, c1, c2;
    int i =0;
    int R = 255;
    int v = 150;
    void setup() {
      size(700, 500);
      // Define colors
      i1 = color(random(R), random(R), random(R));
      i2 = color(random(R), random(R), random(R));
      c1 = i1;
      c2 = f2;
      f1 = i1;
      f2 = i2;
      // noLoop();
      videoExport = new VideoExport(this, "gridColors.mp4");
    void draw() {
      if ( red(c1) == red(f1) && green(c1) == green(f1) && blue(c1) == blue(f1) ) {
      // make gradient
      float inter = map(i, 0, v, 0,1);
      c1 = lerpColor(i1, f1, inter);
      c2 = lerpColor(i2, f2, inter);
      setGradient(0, 200, width, height, c1, c2);
    void pickNewColor(){
        i1 = f1;
        i2 = f2;
        f1 = color(random(R), random(R), random(R));
        f2 = lerpColor(i1, i2, 0.5); 
        i =0;
    void setGradient(int x, int y, float w, float h, color c1, color c2 ) {
     float size = 3; 
     for (int i = x; i <= x+w; i+=10) {
       for (int j = y; j <= y+h; j+=10) {
         float s = j+i;
          float inter = map(s, y, w + (w/4), 0, 1);
          color c = lerpColor(c1, c2, inter);
          if ((j - 0) % 20 == 0)
            ellipse(i, j, size, size);
            ellipse(i+5, j, size, size);
  • Sorry again for late response. I use processing 3.0. I'm not sure what u mean by "close sketch in three different ways". I always use a button in the sketch to close, using the "exit()" function. I'll try by using the close and stop buttons.

  • Surprising result:
    It works occasionally now, but only if i use the stop button in IDE.

    It works about 2 times in every 3 tests.

  • But why?
    Why doesn't it work if i use exit() function, after all, that's supposed to do the same thing?
    Pls Note that since it only works with IDE stop button, one cant export applications made using the library - a major setback.

  • edited April 2016

    This is the error it throws all the time:
    Apr 24, 2016 1:46:46 PM java.util.prefs.WindowsPreferences <init> WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5
    It works if i use IDE STOP button, even though it throws the same error.

  • I just realized I learned most of my basics of processing from your channel, thanks for that too.
    It could help if u made a video on this library too.

  • @alexdontsurf I'll try on a retina computer when I see one :)

    @Lord_of_the_Galaxy Are you using the latest version of the library? This used to be a error before. But it's unrelated to the exit() issue. I don't know why that happens. I will ask and do some tests.

    Good idea about making a video about this library :) Cheers!

  • Nope. It still doesn't work.
    Thanks anyway!

  • @Lord_of_the_Galaxy It seems to be an issue in Processing. You can try a workaround as I suggested here: (basically, call videoExport.dispose() before closing your sketch to make sure all the data is saved to disk).

  • Um, yeah. I tried that too.
    But it still does the same thing(even though I exit after calling dispose( ) )
    Any ideas why that might be happening?
    Any workarounds to this?

  • edited May 2016

    @Lord_of_the_Galaxy What is "the same thing"? It still produces a broken video file? If that's the case I'm going to need to test it on a Windows computer.

    If you know how to use the command line, it might help me if you run this command on the folder where the video is found: "ffmpeg.exe -i YOURVIDEO.mp4" (replace YOURVIDEO with the right filename). It will output some text, which you can copy by selecting and right clicking the mouse. Finally paste it here. I hope that reveals something useful.

  • edited May 2016

    By same thing I mean it still produces same old broken video file.
    The sample code I use:
    import com.hamoid.*;

    VideoExport videoExport;  
    void setup() {  
      size(600, 600);  
      videoExport = new VideoExport(this, "basic.mp4");  
    void draw() {  
      rect(frameCount * frameCount % width, 0, 40, height);  
    void keyPressed(){  
      }catch(Exception e){  
        System.err.println("Error Ocurred");  

    I always exit using a key Press, yet it fails to produce any usable movie files. Also note that it still works if i use the stop button pin the IDE.

    `ffmpeg version N-79107-g30d1213 Copyright (c) 2000-2016 the FFmpeg `developers
      built with gcc 5.3.0 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fon
    tconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enabl
    e-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmod
    plug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpe
    g --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex
     --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-li
    bvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --en
    able-libzimg --enable-lzma --enable-decklink --enable-zlib
      libavutil      55. 19.100 / 55. 19.100
      libavcodec     57. 28.103 / 57. 28.103
      libavformat    57. 29.100 / 57. 29.100
      libavdevice    57.  0.101 / 57.  0.101
      libavfilter     6. 39.102 /  6. 39.102
      libswscale      4.  0.100 /  4.  0.100
      libswresample   2.  0.101 /  2.  0.101
      libpostproc    54.  0.100 / 54.  0.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 000000f783d46940] moov atom not found
    basic.mp4: Invalid data found when processing input  

    That is what it says after doing what you told on command line. I understand nothing of what it says, though. I hope it can reveal something good.

  • It is useful. I see there "moov atom not found" which according to means that the end of the file is missing. So for some reason, they keyPressed + dispose trick is not working. I'll investigate.

  • According to exit()'s web reference:
    System's exit() should not be used in Processing: :-SS

    System.exit() should not be used because closing out an application while draw() is running may cause a crash (particularly with P3D).

Sign In or Register to comment.