Recherche avancée

Médias (91)

Autres articles (65)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, 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 (...)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

Sur d’autres sites (8658)

  • Xuggler decode H264 packets

    18 novembre 2015, par Roy Bean

    I’m making a test with xuggler, and I’m observing a behavior that I don’t understand.

    So I have a H264 frame, stored in a file and I want to decode it.
    Bassically I need of the IVideoPicture to then get a buffred image.

    for the same same packet I need of 10 tries until it retrieved that the IVideoPicture is complete.

    this is what ffmpeg does when reads the frame :

    Input #0, h264, from 'sample1.jpg':
    Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuv420p, 352x288, 25 tbr, 1200k tbn, 50 tbc

    Can someone of xuggler or ffmpeg knowledge explain what is happen ?

    My code bellow :

    IContainer container = IContainer.make();

    RandomAccessFile aFile = new RandomAccessFile("c://sample1Frame/sample1.jpg","r");
    IContainerFormat format = IContainerFormat.make();
    format.setInputFormat("h264");
    container.open(aFile, IContainer.Type.READ, null);
    int numStreams = container.getNumStreams();


    IStreamCoder videoCoder = null;
    for(int i = 0; i < numStreams; i++)
    {
       IStream stream = container.getStream(i);
       // Get the pre-configured decoder that can decode this stream;
       IStreamCoder coder = stream.getStreamCoder();
       if(coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO)
       {
           System.out.println("coder");
       }
       videoCoder = coder;
    }

    // The timebase here is used as the camera frame rate    
    videoCoder.setTimeBase(IRational.make(25,1));

    // we need to tell the driver what video with and height to use
    videoCoder.setWidth(352);
    videoCoder.setHeight(288);

    if(videoCoder.open(null , null) < 0){
       System.err.println("Could not open video decoder for input container");
       return;
    }
    //      videoCoder.setFlag(IStreamCoder.Flags.FLAG_QSCALE,true);
    //      videoCoder.setFlag(IStreamCoder.Flags.FLAG2_FAST,true);

    IPacket packet = IPacket.make();
    //      long firstTimestampInStream = Global.NO_PTS;
    //      long systemClockStartTime = 0;
    int complete = 1;


    while(container.readNextPacket(packet) >= 0){
       int trys= 1;
       System.out.println("PCK = ");
       while(true)
       {
           trys++;
           System.out.println("trys = " + trys);
           System.out.println("packet " + packet.getSize());
           IVideoPicture picture = IVideoPicture.make(videoCoder.getPixelType(), videoCoder.getWidth(), videoCoder.getHeight());


           //TODO
           int offset = 0;
           while(offset < packet.getSize())
           {
               /*
                * Now, we decode the video, checking for any errors.
                *
                */
               System.out.println("packet getTimeBase " + packet.getTimeBase());
               System.out.println("vc getTimeBase " + videoCoder.getTimeBase());
               System.out.println("vc getCodecID " + videoCoder.getCodecID().toString());
               int bytOffset = videoCoder.decodeVideo(picture, packet, offset);
               Logger.getLogger(VideoSamsung.class.getName()).log(Level.SEVERE,"bytOffset =  " + bytOffset);

               if(bytOffset < 0){
                   //                  videoCoder.close();
                   //                  //                  picture.setComplete(true, com.xuggle.xuggler.IPixelFormat.Type.YUV420P, 352, 288, packet.getPts());
                   //                  System.err.println("picture.isComplete()"+picture.isComplete());
                   //                                      BufferedImage sdf = Utils.videoPictureToImage(picture);
                   //                                      File outputfile = new File("c://sdf/image.jpg");
                   //                                      ImageIO.write(sdf, "jpg", outputfile);
                   Logger.getLogger(VideoSamsung.class.getName()).log(Level.SEVERE,"BUMMMMMM!!!!!!!!!!!!!!!!!!!");
                   break;
               }else{
                   //System.out.println(DatatypeConverter.printBase64Binary(videoCoder.getExtraData().getByteArray(0, videoCoder.getExtraData().getSize())));
               }
               offset += bytOffset;
               System.err.println("picture.isComplete()"+picture.isComplete());

               /*
                * Some decoders will consume data in a packet, but will not be able to construct
                * a full video picture yet.  Therefore you should always check if you
                * got a complete picture from the decoder
                */

           }//end while(offset < packet.getSize())

           if (picture.isComplete())
           {
               System.out.println("isComplete");
               IVideoPicture newPic = picture;
               BufferedImage sdf = Utils.videoPictureToImage(picture);
               File outputfile = new File("c://sdf/image_"+complete+".jpg");
               ImageIO.write(sdf, "jpg", outputfile);
               complete++;
               System.out.println("trys = " + trys);
               break;
               //              System.exit(0);
           }else{
               System.out.println("Picture is not Complete");
           }

           if(trys > 20){
               System.out.println("FAIL!!!!!!!!!!  trys = " + trys);
               break;
           }
       }
    }
    /*
    * Technically since we're exiting anyway, these will be cleaned up by
    * the garbage collector... but because we're nice people and want
    * to be invited places for Christmas, we're going to show how to clean up.
    */
    if (videoCoder != null)
    {
       videoCoder.close();
       videoCoder = null;
    }
    if (container !=null)
    {
       container.close();
       container = null;
    }

    the console output :

       PCK =
    trys = 2
    packet 1748
    packet getTimeBase 1/1200000
    vc getTimeBase 25/1
    vc getCodecID CODEC_ID_H264
    Nov 18, 2015 5:39:11 PM filepath main
    SEVERE: bytOffset =  1748
    Picture is not Complete
    trys = 3
    packet 1748
    packet getTimeBase 1/1200000
    vc getTimeBase 25/1
    vc getCodecID CODEC_ID_H264
    picture.isComplete()false
    Nov 18, 2015 5:39:11 PM filepath main
    SEVERE: bytOffset =  1748
    Picture is not Complete
    picture.isComplete()false
    trys = 4
    packet 1748
    packet getTimeBase 1/1200000
    vc getTimeBase 25/1
    vc getCodecID CODEC_ID_H264
    Nov 18, 2015 5:39:11 PM filepath main
    SEVERE: bytOffset =  1748
    picture.isComplete()false
    Picture is not Complete
    trys = 5
    packet 1748
    packet getTimeBase 1/1200000
    vc getTimeBase 25/1
    vc getCodecID CODEC_ID_H264
    Nov 18, 2015 5:39:11 PM filepath main
    SEVERE: bytOffset =  1748
    picture.isComplete()false
    Picture is not Complete
    trys = 6
    packet 1748
    packet getTimeBase 1/1200000
    vc getTimeBase 25/1
    vc getCodecID CODEC_ID_H264
    Nov 18, 2015 5:39:11 PM filepath main
    SEVERE: bytOffset =  1748
    picture.isComplete()false
    Picture is not Complete
    trys = 7
    packet 1748
    packet getTimeBase 1/1200000
    vc getTimeBase 25/1
    vc getCodecID CODEC_ID_H264
    Nov 18, 2015 5:39:11 PM filepath main
    SEVERE: bytOffset =  1748
    picture.isComplete()false
    Picture is not Complete
    trys = 8
    packet 1748
    packet getTimeBase 1/1200000
    vc getTimeBase 25/1
    vc getCodecID CODEC_ID_H264
    Nov 18, 2015 5:39:11 PM filepath main
    SEVERE: bytOffset =  1748
    picture.isComplete()false
    Picture is not Complete
    trys = 9
    packet 1748
    packet getTimeBase 1/1200000
    vc getTimeBase 25/1
    vc getCodecID CODEC_ID_H264
    Nov 18, 2015 5:39:11 PM filepath main
    SEVERE: bytOffset =  1748
    picture.isComplete()false
    Picture is not Complete
    trys = 10
    packet 1748
    packet getTimeBase 1/1200000
    vc getTimeBase 25/1
    vc getCodecID CODEC_ID_H264
    Nov 18, 2015 5:39:11 PM filepath main
    SEVERE: bytOffset =  1748
    picture.isComplete()true
    isComplete
    trys = 10
  • Add audio to Xuggler video stream (ffmpeg)

    11 avril 2017, par zholmes1

    I am trying to set up Facebook live video streaming in Java. I maintain a BufferedImage separately from this method which contains the image that is being streamed. I am connecting successfully and streaming the video, but Facebook takes the video down after two minutes because I am not sending audio as well. How can I add audio to this stream ?

       IContainer container = IContainer.make();
       IContainerFormat containerFormat_live = IContainerFormat.make();
       containerFormat_live.setOutputFormat("flv", streamUrl, null);
       container.setInputBufferLength(0);
       int retVal = container.open(streamUrl, IContainer.Type.WRITE, containerFormat_live);
       if (retVal < 0) {
           System.err.println("Could not open output container for live stream");
           System.exit(1);
       }


       IStream videoStream = container.addNewStream(0);
       IStreamCoder videoCoder = videoStream.getStreamCoder();
       ICodec videoCodec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_H264);
       videoCoder.setNumPicturesInGroupOfPictures(5);
       videoCoder.setCodec(videoCodec);
       videoCoder.setBitRate(200000);
       videoCoder.setPixelType(IPixelFormat.Type.YUV420P);
       videoCoder.setHeight(IMAGE_HEIGHT_PX_OUTPUT);
       videoCoder.setWidth(IMAGE_WIDTH_PX_OUTPUT);
       System.out.println("[ENCODER] video size is " + IMAGE_HEIGHT_PX_OUTPUT + "x" + IMAGE_WIDTH_PX_OUTPUT);
       videoCoder.setFlag(IStreamCoder.Flags.FLAG_QSCALE, true);
       videoCoder.setGlobalQuality(0);
       IRational frameRate = IRational.make(30, 1);
       videoCoder.setFrameRate(frameRate);

       IRational timeBase = IRational.make(frameRate.getDenominator(), frameRate.getNumerator());
       videoCoder.setTimeBase(timeBase);

    //        IStream audioStream = container.addNewStream(1);
    //        IStreamCoder audioCoder = audioStream.getStreamCoder();
    //        ICodec audioCodec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_AAC);
    //        audioCoder.setCodec(audioCodec);
    //        audioCoder.setBitRate(128 * 1024);
    //        audioCoder.setChannels(1);
    //        audioCoder.setSampleRate(44100);
    //        audioCoder.setFrameRate(IRational.make(1, 1));
    //        audioCoder.setTimeBase(timeBase);
    //
    //        IAudioResampler audioResampler = IAudioResampler.make(audioCoder.getChannels(), audioCoder.getChannels(), audioCoder.getSampleRate(), audioCoder.getSampleRate(), IAudioSamples.Format.FMT_S32, audioCoder.getSampleFormat());

       Properties props = new Properties();
       InputStream is = XugglerRtmpReferenceImpl.class.getResourceAsStream("/libx264-normal.ffpreset");
       try {
           props.load(is);
       } catch (IOException e) {
           System.err.println("You need the libx264-normal.ffpreset file from the Xuggle distribution in your classpath.");
           System.exit(1);
       }

       Configuration.configure(props, videoCoder);
    //        Configuration.configure(props, audioCoder);

       videoCoder.open();
    //        audioCoder.open();
       container.writeHeader();

    //        IAudioSamples audioSamples = IAudioSamples.make(512, audioCoder.getChannels());
    //        audioSamples.setComplete(true, 1024, audioCoder.getSampleRate(), audioCoder.getChannels(), IAudioSamples.Format.FMT_S32, 0);
    //
    //        IAudioSamples resampledAudio = IAudioSamples.make(512, audioCoder.getChannels(), IAudioSamples.Format.FMT_S32);
    //        audioResampler.resample(resampledAudio, audioSamples, 0);


       long firstTimeStamp = System.currentTimeMillis();
       long lastKeyFrameTimestamp = 0;
       long lastTimeStamp = System.currentTimeMillis();
       int i = 0;
       while (streaming) {
           //long iterationStartTime = System.currentTimeMillis();
           long now = System.currentTimeMillis();
           //convert it for Xuggler
           BufferedImage currentScreenshot = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
           currentScreenshot.getGraphics().drawImage(bufferedImage, 0, 0, null);
           //start the encoding process
           IPacket packet = IPacket.make();
           IConverter converter = ConverterFactory.createConverter(currentScreenshot, IPixelFormat.Type.YUV420P);
           long timeStamp = (now - firstTimeStamp) * 1000;
           IVideoPicture outFrame = converter.toPicture(currentScreenshot, timeStamp);

           // make sure there is a keyframe at least every 2 seconds
           if (System.currentTimeMillis() - lastKeyFrameTimestamp > 1500) {
               outFrame.setKeyFrame(true);
               lastKeyFrameTimestamp = System.currentTimeMillis();
           }
           outFrame.setQuality(0);
           videoCoder.encodeVideo(packet, outFrame, 0);
           // audioCoder.encodeAudio(packet, IAudioSamples.make(0, audioCoder.getChannels()), 0);

           outFrame.delete();
           if (packet.isComplete()) {
               container.writePacket(packet);
               System.out.println("[ENCODER] writing packet of size " + packet.getSize() + " for elapsed time " + ((timeStamp - lastTimeStamp) / 1000));
               lastTimeStamp = System.currentTimeMillis();
           }
           System.out.println("[ENCODER] encoded image " + i + " in " + (System.currentTimeMillis() - now));
           i++;
           try {
               // sleep for framerate milliseconds
               Thread.sleep(Math.max((long) (1000 / frameRate.getDouble()) - (System.currentTimeMillis() - now), 0));
           } catch (InterruptedException e) {
               e.printStackTrace();
           }
       }
       container.writeTrailer();
  • Images skipped while creating video from image sequence

    1er mai 2015, par Kiran Kumar Dash

    I am creating a video from a set of images. Below is the code written in php script :

    echo 'starts';
    $ffmpeg= "/home/irank/bin/ffmpeg";
       echo exec("$ffmpeg -f image2 -framerate 1/2 -start_number 001 -i \"/var/www/html/fftest/getthumbnail/images/kiran%03d.jpg\" -i \"/var/www/html/fftest/getthumbnail/audios/audio1.mp3\" -c:v libx264 -c:a copy -shortest  -s 1920x1080 -r 60 -vf drawtext=\"fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf:text='iRankMedia':fontsize=20:fontcolor=black:x=100:y=100\"  \"/var/www/html/fftest/getthumbnail/output/imageaudiosequencetext6.avi\" 2>&1" , $output, $return);
    if ($return!=0) {
       echo "fail";
    }
    else {
       echo "<br />$num Video succesfully created";
    }

    I have an image sequence like kiran001.jpg,kiran002.jpg and so on...but the output video shows only upto kiran009.jpg while it skips all image from kiran010.jpg onwards.

    The size and type of images are same.I can’t find the solution.please help