Recherche avancée

Médias (0)

Mot : - Tags -/content

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

Autres articles (76)

  • Pas question de marché, de cloud etc...

    10 avril 2011

    Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
    sur le web 2.0 et dans les entreprises qui en vivent.
    Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
    Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
    le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
    Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...)

  • Activation de l’inscription des visiteurs

    12 avril 2011, par

    Il est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
    Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
    Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)

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

  • libavformat : calling avformat_open_input 2 times results in decoding white frames

    25 avril 2017, par explodus
    • pre build ffmpeg libs format/util/scale
    • version 57.56.101
    • don’t use any deprecated function
    • use the actual style
      • av_read_frame -> avcodec_send_packet -> avcodec_receive_frame -> sws_scale

    Everything is fine on the first run, but when i wanna load/open another file i only get white frames.

    void video::app::flush_cached_frames() {
       if (nullptr == avcontext)
           return;
       if (nullptr == avpicture)
           return;

       // send an empty packet which instructs the codec to start flushing
       AVPacket pkt;
       av_init_packet(&pkt);
       pkt.data = NULL;
       pkt.size = 0;
       avcodec_send_packet(avcontext, &pkt);

       // drain the codec
       while (true) {
           int r = avcodec_receive_frame(avcontext, avpicture);
           if (r != 0)
               break;
       }
    }

    void video::app::close_avi() {
       flush_cached_frames();

       if (avformat && avstream)
           seek_to_frame(0);
       avstream = nullptr;

       if (avfile)
           fclose(avfile);
       avfile = nullptr;

       if (avcontext)
           avcodec_close(avcontext);
       avcontext = nullptr;

       if (avformat)
           avformat_free_context(avformat);
       avformat = nullptr;

       if (sws_ctx)
           sws_freeContext(sws_ctx);
       sws_ctx = nullptr;

       if (avparser)
           av_parser_close(avparser);
       avparser = nullptr;

       if (avinbuf)
           av_free(avinbuf);
       avinbuf = nullptr;
    }

    I think i close anything perfectly. Has anyone an idea ?

    edit1 : init/load

    unsigned video::app::load(const std::string& name) {
       _file = name_;

       close_avi();

       av_register_all();
       avcodec_register_all();

       av_init_packet(&avpkt);

       AVCodecID codec_id = AV_CODEC_ID_H264;
       int64_t duration = 0;
       double fps = .0;
       int ret = 0;
       {
           av_log_set_level(1);

           avfile = fopen(name_.c_str(), "rb");

           avformat = avformat_alloc_context();
           ret = avformat_open_input(&avformat, name_.c_str(), nullptr, nullptr);
           ret = avformat_find_stream_info(avformat, nullptr);
           duration = avformat->duration;

           avstream = nullptr;
           if (avformat->nb_streams == 1) {
               avstream = avformat->streams[0];
           } else {
               avstream = avformat->streams[av_find_default_stream_index(avformat)];
           }

           if (avstream) {
               fps = (double(avstream->avg_frame_rate.num) / double(avstream->avg_frame_rate.den));
               codec_id = avstream->codecpar->codec_id;
               duration = avstream->duration;

               _vid.v_width = avstream->codecpar->width;
               _vid.v_height = avstream->codecpar->height;

               _vid.lastframe = duration / fps;
               _vid.lastframe = avstream->nb_frames;
           }

           avcodec = avcodec_find_decoder(avstream->codecpar->codec_id);
           avparser = av_parser_init(avcodec->id);
           avcontext = avcodec_alloc_context3(avcodec);

           avcontext->flags |= AVFMT_FLAG_NONBLOCK;
           avcontext->flags |= AVFMT_FLAG_FLUSH_PACKETS;
           avcontext->flags |= AVFMT_FLAG_DISCARD_CORRUPT;
           avcontext->flags |= AVFMT_FLAG_NOBUFFER;

           ret = avcodec_parameters_to_context(avcontext, avstream->codecpar);
           ret = avcodec_open2(avcontext, avcodec, nullptr);


           // Determine required buffer size and allocate buffer
           auto numBytes = av_image_get_buffer_size(
                 AV_PIX_FMT_BGRA
               , avcontext->width
               , avcontext->height
               , 1);
           if (avinbuf)
               av_free(avinbuf);
           avinbuf = nullptr;
           avinbuf = (uint8_t *)av_malloc(numBytes * sizeof(uint8_t));
           ret = av_image_fill_arrays(
                 avrgb->data
               , avrgb->linesize
               , avinbuf
               , AV_PIX_FMT_BGRA
               , avcontext->width
               , avcontext->height
               , 1);

           sws_ctx = sws_getContext(
                   avcontext->width
               , avcontext->height
               , avcontext->pix_fmt
               , avcontext->width
               , avcontext->height
               , AV_PIX_FMT_BGRA
               , SWS_BILINEAR
               , nullptr
               , nullptr
               , nullptr
           );
       }

       int err = (sws_ctx && avcontext && avformat) ? 0 : 1;
       // ...
    }

    getting the frame :

    uint8_t * video::app::get_frame(uint32_t frame) {
       if (!avcontext)
           return nullptr;
       if (!avformat)
           return nullptr;
       if (!avpicture)
           return nullptr;
       if (!avfile)
           return nullptr;

       try {
           int ret = 0;

           if (avpicture->data)
               av_frame_unref(avpicture);

           while (true) {
               if ((ret = av_read_frame(avformat, &avpkt)) < 0)
                   break;

               if (avpkt.stream_index == avstream->index) {
                   ret = avcodec_send_packet(avcontext, &avpkt);
                   if (ret < 0)
                       break;

                   while (ret >= 0) {
                       ret = avcodec_receive_frame(avcontext, avpicture);
                       if (ret == AVERROR_EOF) {
                           return nullptr;
                       } else if (ret == -11) {
                           avpkt.data = nullptr;
                           avpkt.size = 0;
                           break;
                       } else if (ret < 0) {
                           return nullptr;
                       }

                       if (ret == AVERROR(EAGAIN)) {
                           avpkt.data = nullptr;
                           avpkt.size = 0;
                           break;
                       }

                       if (ret >= 0) {
                           int linesize[AV_NUM_DATA_POINTERS] = {
                                 avpicture->linesize[0]
                               , avpicture->linesize[1]
                               , avpicture->linesize[2]
                               , avpicture->linesize[3]
                               , avpicture->linesize[4]
                               , avpicture->linesize[5]
                               , avpicture->linesize[6]
                               , avpicture->linesize[7]
                           };
                           uint8_t * data[AV_NUM_DATA_POINTERS] = {
                                 avpicture->data[0]
                               , avpicture->data[1]
                               , avpicture->data[2]
                               , avpicture->data[3]
                               , avpicture->data[4]
                               , avpicture->data[5]
                               , avpicture->data[6]
                               , avpicture->data[7]
                           };

                           {
                               // flip the frame, never ever touch this thing again!
                               // If the planes in the image are unequal size(e.g.YUV420) you need to adapt the height.
                               auto h = avcontext->height;
                               for (int i = 0; i < 4; i++) {
                                   if (i)
                                       data[i] += linesize[i] * ((h >> 1) - 1);
                                   else
                                       data[i] += linesize[i] * (h - 1);
                                   linesize[i] = -linesize[i];
                               }
                           }

                           ret = sws_scale(
                                 sws_ctx
                               , (uint8_t const * const *)data
                               , linesize
                               , 0
                               , avcontext->height
                               , avrgb->data
                               , avrgb->linesize);

                           av_packet_unref(&avpkt);

                           currPts = avpkt.dts;
                           currPts *= av_q2d(avstream->time_base);

                           usleep(1000000 * (currPts - prevPts));
                           prevPts = currPts;

                           return avrgb->data[0];
                       }
                   }
               }
               av_packet_unref(&avpkt);
           }

       } catch (...) {
       }

       return nullptr;
    }
  • avcodec/vaapi_encode : extract the init and close function to base layer

    18 avril 2024, par Tong Wu
    avcodec/vaapi_encode : extract the init and close function to base layer
    

    Related parameters such as device context, frame context are also moved
    to base layer.

    Signed-off-by : Tong Wu <tong1.wu@intel.com>

    • [DH] libavcodec/hw_base_encode.c
    • [DH] libavcodec/hw_base_encode.h
    • [DH] libavcodec/vaapi_encode.c
    • [DH] libavcodec/vaapi_encode.h
    • [DH] libavcodec/vaapi_encode_av1.c
    • [DH] libavcodec/vaapi_encode_h264.c
    • [DH] libavcodec/vaapi_encode_h265.c
    • [DH] libavcodec/vaapi_encode_mjpeg.c
  • avcodec/vaapi_encode : extract a free funtion to base layer

    19 février 2024, par Tong Wu
    avcodec/vaapi_encode : extract a free funtion to base layer
    

    Signed-off-by : Tong Wu <tong1.wu@intel.com>

    • [DH] libavcodec/hw_base_encode.c
    • [DH] libavcodec/hw_base_encode.h
    • [DH] libavcodec/vaapi_encode.c