Recherche avancée

Médias (0)

Mot : - Tags -/tags

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

Autres articles (55)

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

Sur d’autres sites (8715)

  • Revision 28930 : on bouge

    31 mai 2009, par ben.spip@… — Log

    on bouge

  • FFMpeg process created from Java on CentOS doesn't exit

    21 juin 2017, par Donz

    I need to convert a lot of wave files simultaneously. About 300 files in parallel. And new files come constantly. I use ffmpeg process call from my Java 1.8 app, which is running on CentOS. I know that I have to read error and input streams for making created process from Java possible to exit.

    My code after several expirements :

       private void ffmpegconverter(String fileIn, String fileOut){
       String[] comand = new String[]{"ffmpeg", "-v", "-8", "-i", fileIn, "-acodec", "pcm_s16le", fileOut};

       Process process = null;
       BufferedReader reader = null;
       try {
           ProcessBuilder pb = new ProcessBuilder(comand);
           pb.redirectErrorStream(true);
           process = pb.start();

           //Reading from error and standard output console buffer of process. Or it could halts because of nobody
           //reads its buffer
           reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
           String s;
           //noinspection StatementWithEmptyBody
           while ((s = reader.readLine()) != null) {
               log.info(Thread.currentThread().getName() + " with fileIn " + fileIn + " and fileOut " + fileOut + " writes " + s);
               //Ignored as we just need to empty the output buffer from process
           }
           log.info(Thread.currentThread().getName() + " ffmpeg process will be waited for");
           if (process.waitFor( 10, TimeUnit.SECONDS )) {
               log.info(Thread.currentThread().getName() + " ffmpeg process exited normally");
           } else {
               log.info(Thread.currentThread().getName() + " ffmpeg process timed out and will be killed");
           }

       } catch (IOException | InterruptedException e) {
           log.error(Thread.currentThread().getName() + "Error during ffmpeg process executing", e);
       } finally {
           if (process != null) {
               if (reader != null) {
                   try {
                       reader.close();
                   } catch (IOException e) {
                       log.error("Error during closing the process streams reader", e);
                   }
               }
               try {
                   process.getOutputStream().close();
               } catch (IOException e) {
                   log.error("Error during closing the process output stream", e);
               }
               process.destroyForcibly();
               log.info(Thread.currentThread().getName() + " ffmpeg process " + process + " must be dead now");
           }
       }
    }

    If I run separate test with this code it goes normally. But in my app I have hundreds of RUNNING deamon threads "process reaper" which are waiting for ffmpeg process finish. In my real app ffpmeg is started from timer thread. Also I have another activity in separate threads, but I don’t think that this is the problem. Max CPU consume is about 10%.

    Here is that I usual see in thread dump :

    "process reaper" #454 daemon prio=10 os_prio=0 tid=0x00007f641c007000 nid=0x5247 runnable [0x00007f63ec063000]
      java.lang.Thread.State: RUNNABLE
       at java.lang.UNIXProcess.waitForProcessExit(Native Method)
       at java.lang.UNIXProcess.lambda$initStreams$3(UNIXProcess.java:289)
       at java.lang.UNIXProcess$$Lambda$32/2113551491.run(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       at java.lang.Thread.run(Thread.java:745)

    What am I doing wrong ?

    UPD :
    My app accepts a lot of connects with voice traffic. So I have about 300-500 another "good" threads in every moment. Could it be the reason ? Deamon threads have low priority. But I don’t beleive that they really can’t do their jobs in one hour. Ususally it takes some tens of millis.

    UPD2 :
    My synthetic test that runs fine. I tried with new threads option and without it just with straigt calling of run method.

    import java.io.BufferedReader;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;

    public class FFmpegConvert {

       public static void main(String[] args) throws Exception {

           FFmpegConvert f = new FFmpegConvert();
           f.processDir(args[0], args[1], args.length > 2);
       }

       private void processDir(String dirPath, String dirOutPath, boolean isNewThread) {
           File dir = new File(dirPath);
           File dirOut = new File(dirOutPath);
           if(!dirOut.exists()){
               dirOut.mkdir();
           }
           for (int i = 0; i < 1000; i++) {
               for (File f : dir.listFiles()) {
                   try {
                       System.out.println(f.getName());
                       FFmpegRunner fFmpegRunner = new FFmpegRunner(f.getAbsolutePath(), dirOut.getAbsolutePath() + "/" + System.currentTimeMillis() + f.getName());
                       if (isNewThread) {
                           new Thread(fFmpegRunner).start();
                       } else {
                           fFmpegRunner.run();
                       }
                   } catch (Exception e) {
                       e.printStackTrace();
                   }
               }
           }
       }

       class FFmpegRunner implements Runnable {
           private String fileIn;
           private String fileOut;

           FFmpegRunner(String fileIn, String fileOut) {
               this.fileIn = fileIn;
               this.fileOut = fileOut;
           }

           @Override
           public void run() {
               try {
                   ffmpegconverter(fileIn, fileOut);
               } catch (Exception e) {
                   e.printStackTrace();
               }
           }

           private void ffmpegconverter(String fileIn, String fileOut) throws Exception{
               String[] comand = new String[]{"ffmpeg", "-i", fileIn, "-acodec", "pcm_s16le", fileOut};

               Process process = null;
               try {
                   ProcessBuilder pb = new ProcessBuilder(comand);
                   pb.redirectErrorStream(true);
                   process = pb.start();

                   //Reading from error and standard output console buffer of process. Or it could halts because of nobody
                   //reads its buffer
                   BufferedReader reader =
                           new BufferedReader(new InputStreamReader(process.getInputStream()));
                   String line;
                   //noinspection StatementWithEmptyBody
                   while ((line = reader.readLine()) != null) {
                       System.out.println(line);
                       //Ignored as we just need to empty the output buffer from process
                   }

                   process.waitFor();
               } catch (IOException | InterruptedException e) {
                   throw e;
               } finally {
                   if (process != null)
                       process.destroy();
               }
           }

       }

    }

    UPD3 :
    Sorry, I forgot to notice that I see the work of all these process - they created new converted files but anyway don’t exit.

  • Ffmpeg only receives a piece of information from the pipe

    4 juillet 2017, par Maxim Fedorov

    First of all - my english is not very good, i`m sorry for that.

    I use ffmpeg from c# to convert images to video. To interact with ffmpeg, I use pipes.

    public async Task ExecuteCommand(
           string arguments,
           Action<namedpipeserverstream> sendDataUsingPipe)
       {
           var inStream = new NamedPipeServerStream(
               "from_ffmpeg",
               PipeDirection.In,
               1,
               PipeTransmissionMode.Byte,
               PipeOptions.Asynchronous,
               PipeBufferSize,
               PipeBufferSize);

           var outStream = new NamedPipeServerStream(
               "to_ffmpeg",
               PipeDirection.Out,
               1,
               PipeTransmissionMode.Byte,
               PipeOptions.Asynchronous,
               PipeBufferSize,
               PipeBufferSize);

           var waitInConnectionTask = inStream.WaitForConnectionAsync();
           var waitOutConnectionTask = outStream.WaitForConnectionAsync();

           byte[] byteData;

           using (inStream)
           using (outStream)
           using (var inStreamReader = new StreamReader(inStream))
           using (var process = new Process())
           {
               process.StartInfo = new ProcessStartInfo
               {
                   RedirectStandardOutput = true,
                   RedirectStandardError = true,
                   RedirectStandardInput = true,
                   FileName = PathToFfmpeg,
                   Arguments = arguments,
                   UseShellExecute = false,
                   CreateNoWindow = true
               };

               process.Start();

               await waitOutConnectionTask;

               sendDataUsingPipe.Invoke(outStream);

               outStream.Disconnect();
               outStream.Close();

               await waitInConnectionTask;

               var logTask = Task.Run(() => process.StandardError.ReadToEnd());
               var dataBuf = ReadAll(inStream);

               var shouldBeEmpty = inStreamReader.ReadToEnd();
               if (!string.IsNullOrEmpty(shouldBeEmpty))
                   throw new Exception();

               var processExitTask = Task.Run(() => process.WaitForExit());
               await Task.WhenAny(logTask, processExitTask);
               var log = logTask.Result;

               byteData = dataBuf;

               process.Close();
               inStream.Disconnect();
               inStream.Close();
           }

           return byteData;
       }
    </namedpipeserverstream>

    Action "sendDataUsingPipe" looks like

    Action<namedpipeserverstream> sendDataUsingPipe = stream =>
           {
               foreach (var imageBytes in data)
               {
                   using (var image = Image.FromStream(new MemoryStream(imageBytes)))
                   {
                       image.Save(stream, ImageFormat.Jpeg);
                   }
               }
           };
    </namedpipeserverstream>

    When I send 10/20/30 images (regardless of the size) ffmpeg processes everything.
    When I needed to transfer 600/700 / .. images, then in the ffmpeg log I see that it only received 189-192, and in the video there are also only 189-192 images.
    There are no errors in the logs or exceptions in the code.

    What could be the reason for this behavior ?