Recherche avancée

Médias (1)

Mot : - Tags -/ogg

Autres articles (48)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • Librairies et logiciels spécifiques aux médias

    10 décembre 2010, par

    Pour un fonctionnement correct et optimal, plusieurs choses sont à prendre en considération.
    Il est important, après avoir installé apache2, mysql et php5, d’installer d’autres logiciels nécessaires dont les installations sont décrites dans les liens afférants. Un ensemble de librairies multimedias (x264, libtheora, libvpx) utilisées pour l’encodage et le décodage des vidéos et sons afin de supporter le plus grand nombre de fichiers possibles. Cf. : ce tutoriel ; FFMpeg avec le maximum de décodeurs et (...)

Sur d’autres sites (9466)

  • cli : Prefetch yuv/y4m input frames on Windows 8 and newer

    28 juillet 2016, par Henrik Gramner
    cli : Prefetch yuv/y4m input frames on Windows 8 and newer
    

    Use PrefetchVirtualMemory() (if available) on memory-mapped input frames.

    Significantly improves performance when the source file is not already
    present in the OS page cache by asking the OS to bring in those pages from
    disk using large, concurrent I/O requests.

    Most beneficial on fast encoding settings. Up to 40% faster overall with
    — preset ultrafast, and up to 20% faster overall with —preset veryfast.

    This API was introduced in Windows 8, so call it conditionally. On older
    Windows systems the previous behavior remains unchanged.

    • [DH] input/avs.c
    • [DH] input/ffms.c
    • [DH] input/input.c
    • [DH] input/input.h
  • Write frame without decoding it ?

    24 août 2016, par Aram

    I’m trying to use dranger tutorials for writing a webcam h264 streamed video directly to a file without decoding and encoding it (ffmpeg 3.0/3.1 library). But I’m a bit lost on how do I need to populate the AVFormatContext pointer for the av_write_frame once I get the corresponding AVPacket.

    Trying to clarify. What I want to do is this

    1. Open webcam stream in h264
    2. Read a frame
    3. Save it to a file without decoding and encoding it.

    Copy pasting the code from the tutorial :

    #include
    #include <libavutil></libavutil>pixfmt.h>
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavutil></libavutil>avconfig.h>
    #include <libswscale></libswscale>swscale.h>
    #include <libavformat></libavformat>avformat.h>

    int main(int argc, char *argv[]) {
       av_register_all();
       avcodec_register_all();
       avformat_network_init();

       AVFormatContext *pFormatCtx = avformat_alloc_context();

       // Camera comes from argv[1]
       avformat_open_input(&amp;pFormatCtx, argv[1], NULL, NULL);
       avformat_find_stream_info(pFormatCtx, NULL);
       av_dump_format(pFormatCtx, 0, argv[1], 0);

       int video_stream_idx = -1;

       for (int i = 0; i &lt; pFormatCtx->nb_streams; i++) {
           if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
               video_stream_idx = i;
               break;
           }
       }

       AVCodecContext *pCodecContext = NULL;
       AVCodecContext *pCodecContextOrig = NULL;

       pCodecContextOrig = pFormatCtx->streams[video_stream_idx]->codec;
       AVCodec *pCodec;
       pCodec = avcodec_find_decoder(pCodecContextOrig->codec_id);
       pCodecContext = avcodec_alloc_context3(pCodec);
       avcodec_copy_context(pCodecContext, pCodecContextOrig);
       avcodec_open2(pCodecContext, pCodec, NULL);

       AVFrame *pFrame = av_frame_alloc();
       AVFrame *pFrameRGB = av_frame_alloc();

       uint8_t *buffer = NULL;
       int buffer_size = avpicture_get_size(AV_PIX_FMT_RGB24, pCodecContext->width,
                                            pCodecContext->height);
       buffer = (uint8_t *)av_malloc(buffer_size * sizeof(uint8_t));

       // fill buffer
       avpicture_fill((AVPicture *)pFrameRGB, buffer, AV_PIX_FMT_RGB24,
                      pCodecContext->width, pCodecContext->height);

       struct SwsContext *sws_ctx = NULL;
       int frame_finished = 0;
       AVPacket packet;

       // Size(src), fmt(src), Size(dst), fmt(dst) .. flags
       sws_ctx = sws_getContext(pCodecContext->width, pCodecContext->height,
                                pCodecContext->pix_fmt, pCodecContext->width,
                                pCodecContext->height, AV_PIX_FMT_RGB24,
                                SWS_BILINEAR, NULL, NULL, NULL);


       AVFormatContext *out_fmt_ctx;

       avformat_write_header(out_fmt_ctx, NULL);

       int i = 0;
       while (i &lt; 100 &amp;&amp; (av_read_frame(pFormatCtx, &amp;packet) >= 0)) {
           // Want to write these frames to disk
           i++;
       }

       av_write_trailer(out_fmt_ctx);

       av_free(buffer);
       av_free(pFrameRGB);
       av_free(pFrame);

       avcodec_close(pCodecContext);
       avcodec_close(pCodecContextOrig);

       avformat_close_input(&amp;pFormatCtx);

       return 0;
    }

    I think a lot of stuff of this code can be removed. I’m trying to learn :).

    Linking against -lavutil -lavformat -lavcodec -lz -lavutil -lm -lswscale

  • cannot resolve variable PIX_FMT_RGB24, ffmpeg source code install with the newest version [duplicate]

    10 août 2016, par NacyL

    This question already has an answer here :

    i installed the ffmpeg from source code according https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu, and write a test file to save ppm file from a video, but the code cannot reslove PIX_FMT_RGB24, i write the code as below :

    int main() {
       // Initalizing these to NULL prevents segfaults!
       AVFormatContext   *pFormatCtx = NULL;
       int               i, videoStream;
       AVCodecContext    *pCodecCtxOrig = NULL;
       AVCodecContext    *pCodecCtx = NULL;
       AVCodec           *pCodec = NULL;
       AVFrame           *pFrame = NULL;
       AVFrame           *pFrameRGB = NULL;
       AVPacket          packet;
       int               frameFinished;
       int               numBytes;
       uint8_t           *buffer = NULL;
       struct SwsContext *sws_ctx = NULL;

       const char* url = "/home/liulijuan/bin/test.mp4";

       // [1] Register all formats and codecs
       av_register_all();

       // [2] Open video file
       if(avformat_open_input(&amp;pFormatCtx, url, NULL, NULL)!=0)
           return -1; // Couldn't open file

       // [3] Retrieve stream information
       if(avformat_find_stream_info(pFormatCtx, NULL)&lt;0)
           return -1; // Couldn't find stream information

       // Dump information about file onto standard error
       av_dump_format(pFormatCtx, 0, url, 0);

       // Find the first video stream
       videoStream=-1;
       for(i=0; inb_streams; i++)
           if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
               videoStream=i;
               break;
           }
       if(videoStream==-1)
           return -1; // Didn't find a video stream

       // Get a pointer to the codec context for the video stream
       pCodecCtxOrig=pFormatCtx->streams[videoStream]->codec;
       // Find the decoder for the video stream
       pCodec=avcodec_find_decoder(pCodecCtxOrig->codec_id);
       if(pCodec==NULL) {
           fprintf(stderr, "Unsupported codec!\n");
           return -1; // Codec not found
       }
       // Copy context
       pCodecCtx = avcodec_alloc_context3(pCodec);
       if(avcodec_copy_context(pCodecCtx, pCodecCtxOrig) != 0) {
           fprintf(stderr, "Couldn't copy codec context");
           return -1; // Error copying codec context
       }

       // Open codec
       if(avcodec_open2(pCodecCtx, pCodec, NULL)&lt;0)
           return -1; // Could not open codec

       // Allocate video frame
       pFrame=av_frame_alloc();

       // Allocate an AVFrame structure
       pFrameRGB=av_frame_alloc();
       if(pFrameRGB==NULL)
           return -1;

       // Determine required buffer size and allocate buffer
       numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
                                   pCodecCtx->height);
       buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));

       // Assign appropriate parts of buffer to image planes in pFrameRGB
       // Note that pFrameRGB is an AVFrame, but AVFrame is a superset
       // of AVPicture
       avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
                      pCodecCtx->width, pCodecCtx->height);

       // initialize SWS context for software scaling
       sws_ctx = sws_getContext(pCodecCtx->width,
                                pCodecCtx->height,
                                pCodecCtx->pix_fmt,
                                pCodecCtx->width,
                                pCodecCtx->height,
                                PIX_FMT_RGB24,
                                SWS_BILINEAR,
                                NULL,
                                NULL,
                                NULL
       );

       // [4] Read frames and save first five frames to disk
       i=0;
       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);

                   // Save the frame to disk
                   if(++i&lt;=5)
                       SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height,
                                 i);
               }
           }

           // Free the packet that was allocated by av_read_frame
           av_free_packet(&amp;packet);
       }

       // Free the RGB image
       av_free(buffer);
       av_frame_free(&amp;pFrameRGB);

       // Free the YUV frame
       av_frame_free(&amp;pFrame);

       // Close the codecs
       avcodec_close(pCodecCtx);
       avcodec_close(pCodecCtxOrig);

       // Close the video file
       avformat_close_input(&amp;pFormatCtx);

       return 0;
    }

    so i replace PIX_FMT_RGB24 with AV_PIX_FMT_RGB24, but i cannot open the saved ppm file, the save code as below :

    void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame) {
       FILE *pFile;
       char szFilename[32];
       int  y;

       printf("start save frame ...\n");
       // Open file
       sprintf(szFilename, "/home/liulijuan/frame%d.ppm", iFrame);
       pFile=fopen(szFilename, "wb");
       if(pFile==NULL)
           return;

       printf("start write header ...\n");
       // Write header
       fprintf(pFile, "/P6\n%d %d\n255\n", width, height);

       // Write pixel data
       for(y=0; ydata[0]+y*pFrame->linesize[0], 1, width*3, pFile);

       // Close file
       fclose(pFile);
       printf("close file ...\n");
    }

    so, what’s wrong with this code ?