Recherche avancée

Médias (1)

Mot : - Tags -/biomaping

Autres articles (75)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Récupération d’informations sur le site maître à l’installation d’une instance

    26 novembre 2010, par

    Utilité
    Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
    Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...)

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

Sur d’autres sites (6793)

  • FFMPEG : Decode video in h264rgb/libx264rgb error

    9 février 2018, par Furan

    I did a small program to encode raw images in h264rgb codec with ffmpeg.
    I use this codec because I needed to encode lossless rgb images (not possible with the classic h264 codec).

    But now, I have a problem. I’m not able to decode the video generated with ffmpeg. I did a second small program for that, but I get a segfault when I reach the avcodec_decode_video2() function.

    I did all the initialisation correctly. I didn’t forget the avcodec_register_all() and av_init_packet() functions.

    Here is the code for initialisation :

     _c = NULL;
     _frame_nb = 0;

     // Register all formats and codecs
     #pragma omp critical
     {
         avcodec_register_all();
     }

     _pkt = new AVPacket;
     av_init_packet(_pkt);  // a defaut de pouvoir ecrire : pkt = av_packet_alloc();

     if(!_pkt)
         exit(1);

       _codec = avcodec_find_encoder_by_name("libx264rgb");

     if (!_codec) {
         fprintf(stderr, "codec not found\n");
         exit(1);
     }

     _c = avcodec_alloc_context3(_codec);
     if (!_c) {
         fprintf(stderr, "Could not allocate video codec context\n");
         exit(1);
     }

     _c->debug = true;
     _c->pix_fmt =  (AVPixelFormat)AV_PIX_FMT_RGB24;
     _c->width = this->_headerCam[this->_currentCam]->iNbCol;
     _c->height = this->_headerCam[this->_currentCam]->iNbLine;

     _picture = av_frame_alloc();
     if (!_picture) {
         fprintf(stderr, "Could not allocate video _picture\n");
         exit(1);
     }

     _tmp_picture = av_frame_alloc();
     if (!_tmp_picture) {
         fprintf(stderr, "Could not allocate video _tmp_picture\n");
         exit(1);
     }


         _tmp_picture->format = (AVPixelFormat)AV_PIX_FMT_RGB24;
         _tmp_picture->width = this->_headerCam[this->_currentCam]->iNbCol;
         _tmp_picture->height = this->_headerCam[this->_currentCam]->iNbLine;
         _tmp_picture->linesize[0] = this->_headerCam[this->_currentCam]->iNbCol;

     /* open it */
     if (avcodec_open2(_c, _codec, NULL) < 0) {
         fprintf(stderr, "could not open codec\n");
         exit(1);
     }

    And the decode function :

           _pkt->data = NULL;    // packet data will be allocated by the encoder
           _pkt->size = 0;

           unsigned char * inbuf;
           inbuf = (uint8_t*)av_malloc(w*h*3);

           //! read img size
           int size_img;
           fread(&size_img, sizeof(int), 1, this->_pFile);
           _pkt->size = fread(inbuf, 1, size_img, this->_pFile);

           _pkt->data = (unsigned char*)inbuf;

           if(_pkt->size)
           {
               len = avcodec_decode_video2(_c, _tmp_picture, &got_picture, _pkt);
               ...
           }

    Any idea ?

  • A newbie Struggling with FFmpeg Video Encoding

    19 avril 2014, par iJose

    From last 1 week i have been struggling with FFmpeg video encoding.
    I am capturing the video from the device camera using UIImagePickerController.
    and the encoding it using the following function.

    After Encoding i am not able to save the video to my device camera roll.

    i used UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(filepath) it returns Zero GOD KNOWS WHY

    +(void)videoEncoder:(NSString *)filename
    {
       avcodec_register_all();
       int codec_id = AV_CODEC_ID_MPEG4;
       AVCodec *codec;
       AVCodecContext *c= NULL;
       int i, ret, x, y, got_output;
       FILE *f;
       AVFrame *frame;
       AVPacket pkt;
       uint8_t endcode[] = { 0, 0, 1, 0xb7 };

       printf("Encode video file %s\n", [filename UTF8String]);

       /* find the mpeg1 video encoder */
       codec = avcodec_find_encoder(codec_id);
       if (!codec) {
           fprintf(stderr, "Codec not found\n");
           exit(1);
       }

       c = avcodec_alloc_context3(codec);
       if (!c) {
           fprintf(stderr, "Could not allocate video codec context\n");
           exit(1);
       }

       /* put sample parameters */
       c->bit_rate = 400000;
       /* resolution must be a multiple of two */
       c->width = 352;
       c->height = 288;
       /* frames per second */
       c->time_base= (AVRational){1,25};
       c->gop_size = 10; /* emit one intra frame every ten frames */
       c->max_b_frames=1;
       c->pix_fmt = AV_PIX_FMT_YUV420P;

       if(codec_id == AV_CODEC_ID_MPEG4)
           av_opt_set(c->priv_data, "preset", "slow", 0);

       /* open it */
       if (avcodec_open2(c, codec, NULL) < 0) {
           fprintf(stderr, "Could not open codec\n");
           exit(1);
       }

       f = fopen([filename UTF8String], "wb");
       if (!f)
       {
           fprintf(stderr, "Could not open %s\n", [filename UTF8String]);
           exit(1);
       }

       frame = av_frame_alloc();
       if (!frame) {
           fprintf(stderr, "Could not allocate video frame\n");
           exit(1);
       }
       frame->format = c->pix_fmt;
       frame->width  = c->width;
       frame->height = c->height;

       /* the image can be allocated by any means and av_image_alloc() is
        * just the most convenient way if av_malloc() is to be used */
       ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,
                            c->pix_fmt, 32);
       if (ret < 0) {
           fprintf(stderr, "Could not allocate raw picture buffer\n");
           exit(1);
       }

       /* encode 1 second of video */
       for(i=0;i<25;i++) {
           av_init_packet(&pkt);
           pkt.data = NULL;    // packet data will be allocated by the encoder
           pkt.size = 0;

           fflush(stdout);
           /* prepare a dummy image */
           /* Y */
           for(y=0;yheight;y++) {
               for(x=0;xwidth;x++) {
                   frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
               }
           }

           /* Cb and Cr */
           for(y=0;yheight/2;y++) {
               for(x=0;xwidth/2;x++) {
                   frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
                   frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
               }
           }

           frame->pts = i;

           /* encode the image */
           ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
           if (ret < 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
           }

           if (got_output) {
               printf("Write frame %3d (size=%5d)\n", i, pkt.size);
               fwrite(pkt.data, 1, pkt.size, f);
               av_free_packet(&pkt);
           }
       }

       /* get the delayed frames */
       for (got_output = 1; got_output; i++) {
           fflush(stdout);

           ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
           if (ret < 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
           }

           if (got_output) {
               printf("Write frame %3d (size=%5d)\n", i, pkt.size);
               fwrite(pkt.data, 1, pkt.size, f);
               av_free_packet(&pkt);
           }
       }

       /* add sequence end code to have a real mpeg file */
       fwrite(endcode, 1, sizeof(endcode), f);
       fclose(f);

       avcodec_close(c);
       av_free(c);
       av_freep(&frame->data[0]);
       av_frame_free(&frame);
       printf("\n");
    }
  • QtAV render in a widget crashes on application close

    23 novembre 2017, par user3606329

    I compiled FFmpeg statically + QtAV statically and QT statically.

    Once I add the QtAV player in a QWidget it crashes on application close. Did I miss any cleanup procdure ?

    MainWindow::MainWindow(QWidget *parent) :
       QMainWindow(parent),
       ui(new Ui::MainWindow)
    {
       ui->setupUi(this);
       QtAV::setLogLevel(QtAV::LogAll);


       AVPlayer *player = new AVPlayer();
       WidgetRenderer *renderer = new WidgetRenderer();
       renderer->show();
       player->addVideoRenderer(renderer);
       player->setFile("C:\\abc.mp4");
       ui->verticalLayout->addWidget(renderer->widget()); # will cause crash on exit.
       player->play();

    }

    MainWindow::~MainWindow()
    {
     //  delete player; # I tried this and also the removal of the widget
    //   delete renderer; # It still does crash
       delete ui;
    }

    The crash comes from

    WidgetRenderer *renderer = new WidgetRenderer();

    Once the renderer is embedded in a QWidget the application can’t exit gracefully somehow.

    I already tried to clean it up, remove the widget, delete the object, etc. but the crash still remains.

    The player works great and plays the videos ! It only gives a crash when the application is closed. (Doesn’t exit gracefully somehow).

    The QtAV log does not print anything about it.