Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (53)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

Sur d’autres sites (7742)

  • (Java) ImageIO.write() freezes after 540 iterations

    14 octobre 2019, par the4naves

    I’m currently trying to write a simple audio visualizer (Non realtime), but am running into a very weird problem.

    After about 515-545 iterations of ImageIO.write(), the program freezes ; no exceptions, the program doesn’t crash, just, nothing.

    Before you read the code below, here’s a quick rundown of it to make it a bit easier to understand :
    1. Load data from program arguments.
    2. Start ffmpeg with its input set to stdin.
    3. In a loop ; Continually render an image, then send it to ffmpeg with ImageIO.write().

    Other info :
    I’ve verified ImageIO.write() IS actually the problem by placing a print before and after the try/catch statement.
    My first thought was a memory leak, but that doesn’t seem to be the case, at least according to Runtime.getRuntime().freeMemory() ;
    The iterations needed to freeze the program is inconsistent, though its always been in the range of 515-540.
    Rendering a video with less frames works flawlessly.
    My previous solution was to write all images to a folder, then run ffmpeg on them all at once. This worked fine on any number of frames, but used upwards of a gigabyte of storage for a fairly small test video, unacceptable for the small program I’m trying to create.

    As a final note, I realize the code probably has a ton of optimization/general problems, I haven’t had the time to try and get it to work well, as it isn’t even fully working yet.
    With that said, if you see any obvious problems, feel free to include them in your answer if you have the time, it’ll certainly save me some.

    Thanks

    public class Run {

       public static BufferedImage render = new BufferedImage(1920, 1080, BufferedImage.TYPE_INT_RGB);

       public static Graphics buffer = render.getGraphics();

       public static int frame = 0;

       public static double[] bins = new double[3200];
       public static double[] previousBins = new double[3200];

       public static File audio;

       public static BufferedImage background;

       public static OutputStream output;

       public static void main(String[] args) {
           try {
               String command = "cd /Users/admin/Desktop/render ; ffmpeg -r 60 -blocksize 150000 -i pipe:0 -i " + args[1].replaceAll(" ", "\\\\ ") + " final.mp4";

               System.out.println(command);

               ProcessBuilder processBuilder = new ProcessBuilder("bash", "-c", command);

               Process process = processBuilder.start();

               output = process.getOutputStream();
           } catch (IOException e) {
               e.printStackTrace();
           }

           try {
               background = ImageIO.read(new File(args[0]));
           } catch (IOException e) {
               System.out.println("File not found");
           }

           audio = new File(args[1]);

           ByteArrayOutputStream out = new ByteArrayOutputStream();
           BufferedInputStream in = null;

           try { in = new BufferedInputStream(new FileInputStream(audio));
           } catch (FileNotFoundException e1) {
               e1.printStackTrace();
           }

           try {
               out.flush();

               int read;

               byte[] buff = new byte[3200];

               while ((read = in .read(buff)) > 0) {
                   out.write(buff, 0, read);
               }
           } catch (IOException e1) {
               e1.printStackTrace();
           }

           byte[] audioBytes = out.toByteArray();

           System.out.println("Calculating length");

           int frames = 600;

           System.out.println("Rendering images");

           int[] data = new int[3200];

           int index = 0;

           while (frame < frames) {
               for (int i = 0; i < 3200; i++) {
                   data[i] = (short)(audioBytes[index + 2] << 16 | audioBytes[index + 1] << 8 | audioBytes[index] & 0xff);

                   index += 3;
               }

               index -= 4800;

               fourier(data, bins);

               renderImage();

               try {
                   ImageIO.write(render, "jpg", output);
               } catch (IOException e) {
                   e.printStackTrace();
               }

               frame++;

               if (frame % 20 == 0) {
                   System.out.println(frame + "/" + frames + " frames completed");
               }
           }

           System.out.println("Render completed");

           System.out.println("Optimizing file size");

           System.out.println("Optimization complete");

           System.out.println("Program complete");

           System.exit(0);
       }

       public static void renderImage() {
           buffer.drawImage(background, 0, 0, null);

           for (int i = 0; i < 110; i++) {
               int height = (int)((bins[i] + previousBins[i]) / Short.MAX_VALUE);

               buffer.fillRect(15 * i + 20, 800 - height, 10, (int)(height * 1.2));
           }

           System.arraycopy(bins, 0, previousBins, 0, 3200);
       }

       public static void fourier(int[] inReal, double[] out) {
           for (int k = 0; k < inReal.length; k++) {
               double real = 0.0;
               double imaginary = 0.0;

               for (int t = 0; t < inReal.length; t++) {
                   real += inReal[t] * Math.cos(2 * Math.PI * t * k / inReal.length);
                   imaginary -= inReal[t] * Math.sin(2 * Math.PI * t * k / inReal.length);
               }

               out[k] = Math.sqrt(Math.pow(real, 2) + Math.pow(imaginary, 2));
           }
       }

    }
  • ImageIO.write() freezes after 540 iterations

    14 octobre 2019, par the4naves

    I’m currently trying to write a simple audio visualizer (Non realtime), but am running into a very weird problem.

    After about 515-545 iterations of ImageIO.write(), the program freezes ; no exceptions, the program doesn’t crash, just, nothing.

    Before you read the code below, here’s a quick rundown of it to make it a bit easier to understand :
    1. Load data from program arguments.
    2. Start ffmpeg with its input set to stdin.
    3. In a loop ; Continually render an image, then send it to ffmpeg with ImageIO.write().

    Other info :
    I’ve verified ImageIO.write() IS actually the problem by placing a print before and after the try/catch statement.
    My first thought was a memory leak, but that doesn’t seem to be the case, at least according to Runtime.getRuntime().freeMemory() ;
    The iterations needed to freeze the program is inconsistent, though its always been in the range of 515-540.
    Rendering a video with less frames works flawlessly.
    My previous solution was to write all images to a folder, then run ffmpeg on them all at once. This worked fine on any number of frames, but used upwards of a gigabyte of storage for a fairly small test video, unacceptable for the small program I’m trying to create.

    As a final note, I realize the code probably has a ton of optimization/general problems, I haven’t had the time to try and get it to work well, as it isn’t even fully working yet.
    With that said, if you see any obvious problems, feel free to include them in your answer if you have the time, it’ll certainly save me some.

    Thanks

    public class Run {

       public static BufferedImage render = new BufferedImage(1920, 1080, BufferedImage.TYPE_INT_RGB);

       public static Graphics buffer = render.getGraphics();

       public static int frame = 0;

       public static double[] bins = new double[3200];
       public static double[] previousBins = new double[3200];

       public static File audio;

       public static BufferedImage background;

       public static OutputStream output;

       public static void main(String[] args) {
           try {
               String command = "cd /Users/admin/Desktop/render ; ffmpeg -r 60 -blocksize 150000 -i pipe:0 -i " + args[1].replaceAll(" ", "\\\\ ") + " final.mp4";

               System.out.println(command);

               ProcessBuilder processBuilder = new ProcessBuilder("bash", "-c", command);

               Process process = processBuilder.start();

               output = process.getOutputStream();
           } catch (IOException e) {
               e.printStackTrace();
           }

           try {
               background = ImageIO.read(new File(args[0]));
           } catch (IOException e) {
               System.out.println("File not found");
           }

           audio = new File(args[1]);

           ByteArrayOutputStream out = new ByteArrayOutputStream();
           BufferedInputStream in = null;

           try { in = new BufferedInputStream(new FileInputStream(audio));
           } catch (FileNotFoundException e1) {
               e1.printStackTrace();
           }

           try {
               out.flush();

               int read;

               byte[] buff = new byte[3200];

               while ((read = in .read(buff)) > 0) {
                   out.write(buff, 0, read);
               }
           } catch (IOException e1) {
               e1.printStackTrace();
           }

           byte[] audioBytes = out.toByteArray();

           System.out.println("Calculating length");

           int frames = 600;

           System.out.println("Rendering images");

           int[] data = new int[3200];

           int index = 0;

           while (frame < frames) {
               for (int i = 0; i < 3200; i++) {
                   data[i] = (short)(audioBytes[index + 2] << 16 | audioBytes[index + 1] << 8 | audioBytes[index] & 0xff);

                   index += 3;
               }

               index -= 4800;

               fourier(data, bins);

               renderImage();

               try {
                   ImageIO.write(render, "jpg", output);
               } catch (IOException e) {
                   e.printStackTrace();
               }

               frame++;

               if (frame % 20 == 0) {
                   System.out.println(frame + "/" + frames + " frames completed");
               }
           }

           System.out.println("Render completed");

           System.out.println("Optimizing file size");

           System.out.println("Optimization complete");

           System.out.println("Program complete");

           System.exit(0);
       }

       public static void renderImage() {
           buffer.drawImage(background, 0, 0, null);

           for (int i = 0; i < 110; i++) {
               int height = (int)((bins[i] + previousBins[i]) / Short.MAX_VALUE);

               buffer.fillRect(15 * i + 20, 800 - height, 10, (int)(height * 1.2));
           }

           System.arraycopy(bins, 0, previousBins, 0, 3200);
       }

       public static void fourier(int[] inReal, double[] out) {
           for (int k = 0; k < inReal.length; k++) {
               double real = 0.0;
               double imaginary = 0.0;

               for (int t = 0; t < inReal.length; t++) {
                   real += inReal[t] * Math.cos(2 * Math.PI * t * k / inReal.length);
                   imaginary -= inReal[t] * Math.sin(2 * Math.PI * t * k / inReal.length);
               }

               out[k] = Math.sqrt(Math.pow(real, 2) + Math.pow(imaginary, 2));
           }
       }

    }
  • FFMPEG-PHP Code example to trim MP3 file

    15 décembre 2012, par revive

    I've searched here and online,. and have not found clear PHP examples for taking a single MP3 file, and trimming it to a smaller file (removing both beginning and end portions and retaining only the content between a specified start time and end time)..

    What I'm trying to do is pass the start time, end time and mp3 file name to a PHP script, that will then use FFMPEG-PHP to effectively trim or concat that orig file.. without re-encoding it (and retaining all the orig. file metadata, etc.)

    If you provide an example of how to process an MP3 file like this, within one PHP file, it will help a lot ! I'm trying my best to help out our church, and simply don't know FFMPEG-PHP enough to sort this out solo.. :)

    Thanks !!