Recherche avancée

Médias (1)

Mot : - Tags -/artwork

Autres articles (105)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

Sur d’autres sites (14854)

  • How to call av_read_frame() when streamed data is not yet available ?

    16 janvier 2024, par CheekyChips

    I am streaming audio data and using the ffmpeg/libav libraries to process it in C++. I create a CustomIOContext and a read_packet function to provide the streamed data to ffmpeg, and I create an AVFormatContext using that CustomIOContext.

    


    I want to loop through all available data and extract packets using av_read_frame(), and then when there is not enough data left to create a packet I want to wait until I receive more data and then loop again through the new data. However, I can't figure out what to return in my read_packet function below to tell ffmpeg to wait until more data is available. Ffmpeg seems to require all data to be available now. When I have no data to return, ffmpeg seems to think it's the end of the file, when actually it just isn't ready yet. I have tried returning AVERROR(EAGAIN) but I still have problems. It seems like I get random decoder-specific error messages, because it thinks the input is invalid (when actually it is just not available yet), and then once I have the input and I try calling av_read_frame() again, it immediately returns a negative error code because it got into a bad state.

    


    What do I need to do to be able to loop through all the available data using av_read_frame(), and then pause and wait until more data arrives ? How do I keep ffmpeg happy ?

    


    // -------- Set up  --------
size_t ioContextBufferSize = 4096;
avioContextBuffer = avAllocateEmptyBuffer(ioContextBufferSize);
avioContext = avio_alloc_context(avioContextBuffer.ptr,
                         ioContextBufferSize,
                    0, // bWriteable (1=true,0=false)
                        &(opaque),
                        read_packet,
                        0, // Write callback function
                        0)}; // Seek function not provided

AVFormatContext* inContext = avformat_alloc_context();
inContext->pb = avioContext;
inContext->flags = AVFMT_FLAG_CUSTOM_IO;

avformat_open_input(&inContext, "", nullptr, nullptr);
inputPacket = av_packet_alloc();


    


    // -------- Loop and read data -------
// (the second time we reach this while loop, it never enters the loop :(
//
while ((ret = av_read_frame(inContext, inputPacket)) >= 0) {
  .. do stuff with inputPacket
}


    


    // -------- read_packet function -----
// copies data into ffmpeg's internal buffer. What do I return here???
//
static int read_packet(void* opaque, uint8_t* avioContextBuffer, int ioContextBufferSize) {
  OpaqueDataWrapper* streamedData = static_cast(opaque);

  size_t bytesToRead = std::min((size_t)ioContextBufferSize, streamedData->remainingBytes());

  if (!bytesToRead) {
    // We need to wait for more data to arrive! What do I return here to tell ffmpeg to wait a while? 
    if (streamedData->streamStillOpen()) {
      return AVERROR(EAGAIN);
    } else {
      return AVERROR_EOF;
    }
  }
  ... otherwise copy the next bit of data
}


    


  • CGO : How do you use pointers in Golang to access data from an array in C

    23 avril 2018, par nevernew

    I’m writing an app for the windows platform using FFmpeg and it’s golang wrapper goav, but I’m having trouble understanding how to use the C pointers to gain access to the data array they point to.

    I’m trying to get the data stored in the AVFrame class and use Go to write it to a file, and eventually a texture in OpenGl to make a video player with cool transitions.

    I think understanding how to cast and access the C data will make coding this a lot easier.

    I’ve stripped out all the relevant parts of the C code, the wrapper and my code, shown below :

    C code - libavutil/frame.h

    #include

    typedef struct AVFrame {
    #define AV_NUM_DATA_POINTERS 8
       uint8_t *data[AV_NUM_DATA_POINTERS];
    }

    Golang goav wrapper - I don’t really know whats going on here with the unsafe.Pointers and casting but it gives me access to the underlying C code

    package avutil

    /*
       #cgo pkg-config: libavutil
       #include <libavutil></libavutil>frame.h>
       #include
    */
    import "C"
    import (
       "unsafe"
    )

    type Frame C.struct_AVFrame

    func AvFrameAlloc() *Frame {
       return (*Frame)(unsafe.Pointer(C.av_frame_alloc()))
    }

    func Data(f *Frame) *uint8 {
       return (*uint8)(unsafe.Pointer((*C.uint8_t)(unsafe.Pointer(&amp;f.data))))
    }

    My Golang code

    package main

    import "github.com/giorgisio/goav/avutil"

    func main() {
       videoFrame := avutil.AvFrameAlloc()

       data := avutil.Data(videoFrame)

       fmt.Println(data) // here i want the values from data[0] to data[7], but how?
    }
  • Extacting klm data from mp2 stream using c++ and ffmpeg

    19 février 2019, par Douglas

    I have an mp2 stream that has klv metadata. I stored the klv in a file using ffmpeg command line :

    ffmpeg -i input.mpg -map data-re -codec copy -f data output.klv

    I now want to do this in c++. So, I have

    FFMPEG setup …..

    Then the main loop

    // Read frames
    while(av_read_frame(pFormatCtx, &amp;packet) >= 0)
    {
       // Is this a packet from the video stream?
       if(packet.stream_index == videoStream)
       {
           // Decode video frame
           avcodec_decode_video2(pCodecCtx, pFrame, &amp;frameFinished, &amp;packet);

           // Did we get a video frame?
           if(frameFinished)
           {
               // Convert the image from its native format to RGB
               sws_scale(sws_ctx, (uint8_t const * const *)pFrame->data,
                                   pFrame->linesize, 0, pCodecCtx->height,
                                   pFrameRGB->data, pFrameRGB->linesize);

               QImage myImage(pFrameRGB->data[0], pCodecCtx->width, pCodecCtx->height, QImage::Format_RGB888);

               QPixmap img(QPixmap::fromImage(myImage.scaled(ui->label->width(),ui->label->height(),Qt::KeepAspectRatio)));

               ui->label->setPixmap(img);
               QCoreApplication::processEvents();
           }
       }
       else // klv stream
       {
           // Decode klv data
           qDebug() &lt;&lt; packet.buf->size;
           for(int i=0; isize; i++)
           {
               qDebug() &lt;&lt; packet.buf->data[i];
           }
       }

    The resulting klv output is different - I must be doing something wrong processing the packet. The frames are good and I’m viewing it in a qt label - so my ffmpeg setup is working on images but not the klv data. Any ideas ? THANKS