Recherche avancée

Médias (2)

Mot : - Tags -/rotation

Autres articles (72)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

Sur d’autres sites (7169)

  • FFmpeg Javacv - Latency Issue

    24 décembre 2019, par cagney

    I am using an android v21 device to stream data to a javafx application. Its working fine but I have about 2 seconds of latency.

    As of now the basic transportation goes like this

    1. android webrtc/custom implementation 16ms
    2. android packetizer(udp) 6 ms
    3. udp transport assumed at < 5ms
    4. windows depacketizer no buildup of data in buffers
    5. windows ffmpeg framgrabber unkown latency
    6. javafx imageview <1 ms

    My data stream to my desktop and my packetizer is much faster than my frame rate and is often just waiting. There is no buildup of data anywhere else and therefore I assume no delay in any of my code.

    I tested my android device by writing the yuv from camera to a texture and timing how long before the android device can encode the frame into h264 and then how long until its sent. so 16 + 6 = 22ms

    I feel the problem is with the Javacv ffmpeg framegrabber. Im studying this api in order to learn why this is occurring.

    My major concern is that framegrabber takes foever to start...around 4 seconds.

    Once it start I can clearly see how many frames I insert and how many its grabbing and it always lagging by some large number such as 40 up to 200.

    Also Framegrabber.grab() is blocking and runs every 100ms to match my frame rate no matter how fast I tell it to run so I can never catch up.

    Do you have any suggestions ?

    Im starting to think javacv is not a viable solution because it seems many people struggle with this delay issue. If you have alternate suggestions please advise.

    My ffmpeg framgrabber

       public RapidDecoder(final InputStream inputStream, final ImageView view)
    {
       System.out.println(TAG + " starting");

        grabber = new FFmpegFrameGrabber(inputStream, 0);
        converter = new Java2DFrameConverter();
        mView = view;


       emptyBuffer = new Runnable() {
           @Override
           public void run() {
               System.out.println(TAG + " emptybuffer thread running");
               try {

                   grabber.setFrameRate(12);
                   grabber.setVideoBitrate(10000);

                   //grabber.setOption("g", "2");
                  // grabber.setOption("bufsize", "10000");
                   //grabber.setOption("af", "delay 20");
                   //grabber.setNumBuffers(0);
                   //grabber.setOption("flush_packets", "1");
                   //grabber.setOption("probsize", "32");
                   //grabber.setOption("analyzeduration", "0");
                   grabber.setOption("preset", "ultrafast");

                   grabber.setOption("fflags", "nobuffer");
                   //grabber.setVideoOption("nobuffer", "1");
                   //grabber.setOption("fflags", "discardcorrupt");
                   //grabber.setOption("framedrop", "\\");
                  //grabber.setOption("flags","low_delay");
                   grabber.setOption("strict","experimental");
                   //grabber.setOption("avioflags", "direct");
                   //grabber.setOption("filter:v", "fps=fps=30");
                   grabber.setVideoOption("tune", "zerolatency");
                   //grabber.setFrameNumber(60);


                   grabber.start();
               }catch (Exception e)
               {
                   System.out.println(TAG + e);
               }

               while (true)
               {

                   try{
                       grabFrame();
                       Thread.sleep(1);
                   }catch (Exception e)
                   {
                       System.out.println(TAG + " emptybuffer " + e);
                   }

               }



           }
       };

       display = new Runnable() {
           @Override
           public void run() {

               System.out.println(TAG + " display thread running ");

               while(true)
               {

                   try{
                       displayImage();
                       Thread.sleep(10);
                   }catch (Exception e)
                   {
                       System.out.println(TAG + " display " + e);
                   }

               }


           }
       };




    }


    public void generateVideo()
    {
       System.out.println(TAG + " genvid ");




       new Thread(emptyBuffer).start();
       new Thread(display).start();



    }



    public synchronized void grabFrame() throws FrameGrabber.Exception
    {
              //frame = grabber.grabFrame();
           frame = grabber.grab();
       //System.out.println("grab");


    }

    public synchronized void displayImage()
    {


       bufferedImage = converter.convert(frame);
       frame = null;
       if (bufferedImage == null) return;
       mView.setImage(SwingFXUtils.toFXImage(bufferedImage, null));
       //System.out.println("display");
    }

    here you can see i draw texture with image and send to h264 encoder

    @Override
    public void onTextureFrameCaptured(int width, int height, int texId, float[] tranformMatrix, int rotation, long timestamp)
    //Log.d(TAG, "onTextureFrameCaptured : ->") ;

               VideoRenderer.I420Frame frame = new VideoRenderer.I420Frame(width, height, rotation, texId, tranformMatrix, 0,timestamp);
               avccEncoder.renderFrame(frame);
               videoView.renderFrame(frame);
               surfaceTextureHelper.returnTextureFrame();

           }

    Here you can see webrtc encoding happen

    @Override
       public void renderFrame(VideoRenderer.I420Frame i420Frame) {
           start = System.nanoTime();
           bufferque++;

           mediaCodecHandler.post(new Runnable() {
               @Override
               public void run() {
                   videoEncoder.encodeTexture(false, i420Frame.textureId, i420Frame.samplingMatrix, TimeUnit.NANOSECONDS.toMicros(i420Frame.timestamp));
               }
           });


       }

       /**
        * Called to retrieve an encoded frame
        */
       @Override
       public void onEncodedFrame(MediaCodecVideoEncoder.OutputBufferInfo frame, MediaCodec.BufferInfo bufferInfo) {

           b = new byte[frame.buffer().remaining()];
           frame.buffer().get(b);
           synchronized (lock)
           {
               encodedBuffer.add(b);
               lock.notifyAll();
               if(encodedBuffer.size() > 1)
               {
                   Log.e(TAG, "drainEncoder: too big: " + encodedBuffer.size(),null );

               }
           }
           duration = System.nanoTime() - start;
           bufferque--;
           calcAverage();
           if (bufferque > 0)
           {
           Log.d(TAG, "onEncodedFrame: bufferque size: " + bufferque);


       }

    }
  • IJG swings again, and misses

    1er février 2010, par Mans — Multimedia

    Earlier this month the IJG unleashed version 8 of its ubiquitous libjpeg library on the world. Eager to try out the “major breakthrough in image coding technology” promised in the README file accompanying v7, I downloaded the release. A glance at the README file suggests something major indeed is afoot :

    Version 8.0 is the first release of a new generation JPEG standard to overcome the limitations of the original JPEG specification.

    The text also hints at the existence of a document detailing these marvellous new features, and a Google search later a copy has found its way onto my monitor. As I read, however, my state of mind shifts from an initial excited curiosity, through bewilderment and disbelief, finally arriving at pure merriment.

    Already on the first page it becomes clear no new JPEG standard in fact exists. All we have is an unsolicited proposal sent to the ITU-T by members of the IJG. Realising that even the most brilliant of inventions must start off as mere proposals, I carry on reading. The summary informs me that I am about to witness the introduction of three extensions to the T.81 JPEG format :

    1. An alternative coefficient scan sequence for DCT coefficient serialization
    2. A SmartScale extension in the Start-Of-Scan (SOS) marker segment
    3. A Frame Offset definition in or in addition to the Start-Of-Frame (SOF) marker segment

    Together these three extensions will, it is promised, “bring DCT based JPEG back to the forefront of state-of-the-art image coding technologies.”

    Alternative scan

    The first of the proposed extensions introduces an alternative DCT coefficient scan sequence to be used in place of the zigzag scan employed in most block transform based codecs.

    Alternative scan sequence

    Alternative scan sequence

    The advantage of this scan would be that combined with the existing progressive mode, it simplifies decoding of an initial low-resolution image which is enhanced through subsequent passes. The author of the document calls this scheme “image-pyramid/hierarchical multi-resolution coding.” It is not immediately obvious to me how this constitutes even a small advance in image coding technology.

    At this point I am beginning to suspect that our friend from the IJG has been trapped in a half-world between interlaced GIF images transmitted down noisy phone lines and today’s inferno of SVC, MVC, and other buzzwords.

    (Not so) SmartScale

    Disguised behind this camel-cased moniker we encounter a method which, we are told, will provide better image quality at high compression ratios. The author has combined two well-known (to us) properties in a (to him) clever way.

    The first property concerns the perceived impact of different types of distortion in an image. When encoding with JPEG, as the quantiser is increased, the decoded image becomes ever more blocky. At a certain point, a better subjective visual quality can be achieved by down-sampling the image before encoding it, thus allowing a lower quantiser to be used. If the decoded image is scaled back up to the original size, the unpleasant, blocky appearance is replaced with a smooth blur.

    The second property belongs to the DCT where, as we all know, the top-left (DC) coefficient is the average of the entire block, its neighbours represent the lowest frequency components etc. A top-left-aligned subset of the coefficient block thus represents a low-resolution version of the full block in the spatial domain.

    In his flash of genius, our hero came up with the idea of using the DCT for down-scaling the image. Unfortunately, he appears to possess precious little knowledge of sampling theory and human visual perception. Any block-based resampling will inevitably produce sharp artefacts along the block edges. The human visual system is particularly sensitive to sharp edges, so this is one of the most unwanted types of distortion in an encoded image.

    Despite the obvious flaws in this approach, I decided to give it a try. After all, the software is already written, allowing downscaling by factors of 8/8..16.

    Using a 1280×720 test image, I encoded it with each of the nine scaling options, from unity to half size, each time adjusting the quality parameter for a final encoded file size of no more than 200000 bytes. The following table presents the encoded file size, the libjpeg quality parameter used, and the SSIM metric for each of the images.

    Scale Size Quality SSIM
    8/8 198462 59 0.940
    8/9 196337 70 0.936
    8/10 196133 79 0.934
    8/11 197179 84 0.927
    8/12 193872 89 0.915
    8/13 197153 92 0.914
    8/14 188334 94 0.899
    8/15 198911 96 0.886
    8/16 197190 97 0.869

    Although the smaller images allowed a higher quality setting to be used, the SSIM value drops significantly. Numbers may of course be misleading, but the images below speak for themselves. These are cut-outs from the full image, the original on the left, unscaled JPEG-compressed in the middle, and JPEG with 8/16 scaling to the right.

    Looking at these images, I do not need to hesitate before picking the JPEG variant I prefer.

    Frame offset

    The third and final extension proposed is quite simple and also quite pointless : a top-left cropping to be applied to the decoded image. The alleged utility of this feature would be to enable lossless cropping of a JPEG image. In a typical image workflow, however, JPEG is only used for the final published version, so the need for this feature appears quite far-fetched.

    The grand finale

    Throughout the text, the author makes references to “the fundamental DCT property for image representation.” In his own words :

    This property was found by the author during implementation of the new DCT scaling features and is after his belief one of the most important discoveries in digital image coding after releasing the JPEG standard in 1992.

    The secret is to be revealed in an annex to the main text. This annex quotes in full a post by the author to the comp.dsp Usenet group in a thread with the subject why DCT. Reading the entire thread proves quite amusing. A few excerpts follow.

    The actual reason is much simpler, and therefore apparently very difficult to recognize by complicated-thinking people.

    Here is the explanation :

    What are people doing when they have a bunch of images and want a quick preview ? They use thumbnails ! What are thumbnails ? Thumbnails are small downscaled versions of the original image ! If you want more details of the image, you can zoom in stepwise by enlarging (upscaling) the image.

    So with proper understanding of the fundamental DCT property, the MPEG folks could make their videos more scalable, but, as in the case of JPEG, they are unable to recognize this simple but basic property, unfortunately, and pursue rather inferior approaches in actual developments.

    These are just phrases, and they don’t explain anything. But this is typical for the current state in this field : The relevant people ignore and deny the true reasons, and thus they turn in a circle and no progress is being made.

    However, there are dark forces in action today which ignore and deny any fruitful advances in this field. That is the reason that we didn’t see any progress in JPEG for more than a decade, and as long as those forces dominate, we will see more confusion and less enlightenment. The truth is always simple, and the DCT *is* simple, but this fact is suppressed by established people who don’t want to lose their dubious position.

    I believe a trip to the Total Perspective Vortex may be in order. Perhaps his tin-foil hat will save him.

  • Revision 30993 : on force les dernières versions, notamment pour bonux, sinon ça crée des ...

    18 août 2009, par vincent@… — Log

    on force les dernières versions, notamment pour bonux, sinon ça crée des gros bugs