Maximum file size in Processing - audio and video?

edited December 2016 in Library Questions

Hi,

What are the general guidelines on file size in Processing - both audio and video file size?

I'm trying to make some projects with and without Arduino, where I can trigger videofiles with input from sound sensor, and trigger audio-files with keys, but it is difficult to find information on the maximum file size that Processing is able to handle.

I had a wav-file, which I had to compress, but what are the general criteria?

Thank you.

Morten

Tagged:

Answers

  • I don't think there is a "maximum" file size. That depends on many factors - available memory in the computer (RAM), space left to store the files (Permanent memory), your eventual project size (if you have any limit), the maximum memory available to the Java VM (can be changed in preferences), etc.
    In case of sound files, I think it is more difficult, but video files probably don't have any limit - after all, the whole file is never loaded at once.

  • Thanks!

    So probably - it is this factor: "the maximum memory available to the Java VM (can be changed in preferences)"

    Because I have plenty of RAM as well as space on harddisk. So I'll try change the preferences...

  • Hm..There seems to be some kind of maximum file size, when using media files via Processing:

    When calling an audio file (wav, 33 mb, 2 minutes long) Processing cannot run the sketch.

    When the file is compressed into mp3 - it runs fine... Even if I allocate a lot of RAM (fx 3 gb to Processing), it wont accept the high quality wav-file.

    How can I tell, what the limit of Processing is - when it comes to running media files?

    Thank you.

  • In Processing: File >> Preferences, check Increase availabe memory to (amount you want).

    Bear in mind that as a library loads a sound file it might convert it to its own format. 33 MB on disk can get converted into 100 MB in the RAM once the library has loaded and parsed the file. So file size on disk doesn't say much about how much memory is needed in RAM.

    A good library should dynamically load the file into memory as it plays (buffering) so the RAM doesn't get filled up with all the sound files.

  • edited December 2016

    I have changed the amout in Preferences to - 1000 mb - and tried with 500 as well as 6000 mb, but it still cant run the high quality wav (the computer has 8 gb RAM).

    It runs compressed mp3 and small wav-files - but not the heavy ones...

    The sound library is minim - because the Sound library from Processing are in fact distorting the sounds.

    ** So how can I find the limit, that Processing is able to run?** I can try to compress several versions of the high quality file and use the best possible, but it would be great, if there were some kind of general limit, when it comes to running audio and video.

    Thank you

  • Ok, I think there may be a way to solve this.
    Set the buffer size to something reasonable, by using Minim.loadFile(String filename, int bufferSize).

  • Hm..thank you -

    but I dont really get that (due to ignorance).

  • edited December 2016

    Wherever you are using the loadFile() method, just add an extra argument to it, with a value of say 4096.
    Example-
    minim.loadFile("filename", 4096);
    Where minim is a Minim object that has already been initialised.

  • edited December 2016

    Thank you. But the sketch still chrashes, when the heavy wav-file is triggered. The small mp3-file is not a problem to run.

    Could I try something different?

    `import ddf.minim.*;
    
    Minim minim;
    AudioPlayer gris;
    AudioPlayer kvaeg;
    
    void setup()
    
    {
      size(100, 100);
    
      minim = new Minim(this);
    
    gris = minim.loadFile("grisny.mp3");
    kvaeg = minim.loadFile("kvaeg.wav", 4096);
    
    background(0);
    
    }
    
    void draw()
    {
    
    if (keyPressed) {
    if ( key == '1' )
    {   gris.play(); }
    }
    
    if (keyPressed) {
    if ( key == '2' )
    {   kvaeg.play(); }
    }
    }`
    
  • Format your code. Edit your post, select your code and hit ctrl+o.
    Kf

  • Then I have no idea. Like I said, it was just a guess and wasn't guaranteed to work.
    Maybe the author of the Minim library may know.

  • @Morten_hbe -- when you say the sketch crashes, are there console logs / error messages? If so, what are the specific errors?

    Have you checked the list of open Minim Issues to see if yours is already listed, and to leave a detailed report of the problem if not? I don't see anything there with the keyword "memory"....

  • It gives the errors below (which I am not able to interpretate)...

    The problem seems simply to be about file size. As written above the problem can be solved by compressing the sound file, but it seems strange that I can't get a concrete idea about what audio-files/quality, processing is able to run.

    The sound library from P Foundation is also not able to run the high-quality audio-files.

    Error from the sketch:

    java.lang.ArrayIndexOutOfBoundsException: 15 at javazoom.jl.decoder.LayerIDecoder$SubbandLayer1Stereo.read_allocation(LayerIDecoder.java:396) at javazoom.jl.decoder.LayerIDecoder.readAllocation(LayerIDecoder.java:108) at javazoom.jl.decoder.LayerIDecoder.decodeFrame(LayerIDecoder.java:72) at javazoom.jl.decoder.Decoder.decodeFrame(Decoder.java:147) at javazoom.spi.mpeg.sampled.convert.DecodedMpegAudioInputStream.execute(Unknown Source) at org.tritonus.share.TCircularBuffer.read(TCircularBuffer.java:134) at org.tritonus.share.sampled.convert.TAsynchronousFilteredAudioInputStream.read(TAsynchronousFilteredAudioInputStream.java:189) at ddf.minim.javasound.JSBaseAudioRecordingStream.readBytes(JSBaseAudioRecordingStream.java:217) at ddf.minim.javasound.JSBaseAudioRecordingStream.mRead(JSBaseAudioRecordingStream.java:705) at ddf.minim.javasound.JSBaseAudioRecordingStream.read(JSBaseAudioRecordingStream.java:680) at ddf.minim.javasound.JSAudioOutput.readStream(JSAudioOutput.java:125) at ddf.minim.javasound.JSAudioOutput.run(JSAudioOutput.java:74)

  • An ArrayOutOfBounds exception? That is funny.
    I believe that must be a problem with the Java sound API.

Sign In or Register to comment.