Recherche avancée

Médias (1)

Mot : - Tags -/framasoft

Autres articles (67)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 is the first MediaSPIP stable release.
    Its official release date is June 21, 2013 and is announced here.
    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 (...)

Sur d’autres sites (13218)

  • Fix js_vlc_bits value validation when joint stereo is used in cook decoder.

    17 septembre 2011, par Laurent Aimar

    Fix js_vlc_bits value validation when joint stereo is used in cook decoder.

  • Anomalie #2015 (Fermé) : validation courriel inscription

    1er avril 2011, par cedric -
  • How to release resources from ffmpeg

    11 février 2020, par Summit

    I have built a class that reads avi file and displays it.

    This is the defination for the class.

    typedef struct {

       AVFormatContext *fmt_ctx;
       int stream_idx;
       AVStream *video_stream;
       AVCodecContext *codec_ctx;
       AVCodec *decoder;
       AVPacket *packet;
       AVFrame *av_frame;
       AVFrame *gl_frame;
       struct SwsContext *conv_ctx;
       unsigned int  frame_tex;    
    }AppData;


    class ClipPlayer{

    private:    
       AppData data;  
       std::vector< AVFrame* > cache;
    public:

       ClipPlayer();
       ClipPlayer(const  ClipPlayer& player);
       ClipPlayer& operator=(const  ClipPlayer& player);
            ~ClipPlayer();
       void initializeAppData();
       void clearAppData();
       bool readFrame();
       bool initReadFrame();
       void playCache();  
       void init();
       void draw();
       void reset();
       }

    In the init function the AVI file is read and the frames are saved in memory.

    void init()
    {

    initializeAppData();

       // open video
       if (avformat_open_input(&data.fmt_ctx, stdstrPathOfVideo.c_str(), NULL, NULL) < 0) {
           clearAppData();
           return;
       }    
       // find stream info
       if (avformat_find_stream_info(data.fmt_ctx, NULL) < 0) {
           clearAppData();
           return;
       }
       // find the video stream
       for (unsigned int i = 0; i < data.fmt_ctx->nb_streams; ++i)
       {
           if (data.fmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
           {
               data.stream_idx = i;
               break;
           }
       }

       if (data.stream_idx == -1)
       {
           clearAppData();
           return;
       }

       data.video_stream = data.fmt_ctx->streams[data.stream_idx];
       data.codec_ctx = data.video_stream->codec;

       // find the decoder
       data.decoder = avcodec_find_decoder(data.codec_ctx->codec_id);
       if (data.decoder == NULL)
       {
           clearAppData();
           return;
       }

       // open the decoder
       if (avcodec_open2(data.codec_ctx, data.decoder, NULL) < 0)
       {
           clearAppData();
           return;
       }

       // allocate the video frames
       data.av_frame = av_frame_alloc();
       data.gl_frame = av_frame_alloc();
       int size = avpicture_get_size(AV_PIX_FMT_RGBA, data.codec_ctx->width,
           data.codec_ctx->height);
       uint8_t *internal_buffer = (uint8_t *)av_malloc(size * sizeof(uint8_t));
       avpicture_fill((AVPicture *)data.gl_frame, internal_buffer, AV_PIX_FMT_RGBA,
           data.codec_ctx->width, data.codec_ctx->height);
       data.packet = (AVPacket *)av_malloc(sizeof(AVPacket));
    }

    /////////////////////////////////////////////////////////////

    bool ClipPlayer::initReadFrame()
    {
       do {
           glBindTexture(GL_TEXTURE_2D, data.frame_tex);
           int error = av_read_frame(data.fmt_ctx, data.packet);      
           if (error)
           {          
               av_free_packet(data.packet);
               return false;
           }

           if (data.packet->stream_index == data.stream_idx)
           {
               int frame_finished = 0;
               if (avcodec_decode_video2(data.codec_ctx, data.av_frame, &frame_finished,
                   data.packet) < 0) {
                   av_free_packet(data.packet);
                   return false;
               }
               if (frame_finished)
               {              
                   if (!data.conv_ctx)
                   {
                       data.conv_ctx = sws_getContext(data.codec_ctx->width,
                           data.codec_ctx->height, data.codec_ctx->pix_fmt,
                           data.codec_ctx->width, data.codec_ctx->height, AV_PIX_FMT_RGBA,
                           SWS_BICUBIC, NULL, NULL, NULL);
                   }
                   sws_scale(data.conv_ctx, data.av_frame->data, data.av_frame->linesize, 0,
                       data.codec_ctx->height, data.gl_frame->data, data.gl_frame->linesize);

                   glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, data.codec_ctx->width,
                       data.codec_ctx->height, GL_RGBA, GL_UNSIGNED_BYTE,
                       data.gl_frame->data[0]);    

                   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
                   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

                   AVFrame *cachedValue = av_frame_alloc();
                   cachedValue->format = data.av_frame->format;
                   cachedValue->width = data.av_frame->width;
                   cachedValue->height = data.av_frame->height;
                   cachedValue->channels = data.av_frame->channels;
                   cachedValue->channel_layout = data.av_frame->channel_layout;
                   cachedValue->nb_samples = data.av_frame->nb_samples;
                   av_frame_get_buffer(cachedValue, 32);
                   av_frame_copy(cachedValue, data.av_frame);
                   av_frame_copy_props(cachedValue, data.av_frame);
                   cache.push_back((cachedValue));
               }
           }      
       } while (data.packet->stream_index != data.stream_idx);

    ////////////////////////////////////////////////////////////////////

    In the play cache function the frames are displayed

    void ClipPlayer::playCache()
    {
          glActiveTexture(GL_TEXTURE0);
          sws_scale(data.conv_ctx, cache[loop]->data, cache[loop]->linesize, 0,
          data.codec_ctx->height, data.gl_frame->data, data.gl_frame->linesize);
          glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, data.codec_ctx->width,
           data.codec_ctx->height, GL_RGBA, GL_UNSIGNED_BYTE,data.gl_frame->data[0]);
          glBindTexture(GL_TEXTURE_2D, data.frame_tex);    
    }

    In the destructor i try to free the memory

    ~ClipPlayer()
    {
        for (auto &frame : cache)
           {
            av_freep(frame);
           }
    }

    I am not very proficient in using FFmpeg , my question is that have i freed the memory properly.