Recherche avancée

Médias (3)

Mot : - Tags -/pdf

Autres articles (35)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • Création définitive du canal

    12 mars 2010, par

    Lorsque votre demande est validée, vous pouvez alors procéder à la création proprement dite du canal. Chaque canal est un site à part entière placé sous votre responsabilité. Les administrateurs de la plateforme n’y ont aucun accès.
    A la validation, vous recevez un email vous invitant donc à créer votre canal.
    Pour ce faire il vous suffit de vous rendre à son adresse, dans notre exemple "http://votre_sous_domaine.mediaspip.net".
    A ce moment là un mot de passe vous est demandé, il vous suffit d’y (...)

Sur d’autres sites (7384)

  • FFMEPG error : Exactly one scaler algorithm must be chosen

    28 mai 2015, par Dave_Dev

    I am currently working on a FFMPEG project. I am trying to convert a RGB image in a YUV image using this code (I found it in the internet last night) :

    void Decode::video_encode_example(const char *filename, int codec_id)

       {

       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);

       /* find the mpeg1 video encoder */
       codec = avcodec_find_encoder((enum AVCodecID)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(2);
       }

       /* 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};
       /* emit one intra frame every ten frames
        * check frame pict_type before passing frame
        * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
        * then gop_size is ignored and the output of encoder
        * will always be I frame irrespective to gop_size
        */
       c->gop_size = 10;
       c->max_b_frames = 1;
       c->pix_fmt = AV_PIX_FMT_YUV420P;

       if (codec_id == AV_CODEC_ID_H264)
           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(3);
       }

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

       frame = avcodec_alloc_frame();// Dans une version plus récente c'est av_frame_alloc
       if (!frame) {
           fprintf(stderr, "Could not allocate video frame\n");
           exit(5);
       }
       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(6);
       }

       //
       // RGB to YUV:
       //    http://stackoverflow.com/questions/16667687/how-to-convert-rgb-from-yuv420p-for-ffmpeg-encoder
       //
       // Create some dummy RGB "frame"
       uint8_t *rgba32Data = new uint8_t[4*c->width*c->height];

       SwsContext * ctx = sws_getContext(c->width, c->height,
                                         AV_PIX_FMT_RGBA, c->width, c->height,
                                         AV_PIX_FMT_YUV420P, 0, 0, 0, 0);


       /* 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; y < c->height; y++) {
           //            for (x = 0; x < c->width; x++) {
           //                frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
           //            }
           //        }
           //
           //        /* Cb and Cr */
           //        for (y = 0; y < c->height/2; y++) {
           //            for (x = 0; x < c->width/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;
           //            }
           //        }

           uint8_t *pos = rgba32Data;
           for (y = 0; y < c->height; y++)
           {
               for (x = 0; x < c->width; x++)
               {
                   pos[0] = i / (float)25 * 255;
                   pos[1] = 0;
                   pos[2] = x / (float)(c->width) * 255;
                   pos[3] = 255;
                   pos += 4;
               }
           }

           uint8_t * inData[1] = { rgba32Data }; // RGBA32 have one plane
           //
           // NOTE: In a more general setting, the rows of your input image may
           //       be padded; that is, the bytes per row may not be 4 * width.
           //       In such cases, inLineSize should be set to that padded width.
           //
           int inLinesize[1] = { 4*c->width }; // RGBA stride
           sws_scale(ctx, inData, inLinesize, 0, c->height, frame->data, frame->linesize);

           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(7);
           }

           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(8);
           }

           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]);
       avcodec_free_frame(&frame);// Dans une version plus récente c'est av_frame_alloc
       printf("\n");
       }

           int main()
           {

               Decode d;

               avcodec_register_all();

               d.video_encode_example("/home/Dave/Desktop/test.mpg",AV_CODEC_ID_MPEG2VIDEO);

           }

    When I run this application, my Linux terminal shows me the following error :

    [swscaler @ 0x1e1dc60] Exactly one scaler algorithm must be chosen
    Segmentation fault (core dumped)

    I do not know what is actually happening. Could you help me please ?

    Best regards
    Dave_Dev

  • FFMPEG error : Exactly one scaler algorithm must be chosen

    28 mai 2015, par Dave_Dev

    I am currently working on an FFMPEG project. I am trying to convert an RGB image into a YUV image using this code (I found it in the internet last night) :

    void Decode::video_encode_example(const char *filename, int codec_id)

       {

       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);

       /* find the mpeg1 video encoder */
       codec = avcodec_find_encoder((enum AVCodecID)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(2);
       }

       /* 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};
       /* emit one intra frame every ten frames
        * check frame pict_type before passing frame
        * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
        * then gop_size is ignored and the output of encoder
        * will always be I frame irrespective to gop_size
        */
       c->gop_size = 10;
       c->max_b_frames = 1;
       c->pix_fmt = AV_PIX_FMT_YUV420P;

       if (codec_id == AV_CODEC_ID_H264)
           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(3);
       }

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

       frame = avcodec_alloc_frame();// Dans une version plus récente c'est av_frame_alloc
       if (!frame) {
           fprintf(stderr, "Could not allocate video frame\n");
           exit(5);
       }
       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(6);
       }

       //
       // RGB to YUV:
       //    http://stackoverflow.com/questions/16667687/how-to-convert-rgb-from-yuv420p-for-ffmpeg-encoder
       //
       // Create some dummy RGB "frame"
       uint8_t *rgba32Data = new uint8_t[4*c->width*c->height];

       SwsContext * ctx = sws_getContext(c->width, c->height,
                                         AV_PIX_FMT_RGBA, c->width, c->height,
                                         AV_PIX_FMT_YUV420P, 0, 0, 0, 0);


       /* 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; y < c->height; y++) {
           //            for (x = 0; x < c->width; x++) {
           //                frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
           //            }
           //        }
           //
           //        /* Cb and Cr */
           //        for (y = 0; y < c->height/2; y++) {
           //            for (x = 0; x < c->width/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;
           //            }
           //        }

           uint8_t *pos = rgba32Data;
           for (y = 0; y < c->height; y++)
           {
               for (x = 0; x < c->width; x++)
               {
                   pos[0] = i / (float)25 * 255;
                   pos[1] = 0;
                   pos[2] = x / (float)(c->width) * 255;
                   pos[3] = 255;
                   pos += 4;
               }
           }

           uint8_t * inData[1] = { rgba32Data }; // RGBA32 have one plane
           //
           // NOTE: In a more general setting, the rows of your input image may
           //       be padded; that is, the bytes per row may not be 4 * width.
           //       In such cases, inLineSize should be set to that padded width.
           //
           int inLinesize[1] = { 4*c->width }; // RGBA stride
           sws_scale(ctx, inData, inLinesize, 0, c->height, frame->data, frame->linesize);

           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(7);
           }

           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(8);
           }

           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]);
       avcodec_free_frame(&frame);// Dans une version plus récente c'est av_frame_alloc
       printf("\n");
       }

           int main()
           {

               Decode d;

               avcodec_register_all();

               d.video_encode_example("/home/Dave/Desktop/test.mpg",AV_CODEC_ID_MPEG2VIDEO);

           }

    When I run this application, my Linux terminal shows me the following error :

    [swscaler @ 0x1e1dc60] Exactly one scaler algorithm must be chosen
    Segmentation fault (core dumped)

    I do not know what is actually happening. Could you help me please ?

  • FFMPEG compiled binaries don't run using MinGW

    9 juin 2015, par Paul Knopf

    I am trying to build windows executables/dlls for Windows XP, and they are not working. They are the correct architecture. They run fine on my Windows 8 device machine.

    I used dependency walker to find missing DLLs, and all were present.

    Here are the compiled executables I am trying to run.

    I ran the windows build script for ffmpeg.

    Here is a dumpbin /headers ffmpeg.exe

    Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
    Copyright (C) Microsoft Corporation.  All rights reserved.


    Dump of file ffmpeg.exe

    PE signature found

    File Type: EXECUTABLE IMAGE

    FILE HEADER VALUES
                14C machine (x86)
                  7 number of sections
              51A40 time date stamp Sun Jan 04 15:53:20 1970
                  0 file pointer to symbol table
                  0 number of symbols
                 E0 size of optional header
                32F characteristics
                      Relocations stripped
                      Executable
                      Line numbers stripped
                      Symbols stripped
                      Application can handle large (>2GB) addresses
                      32 bit word machine
                      Debug information stripped

    OPTIONAL HEADER VALUES
                10B magic # (PE32)
               2.25 linker version
              41400 size of code
              4FA00 size of initialized data
               1200 size of uninitialized data
               14E0 entry point (004014E0)
               1000 base of code
              43000 base of data
             400000 image base (00400000 to 00456FFF)
               1000 section alignment
                200 file alignment
               4.00 operating system version
               1.00 image version
               4.00 subsystem version
                  0 Win32 version
              57000 size of image
                400 size of headers
              597A9 checksum
                  3 subsystem (Windows CUI)
                140 DLL characteristics
                      Dynamic base
                      NX compatible
             200000 size of stack reserve
               1000 size of stack commit
             100000 size of heap reserve
               1000 size of heap commit
                  0 loader flags
                 10 number of directories
                  0 [       0] RVA [size] of Export Directory
              51000 [    36F0] RVA [size] of Import Directory
                  0 [       0] RVA [size] of Resource Directory
                  0 [       0] RVA [size] of Exception Directory
                  0 [       0] RVA [size] of Certificates Directory
                  0 [       0] RVA [size] of Base Relocation Directory
                  0 [       0] RVA [size] of Debug Directory
                  0 [       0] RVA [size] of Architecture Directory
                  0 [       0] RVA [size] of Global Pointer Directory
              56004 [      18] RVA [size] of Thread Storage Directory
                  0 [       0] RVA [size] of Load Configuration Directory
                  0 [       0] RVA [size] of Bound Import Directory
              517F0 [     6C4] RVA [size] of Import Address Table Directory
                  0 [       0] RVA [size] of Delay Import Directory
                  0 [       0] RVA [size] of COM Descriptor Directory
                  0 [       0] RVA [size] of Reserved Directory


    SECTION HEADER #1
      .text name
      412BC virtual size
       1000 virtual address (00401000 to 004422BB)
      41400 size of raw data
        400 file pointer to raw data (00000400 to 000417FF)
          0 file pointer to relocation table
          0 file pointer to line numbers
          0 number of relocations
          0 number of line numbers
    60500060 flags
            Code
            Initialized Data
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            Execute Read

    SECTION HEADER #2
      .data name
        19C virtual size
      43000 virtual address (00443000 to 0044319B)
        200 size of raw data
      41800 file pointer to raw data (00041800 to 000419FF)
          0 file pointer to relocation table
          0 file pointer to line numbers
          0 number of relocations
          0 number of line numbers
    C0700040 flags
            Initialized Data
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            Read Write

    SECTION HEADER #3
     .rdata name
       A7D8 virtual size
      44000 virtual address (00444000 to 0044E7D7)
       A800 size of raw data
      41A00 file pointer to raw data (00041A00 to 0004C1FF)
          0 file pointer to relocation table
          0 file pointer to line numbers
          0 number of relocations
          0 number of line numbers
    40700040 flags
            Initialized Data
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            Read Only

    SECTION HEADER #4
       .bss name
       1200 virtual size
      4F000 virtual address (0044F000 to 004501FF)
          0 size of raw data
          0 file pointer to raw data
          0 file pointer to relocation table
          0 file pointer to line numbers
          0 number of relocations
          0 number of line numbers
    C0700080 flags
            Uninitialized Data
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            Read Write

    SECTION HEADER #5
     .idata name
       36F0 virtual size
      51000 virtual address (00451000 to 004546EF)
       3800 size of raw data
      4C200 file pointer to raw data (0004C200 to 0004F9FF)
          0 file pointer to relocation table
          0 file pointer to line numbers
          0 number of relocations
          0 number of line numbers
    C0300040 flags
            Initialized Data
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            Read Write

    SECTION HEADER #6
       .CRT name
         3C virtual size
      55000 virtual address (00455000 to 0045503B)
        200 size of raw data
      4FA00 file pointer to raw data (0004FA00 to 0004FBFF)
          0 file pointer to relocation table
          0 file pointer to line numbers
          0 number of relocations
          0 number of line numbers
    C0300040 flags
            Initialized Data
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            Read Write

    SECTION HEADER #7
       .tls name
         20 virtual size
      56000 virtual address (00456000 to 0045601F)
        200 size of raw data
      4FC00 file pointer to raw data (0004FC00 to 0004FDFF)
          0 file pointer to relocation table
          0 file pointer to line numbers
          0 number of relocations
          0 number of line numbers
    C0300040 flags
            Initialized Data
            RESERVED - UNKNOWN
            RESERVED - UNKNOWN
            Read Write

     Summary

           1000 .CRT
           2000 .bss
           1000 .data
           4000 .idata
           B000 .rdata
          42000 .text
           1000 .tls

    When I attempt to run the executable on XP, it just closes. There is no "missing dll" messages, nor anything in the event viewer.