Recherche avancée

Médias (91)

Autres articles (60)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (10849)

  • 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 ?

  • Java Xuggler Metadata List of Chapters MP4/M4V Video

    27 juin 2017, par MrSax

    I’m trying to use Xuggler like FFMPEG Metadata Wrapper (I just need the list of Chapters of MP4/M4V Video).

    So far I have not been able to find a solution.
    Can anyone help me ?

    I was only able to get the following information :

       final String filename = "...path...";
       IContainer container = IContainer.make();
       int result = container.open(filename, IContainer.Type.READ, null);
       if (result &lt; 0)
           throw new RuntimeException("Failed to open media file");
       int numStreams = container.getNumStreams();
       long duration = container.getDuration();
       long fileSize = container.getFileSize();
       long bitRate = container.getBitRate();
       System.out.println("Number of streams: " + numStreams);
       System.out.println("Duration (ms): " + duration);
       System.out.println("File Size (bytes): " + fileSize);
       System.out.println("Bit Rate: " + bitRate);
       for (int i = 0; i &lt; numStreams; i++) {
           IStream stream = container.getStream(i);
           IStreamCoder coder = stream.getStreamCoder();
           System.out.println("*** Start of Stream Info ***");
           System.out.printf("stream %d: ", i);
           System.out.printf("type: %s; ", coder.getCodecType());
           System.out.printf("codec: %s; ", coder.getCodecID());
           System.out.printf("duration: %s; ", stream.getDuration());
           System.out.printf("start time: %s; ", container.getStartTime());
           System.out.printf("timebase: %d/%d; ", stream.getTimeBase().getNumerator(),
                   stream.getTimeBase().getDenominator());
           System.out.printf("coder tb: %d/%d; ", coder.getTimeBase().getNumerator(),
                   coder.getTimeBase().getDenominator());
           System.out.println();
           if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {
               System.out.printf("sample rate: %d; ", coder.getSampleRate());
               System.out.printf("channels: %d; ", coder.getChannels());
               System.out.printf("format: %s", coder.getSampleFormat());
           } else if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {
               System.out.printf("width: %d; ", coder.getWidth());
               System.out.printf("height: %d; ", coder.getHeight());
               System.out.printf("format: %s; ", coder.getPixelType());
               System.out.printf("frame-rate: %5.2f; ", coder.getFrameRate().getDouble());
           }
           System.out.println();
           System.out.println("*** End of Stream Info ***");

    UPDATE 07.06.2017
    I just tried it with VLCJ, but still I can not get the list of chapters.

       File file = new File("ia_ISL_13_r720P.m4v");

       NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "vlc64/");
       Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);

       MediaPlayerFactory mpf = new MediaPlayerFactory();
       EmbeddedMediaPlayer emp = mpf.newEmbeddedMediaPlayer();

       MediaMeta mediaMeta = mpf.getMediaMeta(file.getAbsolutePath(), true);
       MediaMetaData asMediaMetaData = mediaMeta.asMediaMetaData();
       System.out.println(asMediaMetaData.getAlbum());
       System.out.println(asMediaMetaData.getArtist());
       System.out.println(asMediaMetaData.getTitle());

       emp.prepareMedia(file.getAbsolutePath());
       emp.play();
       emp.nextChapter(); // -> GO NEXT CHAPTER - SUCCESS

       List> allChapterDescriptions = emp.getAllChapterDescriptions();

       for (List<string> list : allChapterDescriptions) {
           for (String string : list) {
               System.out.println(string);
           }
       }
    </string>