Recherche avancée

Médias (0)

Mot : - Tags -/interaction

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (73)

  • MediaSPIP Core : La Configuration

    9 novembre 2010, par

    MediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
    Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (7612)

  • ffmpeg YUV to RGB distored color and position

    15 novembre 2012, par user1542140

    Sorry that I still cannot post images for my question since low reputation.

    I use the ffmpeg function to convert the decoded frame, from YUV to RGB24, but the color and resulted image is distorted seriously. Following is my code snip, the frame width and height is (176, 144)

    len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
       if (got_picture) {
               //...

       AVFrame *pFrameRGB = avcodec_alloc_frame();
       // Determine required buffer size and allocate buffer
       int numBytes=avpicture_get_size(PIX_FMT_RGB24, c->width, c->height);
       uint8_t *buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
       avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24, c->width, c->height);

       struct SwsContext *img_convert_ctx = sws_getContext(c->width, c->height, PIX_FMT_YUV420P, c->width, c->height, PIX_FMT_BGR24, SWS_BICUBIC, NULL, NULL, NULL);
       sws_scale(img_convert_ctx, picture->data, picture->linesize, 0, picture->height, pFrameRGB->data, pFrameRGB->linesize);
       sws_freeContext(img_convert_ctx);
       // Save the frame to disk
       if(++frame<=5)
           SaveFrame(pFrameRGB, c->width, c->height, frame);
  • FFmpeg : avcodec_encode_video() and JPEG images

    2 février 2012, par user105909

    I'm trying to encode a series of .jpg files into a video using the ffmpeg library, and I can't seem to get the frames to encode. (I have to use the ffmpeg library, and using ffmpeg from a command line is not an option in my case.)

    Except for the part where I'm trying to open JPG files as AVFrames, my code is more or less the same thing as found in api-example.c from the ffmpeg library. When I populate the frames as the example does, everything works as expected. In the code below, I fail to encode any frames. Obviously the trouble is related to how I'm opening the JPG files, but I can't figure out what.

    I'm opening the image like this :

    AVFrame* open_image(const char* imageFileName, int width, int height, long * bufSize)
    {
       AVFormatContext *pFormatCtx;

       if(av_open_input_file(&pFormatCtx, imageFileName, NULL, 0, NULL)!=0)
       {
           printf("Can't open image file '%s'\n", imageFileName);
           return NULL;
       }      

       AVCodecContext *pCodecCtx;

       pCodecCtx = pFormatCtx->streams[0]->codec;
       pCodecCtx->width = width;
       pCodecCtx->height = height;
       pCodecCtx->pix_fmt = PIX_FMT_YUV420P;

       // Find the decoder for the video stream
       AVCodec *pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
       if (!pCodec)
       {
           printf("Codec not found\n");
           return NULL;
       }

       // Open codec
       if(avcodec_open(pCodecCtx, pCodec)<0)
       {
           printf("Could not open codec\n");
           return NULL;
       }

       AVFrame *pFrame = avcodec_alloc_frame();
       if (!pFrame)
       {
           LOGV(TAG, "Can't allocate memory for AVFrame\n");
           return NULL;
       }

       int frameFinished;
       int numBytes;

       // Determine required buffer size and allocate buffer
       numBytes = avpicture_get_size(PIX_FMT_YUVJ420P, pCodecCtx->width, pCodecCtx->height);

       // ***
       *bufSize = numBytes;
       // ***

       uint8_t *buffer = (uint8_t *) av_malloc(numBytes * sizeof(uint8_t));

       avpicture_fill((AVPicture *) pFrame, buffer, PIX_FMT_YUVJ420P, pCodecCtx->width, pCodecCtx->height);

       // Read frame

       AVPacket packet;

       int framesNumber = 0;
       while (av_read_frame(pFormatCtx, &packet) >= 0)
       {
           if(packet.stream_index != 0)
               continue;

           int ret = avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
           if (ret > 0)
           {
               sprintf(buf, "Frame is decoded, size %d", ret);
               LOGV(TAG, buf);
               pFrame->quality = 4;
               return pFrame;
           }
           else {
               // printf("Error [%d] while decoding frame: %s\n", ret, strerror(AVERROR(ret)));
               sprintf(buf, "Error %d decoding frame: %s", ret, strerror(AVERROR(ret)));
               LOGV(TAG, buf);
           }
       }
    }

    ...and attempting to encode them like this :

    DIR * dir = opendir(path);
    int i = 0;

    if (dir != NULL) {

       for(struct dirent *ent = readdir(dir); ent != NULL; ent = readdir(dir)) {
           fflush(stdout);

           printf("%s/%s", path, ent->d_name);
           LOGV(TAG, filename);

           // If not a jpg file, pass it over
           const char * ext = strrchr(filename, '.');
           if((!ext) || (strcmp(ext, ".jpg"))) {
               continue;
           }

           /*** NOTE: Is this where I've gone wrong? Bufsize is set in open_image based on av_picture_size() */
           long bufSize = 0L;
           AVFrame * frame = open_image(filename, width, height, &bufSize);
           if(frame) {
               // This is what it needs to do, and it does not work.
               // Causes:
               // Wrong format?
               // Wrong buffer size?
               uint8_t * picBuf = (uint8_t *)malloc(bufSize);

               out_size = avcodec_encode_video(c, picBuf, bufSize, frame);

               printf("encoding frame %3d (size=%5d)\n", i++, out_size);
               /** On the first image, out_size is 0. On the next, it's -1, and fails. */

               if(out_size < 0) {
                   printf("Error encoding frame");
                   return -6;
               }

               fwrite(picBuf, 1, bufSize, f);

               free(picBuf);
               av_free(frame);
           }
           else {
               printf("Couldn't open image");
               return -5;
           }
       }

       closedir(dir);
    }
    else {
       printf("Couldn't open directory %s\n", path);
       return -4;
    }

    Could someone point me in the right direction ?

  • Use imagick->pingImage to retrieve the image dimensions.

    14 octobre 2013, par blueimp
    Use imagick->pingImage to retrieve the image dimensions.
    

    Delegate to the get_image_size method to determine the image validity.