Recherche avancée

Médias (0)

Mot : - Tags -/flash

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)

  • C# Process Multitasking and Limitations

    30 juin 2017, par Komak57

    To give you a intro, me and some guys have suddenly come across a need for a dedicated encoding machine to receive dynamic requests from a server. I wrote a TCP Server, and put it on a Pi to listen for requests. I also wrote a TCP Client that will connect to the Pi, tell it how many cores it has, how many encoders it can run, what kind of latency is involved and other system relevant information. When the Server receives instruction, it will send a request to a valid TCP Client that will then begin a Process to use FFMPEG to start encoding based on some parameters. I’ve been having some weird issues where, when stress testing an 8-core system, it starts 8 encoders, but only 3 of them are actually encoding. The remaining 5 sit at 0% idle waiting for a slot to open up.

    tl ;dr - I’ve determined that using Process.StartInfo.UseShellExecute == false manages the processes in a thread based system, and due to my systems current limitations, only allows 3 threads to run simultaneously. This command is required for Process.BeginOutputReadLine() and Process.BeginErrorReadLine() to get useful information about the encoding process.

    Program.cs

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Threading;
    using System.Threading.Tasks;

    namespace EncodeMinimum
    {
       class Program
       {
           private static int threadCount = 0;
           /// <summary>
           /// Returns the number of available CPU Threads
           /// </summary>
           public static int ThreadCount
           {
               set
               {
                   threadCount = value;
                   CoreStatus = new bool[threadCount];
               }
               get
               {
                   return threadCount;
               }
           }
           private static int lastCore = -1;
           /// <summary>
           /// Increment to next available core and return. Causes IndexOutOfRangeException if there are no available cores.
           /// </summary>
           private static int nextCore
           {
               get
               {
                   int start = lastCore;
                   lastCore++;
                   if (lastCore >= ThreadCount)
                       lastCore = 0;
                   while (CoreStatus[lastCore] &amp;&amp; lastCore != start)
                   {
                       lastCore++;
                       if (lastCore >= ThreadCount)
                           lastCore = 0;
                   }
                   if (lastCore == start &amp;&amp; CoreStatus[lastCore])
                   {
                       throw new IndexOutOfRangeException("No valid cores available.");
                   }
                   return lastCore;
               }
           }
           private static bool[] CoreStatus = new bool[0];
           private static Dictionary tasks = new Dictionary();

           /// <summary>
           /// IntPtr representing the affinity of a single core. Max of 1 of 16 cores.
           /// </summary>
           public static IntPtr[] SingleCore = new IntPtr[]{ (IntPtr)0x0001, (IntPtr)0x0002, (IntPtr)0x0004, (IntPtr)0x0008,
                                                       (IntPtr)0x0010,(IntPtr)0x0020,(IntPtr)0x0040,(IntPtr)0x0080,
                                                       (IntPtr)0x0100,(IntPtr)0x0200,(IntPtr)0x0400,(IntPtr)0x0800,
                                                       (IntPtr)0x1000,(IntPtr)0x2000,(IntPtr)0x4000,(IntPtr)0x8000};

           /// <summary>
           /// Allows for compatibility between Linux and Windows operating systems, sorta.
           /// </summary>
           public static bool IsLinux
           {
               get
               {
                   PlatformID p = Environment.OSVersion.Platform;
                   return (p == PlatformID.Unix);
               }
           }

           static void Main(string[] args)
           {
               Console.WriteLine("[" + DateTime.Now.ToString("h:mm:ss") + "] Program Start");
               ThreadCount = Environment.ProcessorCount;
               bool HandleText = true;
               for (int id = 0; id &lt; ThreadCount; id++)
               {
                   Console.WriteLine("[" + DateTime.Now.ToString("h:mm:ss") + "] Creating Encoding process for ID " + id);
                   tasks.Add(id, new Encoder(id, new Process(), nextCore));
                   CoreStatus[tasks[id].Core] = true;

                   if (Program.IsLinux)
                       tasks[id].Process.StartInfo.FileName = "/usr/bin/ffmpeg";
                   else
                       tasks[id].Process.StartInfo.FileName = @"C:\FFMEPG\ffmpeg.exe";
                   tasks[id].Process.StartInfo.Arguments = String.Format("-y -i {0} -threads 1 -c:v libx264 -preset ultrafast -s {1} -r {2} -b:v {3}k -c:a aac -b:a 41k -f flv {4}", "./original.mp4", "1280x720", "60", "7500", "./out-"+id+".flv");
                   tasks[id].Process.StartInfo.Verb = "runas";
                   if (HandleText)
                   {
                       tasks[id].Process.StartInfo.CreateNoWindow = true; // true
                       tasks[id].Process.StartInfo.UseShellExecute = false; //false
                       tasks[id].Process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
                       tasks[id].Process.OutputDataReceived += new DataReceivedEventHandler(ScannerHandler);
                       tasks[id].Process.ErrorDataReceived += new DataReceivedEventHandler(ScannerHandler);
                       tasks[id].Process.StartInfo.RedirectStandardOutput = true; // true
                       tasks[id].Process.StartInfo.RedirectStandardError = true; // true
                   } else
                   {
                       tasks[id].Process.StartInfo.CreateNoWindow = false;
                       tasks[id].Process.StartInfo.UseShellExecute = true;
                   }

                   try
                   {
                       Console.WriteLine("[" + DateTime.Now.ToString("h:mm:ss") + "] Starting Encoder for stream " + id);
                       tasks[id].Process.Start();
                       if (HandleText)
                       {
                           tasks[id].Process.BeginOutputReadLine();
                           tasks[id].Process.BeginErrorReadLine();
                       }
                       tasks[id].Process.ProcessorAffinity = Program.SingleCore[tasks[id].Core];
                       // Used in multithreaded operations to immediately notify when a process has closed
                       /*tasks[id].Process.WaitForExit();
                       CoreStatus[tasks[id].Core] = false;
                       tasks.Remove(id);*/
                   }
                   catch (Exception e)
                   {
                       Console.WriteLine("[" + DateTime.Now.ToString("h:mm:ss") + "] Failed to start Encoder: " + e.ToString());
                       CoreStatus[tasks[id].Core] = false;
                       tasks.Remove(id);
                   }
               }

               // Asynchronously look for Escape Key
               Thread keyscan = new Thread(new ThreadStart(CheckKeys));
               keyscan.Start();

               // Sleep until Escape Key found
               while (keyscan.IsAlive)
                   Thread.Sleep(100);

               for(int i = 0; i &lt; tasks.Count; i++)
               {
                   tasks[i].Process.Kill();
               }
           }

           /// <summary>
           /// Scans for Escape key 10 time a second
           /// </summary>
           static void CheckKeys()
           {
               // run thread until key is pressed
               while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                   Thread.Sleep(100);
               return;
           }

           /// <summary>
           /// Prints output from processes directly to console.
           /// </summary>
           private static void ScannerHandler(object sendingProcess,
               DataReceivedEventArgs errLine)
           {
               if (!String.IsNullOrEmpty(errLine.Data))
               {
                   Process p = sendingProcess as Process;
                   string msg = errLine.Data.ToString().Trim();
                   Console.WriteLine("[" + DateTime.Now.ToString("h:mm:ss") + "] &lt;" + p.Id + ">: " + msg);
               }
           }
       }
    }

    Encoder.cs

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;

    namespace EncodeMinimum
    {
       public class Encoder
       {
           public Process Process;
           public Thread Task;
           public int ID;
           public int Core;
           public Encoder(int ID, Process Task, int Core)
           {
               this.ID = ID;
               this.Process = Task;
               this.Core = Core;
           }
       }
    }

    I need a way to handle the output from each process created in a live-update manner, while being able to handle any number of simultaneous processes. I might be able to command the process to output to a text file, and read changes from it, but because there’s so little documentation on doing so, I’m not sure how to begin. Are there any alternatives to reading a Processes output without running into this threading issue ?

  • LGPL Xuggle : ConverterFactory.createConverter not supported

    24 mars 2013, par jlengrand

    I am using Xuggle to create an mpeg-ts stream.
    Everything was working nice until I realized that I was using the GPL version of ffmpeg, which I cannot.

    So I recompiled the whole library, and removed the —enable-nonfree and —enable-gpl flags from ffmpeg.

    The thing is that now my code would throw an error at me.

    The lines in question are :

    image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
    IVideoPicture outFrame = ConverterFactory.createConverter(image, IPixelFormat.Type.YUV420P).toPicture(image, timeStamp);

    And the error I get is

    java.lang.UnsupportedOperationException: Converter class com.xuggle.xuggler.video.BgrConverter constructor failed with: java.lang.IllegalArgumentException: IVideoResampler not supported in this build
       at com.xuggle.xuggler.video.ConverterFactory.createConverter(ConverterFactory.java:347)

    The thing is that we were using the same code with the 3.3 version of Xuggle, and even though ffmpeg was throwing warnings at us saying that we had no hardware acceleration, everything was working fine.

    So did something important change between those versions ?
    And how can I overcome this ? I searched in the archive but couldn't find related issues so far.

    Thanks !

  • Transcoding audio using xuggler

    23 juin 2014, par amd

    I am trying to convert an audio file with the header

    Opening audio decoder: [pcm] Uncompressed PCM audio decoder
    AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)
    Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)

    I want to transcode this file to mp3 format. I have following code snippet but its not working well. I have written it using XUGGLER code snippet for transcoding audio and video.

    Audio decoder is

       audioDecoder = IStreamCoder.make(IStreamCoder.Direction.DECODING, ICodec.findDecodingCodec(ICodec.ID.CODEC_ID_PCM_S16LE));
       audioDecoder.setSampleRate(44100);
       audioDecoder.setBitRate(176400);
       audioDecoder.setChannels(2);
       audioDecoder.setTimeBase(IRational.make(1,1000));
       if (audioDecoder.open(IMetaData.make(), IMetaData.make()) &lt; 0)
           return false;
       return true;

    Audio encoder is

       outContainer = IContainer.make();
       outContainerFormat = IContainerFormat.make();
       outContainerFormat.setOutputFormat("mp3", urlOut, null);
       int retVal = outContainer.open(urlOut, IContainer.Type.WRITE, outContainerFormat);
       if (retVal &lt; 0) {
           System.out.println("Could not open output container");
           return false;
       }
       outAudioCoder = IStreamCoder.make(IStreamCoder.Direction.ENCODING, ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_MP3));
       outAudioStream = outContainer.addNewStream(outAudioCoder);
       outAudioCoder.setSampleRate(new Integer(44100));
       outAudioCoder.setChannels(2);
       retVal = outAudioCoder.open(IMetaData.make(), IMetaData.make());
       if (retVal &lt; 0) {
           System.out.println("Could not open audio coder");
           return false;
       }
       retVal = outContainer.writeHeader();
       if (retVal &lt; 0) {
           System.out.println("Could not write output FLV header: ");
           return false;
       }
       return true;

    And here is encode method where i send packets of 32 byte to transcode

    public void encode(byte[] audioFrame){
       //duration of 1 video frame
       long lastVideoPts = 0;

       IPacket packet_out = IPacket.make();
       int lastPos = 0;
       int lastPos_out = 0;

       IAudioSamples audioSamples = IAudioSamples.make(48000, audioDecoder.getChannels());
       IAudioSamples audioSamples_resampled = IAudioSamples.make(48000, audioDecoder.getChannels());

       //we always have 32 bytes/sample
       int pos = 0;
       int audioFrameLength = audioFrame.length;
       int audioFrameCnt = 1;
       iBuffer = IBuffer.make(null, audioFrame, 0, audioFrameLength);
       IPacket packet = IPacket.make(iBuffer);
       //packet.setKeyPacket(true);
       packet.setTimeBase(IRational.make(1,1000));
       packet.setDuration(20);
       packet.setDts(audioFrameCnt*20);
       packet.setPts(audioFrameCnt*20);
       packet.setStreamIndex(1);
       packet.setPosition(lastPos);
       lastPos+=audioFrameLength;
       int pksz = packet.getSize();
       packet.setComplete(true, pksz);
       /*
       * A packet can actually contain multiple samples
       */
       int offset = 0;
       int retVal;
       while(offset &lt; packet.getSize())
       {
           int bytesDecoded = audioDecoder.decodeAudio(audioSamples, packet, offset);
           if (bytesDecoded &lt; 0)
               throw new RuntimeException("got error decoding audio ");
           offset += bytesDecoded;
           if (audioSamples.isComplete())
           {
               int samplesConsumed = 0;
               while (samplesConsumed &lt; audioSamples.getNumSamples()) {
                   retVal = outAudioCoder.encodeAudio(packet_out, audioSamples, samplesConsumed);
                   if (retVal &lt;= 0)
                       throw new RuntimeException("Could not encode audio");
                   samplesConsumed += retVal;
                   if (packet_out.isComplete()) {
                       packet_out.setPosition(lastPos_out);
                       packet_out.setStreamIndex(1);
                       lastPos_out+=packet_out.getSize();
                       retVal = outContainer.writePacket(packet_out);
                       if(retVal &lt; 0){
                           throw new RuntimeException("Could not write data packet");
                       }
                   }
               }
           }

       }

    }

    I get an output file but it doesnt get played. I have very little experience of audio encoding and sampling. Thanks in advance.