Recherche avancée

Médias (3)

Mot : - Tags -/image

Autres articles (61)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • 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

  • 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 (...)

Sur d’autres sites (7256)

  • How to make video from images using Java + x264 ; cross platform solution required

    19 octobre 2014, par Shashank Tulsyan

    I have made a software which records my entire day into a video.
    Example video : https://www.youtube.com/watch?v=ITZYMMcubdw (Note : >16hrs compressed in 2mins, video speed too high, might cause epilepsy :P )

    The approach that I use right now is, Avisynth + x264 + Java.
    This is very very efficient. The video for entire day is created in 3-4mins, and reduced to a size of 40-50MB. This is perfect, the only issue is that this solution is not cross platform.
    Does anyone have a better idea ?

    I tried using java based x246 libraries but

    1. They are slow as hell
    2. The video output size is too big
    3. The video quality is not satisfactory.

    Some website suggest a command such as :

    x264.exe --crf 18 --fps 24 --input-res 1920x1080 --input-csp rgb -o "T:\crf18.mkv" "T:\___BBB\big_buck_bunny_%05d.png"

    There are 2 problems with this approach.

    1. As far as I know, x264 does accept image sequence as input, ffmpeg does
    2. The input images are not named in sequence such as image01.png , image02.png etc. They are named as timestamp_as_longinteger.png . So inorder to allow x264 to accept these images as input, I have to rename all of them ( i make a symbolic link for all images in a new folder ). This approach is again unsatisfactory, because I need more flexibility in selecting/unselecting files which would be converted to a video. Right now my approach is a hack.

    The best solution is x264. But not sure how I can send it an image sequence from Java. That too, images which are not named in sequential fashion.


    BTW The purpose of making video is going back in time, and finding out how time was spend/wasted.
    The software is aware of what the user is doing. So using this I can find out (visually) how a class evolved with time. How much time I spend on a particular class/package/module/project/customer. The granuality right now is upto the class level, I wish to take it to the function level. The software is called jitendriya.

    Here is a sample graph


    Here is 1 solution
    How does one encode a series of images into H264 using the x264 C API ?

    But this is for C. If I have to do the same in java, and in a cross plaform fashion, I will have to resort to JNA/JNI. JNA might have a significant performance hit. JNI would be more work.
    FFMpeg also looks like a nice alternative, but I am still not satisfied by any of these solutions looking at the pros and cons.


    Solution Adapted.

    package weeklyvideomaker;

    import java.awt.AWTException;
    import java.awt.Rectangle;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.util.Calendar;
    import java.util.LinkedList;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import neembuu.release1.util.StreamGobbler;
    import org.shashaank.activitymonitor.ScreenCaptureHandler;
    import org.shashaank.jitendriya.JitendriyaParams;

    /**
    *
    * @author Shashank
    */
    public class DirectVideoScreenHandler implements ScreenCaptureHandler {
       private final JitendriyaParams  jp;

       private String extension="264";
       private boolean lossless=false;
       private String fps="24/1";

       private Process p = null;
       private Rectangle r1;
       private Robot r;

       private int currentDay;

       private static final String[]weeks={"sun","mon","tue","wed","thu","fri","sat"};

       public DirectVideoScreenHandler(JitendriyaParams jp) {
           this.jp = jp;
       }

       public String getExtension() {
           return extension;
       }

       public void setExtension(String extension) {
           this.extension = extension;
       }

       public boolean isLossless() {
           return lossless;
       }

       public void setLossless(boolean lossless) {
           this.lossless = lossless;
       }

       public String getFps() {
           return fps;
       }

       public void setFps(String fps) {
           this.fps = fps;
       }

       private static int getday(){
           return Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1;
       }

       public void make()throws IOException,AWTException{
           currentDay = getday();
           File week = jp.getWeekFolder();

           String destinationFile = week+"\\videos\\"+weeks[currentDay]+"_"+System.currentTimeMillis()+"_direct."+extension;

           r = new Robot();
           r1 = getScreenSize();

           ProcessBuilder pb = makeProcess(destinationFile, 0, r1.width, r1.height);

           p = pb.start();
           StreamGobbler out = new StreamGobbler(p.getInputStream(), "out");
           StreamGobbler err = new StreamGobbler(p.getErrorStream(), "err");
           out.start();err.start();
       }

       private static Rectangle getScreenSize(){
           return new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
       }

       private void screenShot(OutputStream os)throws IOException{        
           BufferedImage bi = r.createScreenCapture(r1);
           int[]intRawData = ((java.awt.image.DataBufferInt)
                   bi.getRaster().getDataBuffer()).getData();
           byte[]rawData = new byte[intRawData.length*3];
           for (int i = 0; i < intRawData.length; i++) {
               int rgb = intRawData[i];
               rawData[ i*3 + 0 ] = (byte) (rgb >> 16);
               rawData[ i*3 + 1 ] = (byte) (rgb >> 8);
               rawData[ i*3 + 2 ] = (byte) (rgb);
           }
           os.write(rawData);
       }

       private ProcessBuilder makeProcess(String destinationFile, int numberOfFrames,
               int width, int height){
           LinkedList<string> commands = new LinkedList&lt;>();
           commands.add("\""+encoderPath()+"\"");
           if(true){
               commands.add("-");
               if(lossless){
                   commands.add("--qp");
                   commands.add("0");
               }
               commands.add("--keyint");
               commands.add("240");
               commands.add("--sar");
               commands.add("1:1");
               commands.add("--output");
               commands.add("\""+destinationFile+"\"");
               if(numberOfFrames>0){
                   commands.add("--frames");
                   commands.add(String.valueOf(numberOfFrames));
               }else{
                   commands.add("--stitchable");
               }
               commands.add("--fps");
               commands.add(fps);
               commands.add("--input-res");
               commands.add(width+"x"+height);
               commands.add("--input-csp");
               commands.add("rgb");//i420
           }
           return new ProcessBuilder(commands);
       }

       private String encoderPath(){
           return jp.getToolsPath()+File.separatorChar+"x264_64.exe";
       }

       @Override public void run() {
           try {
               if(p==null){
                   make();
               }
               if(currentDay!=getday()){// day changed
                   destroy();
                   return;
               }
               if(!r1.equals(getScreenSize())){// screensize changed
                   destroy();
                   return;
               }
               screenShot(p.getOutputStream());
           } catch (Exception ex) {
               Logger.getLogger(DirectVideoScreenHandler.class.getName()).log(Level.SEVERE, null, ex);
           }
       }

       private void destroy()throws Exception{
           p.getOutputStream().flush();
           p.getOutputStream().close();
           p.destroy();
           p = null;
       }

    }
    </string>

    package weeklyvideomaker;

    import org.shashaank.jitendriya.JitendriyaParams;

    /**
    *
    * @author Shashank
    */
    public class DirectVideoScreenHandlerTest {
       public static void main(String[] args)throws Exception {
           JitendriyaParams  jp = new JitendriyaParams.Builder()
                   .setToolsPath("F:\\GeneralProjects\\JReminder\\development_environment\\tools")
                   .setOsDependentDataFolderPath("J:\\jt_data")
                   .build();
           DirectVideoScreenHandler w = new DirectVideoScreenHandler(jp);
           w.setExtension("264");
           w.setFps("24/1");
           w.setLossless(false);
           w.make();

           for (int i = 0; ; i++) {
               w.run();
               Thread.sleep(1000);
           }
       }
    }
  • Ffmpeg set duration using node-fluent-ffmpeg

    23 mai 2013, par Vprnl

    I'm really new to the world of ffmpeg so please excuses me if this is a stupid queston.

    I'm using the module Node-fluent-ffmpeg to stream a movie and convert it from avi to webm.
    So far so good (it plays the video), but I'm having trouble parsing the duration to the player. My ultimate goal is to be able to skip ahead in the movie. But first the player needs to know how long the video is.

    my code is as followed :

    var stat = fs.statSync(movie);

    var start = 0;
    var end = 0;
    var range = req.header(&#39;Range&#39;);
    if (range != null) {
    start = parseInt(range.slice(range.indexOf(&#39;bytes=&#39;)+6,
     range.indexOf(&#39;-&#39;)));
    end = parseInt(range.slice(range.indexOf(&#39;-&#39;)+1,
     range.length));
    }
    if (isNaN(end) || end == 0) end = stat.size-1;
    if (start > end) return;

    res.writeHead(206, { // NOTE: a partial http response
       &#39;Connection&#39;:&#39;close&#39;,
       &#39;Content-Type&#39;:&#39;video/webm&#39;,
       &#39;Content-Length&#39;:end - start,
       &#39;Content-Range&#39;:&#39;bytes &#39;+start+&#39;-&#39;+end+&#39;/&#39;+stat.size,
       &#39;Transfer-Encoding&#39;:&#39;chunked&#39;
    });

    var  proc = new ffmpeg({ source: movie, nolog: true, priority: 1, timeout:15000})
       .toFormat(&#39;webm&#39;)
       .withVideoBitrate(&#39;1024k&#39;)
       .addOptions([&#39;-probesize 900000&#39;, &#39;-analyzeduration 0&#39;, &#39;-bufsize 14000&#39;])
       .writeToStream(res, function(retcode, error){
       if (!error){
           console.log(&#39;file has been converted succesfully&#39;,retcode);
       }else{
           console.log(&#39;file conversion error&#39;,error);
       }
    });

    I tried to set the header with a start and a end based on this article : http://delog.wordpress.com/2011/04/25/stream-webm-file-to-chrome-using-node-js/

    I also looked in the FFmpeg documentation and found -f duration and -ss.
    But I don't quite know how to convert the byte range to seconds.

    I feel like I'm pretty close to a solution but my inexperience with the subject matter prohibits me from getting it to work. If I'm unclear in any way please let me know. (I have a tendency of explaining things fuzzy.)

    Thanks in advance !

  • Traceback error with Python when using ffmpeg to convert a video

    16 mai 2013, par TheMickeyNick

    The simple way my script runs is the user provides a folder location and a filetype and glob.glob() finds the files with the filetype provided and adds them to a list. It then uses a for loop and goes through the list and converts each video. But it doesn't like when I try to run my ffmpeg command. Any help would be awesome. I'm also using Win 7 64 bit with 64 bit ffmpeg and Python 3.3
    Here's the error :

    OS Error
    Traceback (most recent call last):
     File "C:\Python33\lib\subprocess.py", line 1106, in _execute_child
       startupinfo)
    FileNotFoundError: [WinError 2] The system cannot find the file specified

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
     File "C:\Users\user\Workspace\PythonConverter\HTMLandPythonConverter\Converter.py", line 77, in <module>
       massConvert(fileNames)
     File "C:\Users\user\Workspace\PythonConverter\HTMLandPythonConverter\Converter.py", line 47, in massConvert
       convertVideotoNewFormat(&#39;.mp4&#39;, x)
     File "C:\Users\user\Workspace\PythonConverter\HTMLandPythonConverter\Converter.py", line 61, in convertVideotoNewFormat
       myFile = subprocess.Popen(ffmpegString)#, stdout=subprocess.PIPE, stderr=subprocess.PIPE
     File "C:\Python33\lib\subprocess.py", line 820, in __init__
       restore_signals, start_new_session)
     File "C:\Python33\lib\subprocess.py", line 1112, in _execute_child
       raise WindowsError(*e.args)
    FileNotFoundError: [WinError 2] The system cannot find the file specified
    </module>

    Here is my code :

    import subprocess
    from subprocess import call
    import glob

    fileNames = []
    fileLocation = {}
    filetype = {}
    def convertString(location):
       s = list(location)
       for i in range(len(s)):
           if s[i] in &#39;\\&#39;:
               s[i] = &#39;/&#39;

       if s[len(s)-1] != &#39;/&#39;:
           s.append(&#39;/&#39;)
       location = "".join(s)
       return location

    def convertStringBack(stringTo):
       s = list(stringTo)
       for i in range(len(s)):
           if s[i] in &#39;/&#39;:
               s[i] = &#39;\\&#39;
       stringTo = "".join(s)
       return stringTo

    def fileTypeTester():
       FieldType = &#39;*&#39; + input(&#39;What\&#39;s the file type we are converting from?&#39;)
       typeSplit = list(FieldType)
       if typeSplit[1] != &#39;.&#39;:
           typeSplit.insert(1,&#39;.&#39;)
       FieldType = "".join(typeSplit)
       if FieldType not in [&#39;*.flv&#39;,&#39;*.kdb&#39;]:
           print(&#39;Not a valid file type&#39;)
       else:
           return FieldType
       return None

    def massConvert(listOfFiles):
       print(&#39;Starting Conversion&#39;)
       for x in listOfFiles:
           #x = convertStringBack(x)
           print(&#39;Converting &#39; + x + &#39; to .mp4&#39;)
           convertVideotoNewFormat(&#39;.mp4&#39;, x)
       print(&#39;Finished File Conversion&#39;)


    def convertVideotoNewFormat(newFormat, fileLoc):
       newFilePath = fileLoc[0:len(fileLoc)-4]
       ffmpegString = ["ffmpeg64","-i", fileLoc,"-qscale","0","-ar","22050","-vcodec","libx264",newFilePath,newFormat]
       try:
           subprocess.check_call(newFilePath)
       except OSError:
           print(&#39;OS Error&#39;)
       except subprocess.CalledProcessError:
           print(&#39;Subprocess Error&#39;)
       myFile = subprocess.Popen(ffmpegString)
       print(myFile)

    #This will replace old HTML flv object tag with new video tag, but it is yet to be implemented
    def replaceHTML():
       pass

    fileLocation = input(&#39;What is the path of the files you\&#39;d like to convert?&#39;)
    fileLocation = convertString(fileLocation)
    fileType = fileTypeTester()
    fileNames = glob.glob(fileLocation + fileType)
    massConvert(fileNames)

    I've looked around and most of the tutorials are in 2.7 the code is 3.3 and I can't find a tutorial to use ffmpeg for 3.3. My ffmpeg is set to 'ffmpeg64' on my PATH.

    Thanks !