Recherche avancée

Médias (0)

Mot : - Tags -/content

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

Autres articles (69)

  • Use, discuss, criticize

    13 avril 2011, par

    Talk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
    The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
    A discussion list is available for all exchanges between users.

  • MediaSPIP Player : problèmes potentiels

    22 février 2011, par

    Le lecteur ne fonctionne pas sur Internet Explorer
    Sur Internet Explorer (8 et 7 au moins), le plugin utilise le lecteur Flash flowplayer pour lire vidéos et son. Si le lecteur ne semble pas fonctionner, cela peut venir de la configuration du mod_deflate d’Apache.
    Si dans la configuration de ce module Apache vous avez une ligne qui ressemble à la suivante, essayez de la supprimer ou de la commenter pour voir si le lecteur fonctionne correctement : /** * GeSHi (C) 2004 - 2007 Nigel McNie, (...)

  • MediaSPIP Player : les contrôles

    26 mai 2010, par

    Les contrôles à la souris du lecteur
    En plus des actions au click sur les boutons visibles de l’interface du lecteur, il est également possible d’effectuer d’autres actions grâce à la souris : Click : en cliquant sur la vidéo ou sur le logo du son, celui ci se mettra en lecture ou en pause en fonction de son état actuel ; Molette (roulement) : en plaçant la souris sur l’espace utilisé par le média (hover), la molette de la souris n’exerce plus l’effet habituel de scroll de la page, mais diminue ou (...)

Sur d’autres sites (7672)

  • FFmpeg H264 parsing

    20 mai 2015, par Yoohoo

    I am using FFmpeg to decoding H.264 video, for the following program :

       #include
       #include
       #include
       #include

       #include <sys></sys>time.h>
       #include

    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavutil></libavutil>mathematics.h>

    #include <sdl></sdl>SDL.h>

    void sigint_handler(int signal) {
       printf("\n");
       exit(0);
    }

    const char *window_title;
    SDL_Surface *screen;
    SDL_Overlay *yuv_overlay;

    #define INBUF_SIZE 80000

    /*
    * Video decoding example
    */

    static long get_time_diff(struct timeval time_now) {
      struct timeval time_now2;
      gettimeofday(&amp;time_now2,0);
      return time_now2.tv_sec*1.e6 - time_now.tv_sec*1.e6 + time_now2.tv_usec - time_now.tv_usec;
    }

    int video_open(AVCodecContext *avctx, const char *filename){
       int flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
       int w,h;

       flags |= SDL_RESIZABLE;

       if (avctx->width){
           w = avctx->width;
           h = avctx->height;
       } else {
           w = 640;
           h = 480;
       }

       if(SDL_Init(SDL_INIT_VIDEO) &lt; 0) {
       fprintf(stderr, "SDL_INIT_VIDEO failed!\n");
       exit(1);
       }

       screen = SDL_SetVideoMode(w, h, 0, flags);

       if (!screen) {
           fprintf(stderr, "SDL: could not set video mode - exiting\n");
           return -1;
       }
       if (!window_title)
           window_title = filename;
       SDL_WM_SetCaption(window_title, window_title);

       yuv_overlay = SDL_CreateYUVOverlay(w, h, SDL_YV12_OVERLAY, screen);

       if (yuv_overlay->hw_overlay) {
       fprintf(stderr, "Using hardware overlay!\n");
       }

       return 0;
    }

    int main(int argc, char **argv) {
       AVCodec *codec;
       AVCodecContext *c= NULL;
       AVCodecParserContext *parser = NULL;
       int frame, got_picture, len2, len;
       const char *filename;
       FILE *f;
       AVFrame *picture;
       char *arghwtf = malloc(INBUF_SIZE);
       char *luma = NULL;
       char *chroma = NULL;
       int i=0;
       uint64_t in_len;
       int pts, dts;
       struct timeval t;
       float inv_fps = 1e6/23.98;
       AVPacket avpkt;
       SDL_Rect rect;


       /* register all the codecs */
       avcodec_register_all();

       filename = argv[1];

       av_init_packet(&amp;avpkt);

       printf("Decoding file %s...\n", filename);

       /* find the H.264 video decoder */
       codec = avcodec_find_decoder(CODEC_ID_H264);
       if (!codec) {
           fprintf(stderr, "codec not found\n");
           exit(1);
       }

       c = avcodec_alloc_context3(codec);
       picture = avcodec_alloc_frame();

       c->skip_loop_filter = 48; // skiploopfilter=all

       if (avcodec_open(c, codec) &lt; 0) {
           fprintf(stderr, "could not open codec\n");
           exit(1);
       }

       /* the codec gives us the frame size, in samples */
       parser = av_parser_init(c->codec_id);
       parser->flags |= PARSER_FLAG_ONCE;

       f = fopen(filename, "rb");
       if (!f) {
           fprintf(stderr, "could not open %s\n", filename);
           exit(1);
       }

       frame = 0;
       gettimeofday(&amp;t, 0);
       if(fread(arghwtf, 1, INBUF_SIZE, f) == 0) {
       exit(1);
       }
       in_len = 80000;
           while (in_len > 0 &amp;&amp; !feof(f)) {
           len = av_parser_parse2(parser, c, &amp;avpkt.data, &amp;avpkt.size, arghwtf, in_len,
                                      pts, dts, AV_NOPTS_VALUE);

               len2 = avcodec_decode_video2(c, picture, &amp;got_picture, &amp;avpkt);
               if (len2 &lt; 0) {
                   fprintf(stderr, "Error while decoding frame %d\n", frame);
                   exit(1);
               }
               if (got_picture) {
           if(!screen) {
               video_open(c, filename);

               rect.x = 0;
               rect.y = 0;
               rect.w = c->width;
               rect.h = c->height;
               inv_fps = av_q2d(c->time_base);
               fprintf(stderr, "w:%i h:%i\n", rect.w, rect.h);

               luma = malloc(c->width*c->height);
               chroma = malloc(c->width*c->height/4);

               SDL_DisplayYUVOverlay(yuv_overlay, &amp;rect);

               signal(SIGINT, sigint_handler);
           }
                   fprintf(stderr, "\rDisplaying %c:frame %3d (%02d:%02d)...", av_get_pict_type_char(picture->pict_type), frame, frame/1440, (frame/24)%60);
                   fflush(stderr);

           SDL_LockYUVOverlay(yuv_overlay);

                   for(i=0;iheight;i++) {
                     memcpy(luma + i * c->width, picture->data[0] + i * picture->linesize[0], c->width);
                   }
           memcpy(yuv_overlay->pixels[0], luma, c->width * c->height);
                   for(i=0;iheight/2;i++) {
                     memcpy(chroma + i * c->width/2, picture->data[2] + i * picture->linesize[2], c->width/2);
                   }
           memcpy(yuv_overlay->pixels[1], chroma, c->width * c->height / 4);
                   for(i=0;iheight/2;i++) {
                     memcpy(chroma + i * c->width/2, picture->data[1] + i * picture->linesize[1], c->width/2);
                   }
           memcpy(yuv_overlay->pixels[2], chroma, c->width * c->height / 4);

           SDL_UnlockYUVOverlay(yuv_overlay);
           SDL_DisplayYUVOverlay(yuv_overlay, &amp;rect);

           while(get_time_diff(t) &lt; inv_fps) {
               sleep(1000);
           }
                   frame++;
           gettimeofday(&amp;t, 0);
               }
           memcpy(arghwtf, arghwtf + len, 80000-len);
           fread(arghwtf + 80000 - len, 1, len, f);
           }

       /* some codecs, such as MPEG, transmit the I and P frame with a
          latency of one frame. You must do the following to have a
          chance to get the last frame of the video */
       avpkt.data = NULL;
       avpkt.size = 0;
       len = avcodec_decode_video2(c, picture, &amp;got_picture, &amp;avpkt);
       if (got_picture) {
           printf("saving last frame %3d\n", frame);
           fflush(stdout);

       /* Display last frame here, same code as in the decoding loop above. */

           frame++;
       }

       fclose(f);

       avcodec_close(c);
       av_free(c);
       av_free(picture);
       printf("\n");
    }

    It gives error :

    ||=== H264_decoding, Debug ===|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp||In function ‘int main(int, char**)’:|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|107|error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|136|warning: ‘AVFrame* avcodec_alloc_frame()’ is deprecated (declared at /home/yoohoo/ffmpeg_build/include/libavcodec/avcodec.h:3629) [-Wdeprecated-declarations]|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|136|warning: ‘AVFrame* avcodec_alloc_frame()’ is deprecated (declared at /home/yoohoo/ffmpeg_build/include/libavcodec/avcodec.h:3629) [-Wdeprecated-declarations]|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|138|error: invalid conversion from ‘int’ to ‘AVDiscard’ [-fpermissive]|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|140|error: ‘avcodec_open’ was not declared in this scope|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|163|error: invalid conversion from ‘char*’ to ‘const uint8_t* {aka const unsigned char*}’ [-fpermissive]|
    /home/yoohoo/ffmpeg_build/include/libavcodec/avcodec.h|4465|error:   initializing argument 5 of ‘int av_parser_parse2(AVCodecParserContext*, AVCodecContext*, uint8_t**, int*, const uint8_t*, int, int64_t, int64_t, int64_t)’ [-fpermissive]|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|181|error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|182|error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|188|error: ‘av_get_pict_type_char’ was not declared in this scope|
    /home/yoohoo/codeblocks/Real-time video streaming/H264_decoding/main.cpp|210|error: ‘sleep’ was not declared in this scope|
    ||=== Build finished: 9 errors, 2 warnings ===|

    I am wondering it is an incompatible problem due to I move this C program to C++, but I finally need to use it in C++. How to solve these invalid conversion problem ? Thanks in advance !

  • VP8 Codec Optimization Update

    16 juin 2010, par noreply@blogger.com (John Luther) — inside webm

    Since WebM launched in May, the team has been working hard to make the VP8 video codec faster. Our community members have contributed improvements, but there’s more work to be done in some interesting areas related to performance (more on those below).


    Encoder


    The VP8 encoder is ripe for speed optimizations. Scott LaVarnway’s efforts in writing an x86 assembly version of the quantizer will help in this goal significantly as the quantizer is called many times while the encoder makes decisions about how much detail from the image will be transmitted.

    For those of you eager to get involved, one piece of low-hanging fruit is writing a SIMD version of the ARNR temporal filtering code. Also, much of the assembly code only makes use of the SSE2 instruction set, and there surely are newer extensions that could be made use of. There are also redundant code removal and other general cleanup to be done ; (Yaowu Xu has submitted some changes for these).

    At a higher level, someone can explore some alternative motion search strategies in the encoder. Eventually the motion search can be decoupled entirely to allow motion fields to be calculated elsewhere (for example, on a graphics processor).

    Decoder


    Decoder optimizations can bring higher resolutions and smoother playback to less powerful hardware.

    Jeff Muizelaar has submitted some changes which combine the IDCT and summation with the predicted block into a single function, helping us avoid storing the intermediate result, thus reducing memory transfers and avoiding cache pollution. This changes the assembly code in a fundamental way, so we will need to sync the other platforms up or switch them to a generic C implementation and accept the performance regression. Johann Koenig is working on implementing this change for ARM processors, and we’ll merge these changes into the mainline soon.

    In addition, Tim Terriberry is attacking a different method of bounds checking on the "bool decoder." The bool decoder is performance-critical, as it is called several times for each bit in the input stream. The current code handles this check with a simple clamp in the innermost loops and a less-frequent copy into a circular buffer. This can be expensive at higher data rates. Tim’s patch removes the circular buffer, but uses a more complex clamp in the innermost loops. These inner loops have historically been troublesome on embedded platforms.

    To contribute in these efforts, I’ve started working on rewriting higher-level parts of the decoder. I believe there is an opportunity to improve performance by paying better attention to data locality and cache layout, and reducing memory bus traffic in general. Another area I plan to explore is improving utilization in the multi-threaded decoder by separating the bitstream decoding from the rest of the image reconstruction, using work units larger than a single macroblock, and not tying functionality to a specific thread. To get involved in these areas, subscribe to the codec-devel mailing list and provide feedback on the code as it’s written.

    Embedded Processors


    We want to optimize multiple platforms, not just desktops. Fritz Koenig has already started looking at the performance of VP8 on the Intel Atom platform. This platform need some attention as we wrote our current x86 assembly code with an out-of-order processor in mind. Since Atom is an in-order processor (much like the original Pentium), the instruction scheduling of all of the x86 assembly code needs to be reexamined. One option we’re looking at is scheduling the code for the Atom processor and seeing if that impacts the performance on other x86 platforms such as the Via C3 and AMD Geode. This is shaping up to be a lot of work, but doing it would provide us with an opportunity to tighten up our assembly code.

    These issues, along with wanting to make better use of the larger register file on x86_64, may reignite every assembly programmer’s (least ?) favorite debate : whether or not to use intrinsics. Yunqing Wang has been experimenting with this a bit, but initial results aren’t promising. If you have experience in dealing with a lot of assembly code across several similar-but-kinda-different platforms, these maintainability issues might be familiar to you. I hope you’ll share your thoughts and experiences on the codec-devel mailing list.

    Optimizing codecs is an iterative (some would say never-ending) process, so stay tuned for more posts on the progress we’re making, and by all means, start hacking yourself.

    It’s exciting to see that we’re starting to get substantial code contributions from developers outside of Google, and I look forward to more as WebM grows into a strong community effort.

    John Koleszar is a software engineer at Google.

  • Video Encoding/Decoding - FFmpeg/Libav

    10 janvier 2014, par learner

    I am trying to learn video encoding/decoding using FFmpeg/Libav libraries. The code I follow is : http://www.ffmpeg.org/doxygen/0.6/api-example_8c-source.html

    I am working with only Video Encoding and Video Decoding part of the code. The code encodes dummy images and decodes a dummy video. I am not able to figure out why it doesn't access the video file I provide it (myFile.mpg) in main() function.

    video_encode_example("myFile.mpg");

    filename = "myFile.mpg";

    How do I make it access my video file ?? It generates random images and video even when I give any random name in the above piece of code ("asdf.mpg" or "aaaa.mpg", etc.).

    Here is the selected part I work with :

    #include
    #include
    #include

    #ifdef HAVE_AV_CONFIG_H
    #undef HAVE_AV_CONFIG_H
    #endif

    #include "libavcodec/avcodec.h"
    #include "libavutil/mathematics.h"

    #define INBUF_SIZE 4096
    #define AUDIO_INBUF_SIZE 20480
    #define AUDIO_REFILL_THRESH 4096

    /*
    * Video encoding example
    */
    static void video_encode_example(const char *filename)
    {
        AVCodec *codec;
        AVCodecContext *c = NULL;
        int i, out_size, size, x, y, outbuf_size;
        FILE *f;
        AVFrame *picture;
        uint8_t *outbuf, *picture_buf;

        printf("Video encoding\n");

        /* find the mpeg1 video encoder */
        codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
        if (!codec)
        {
            fprintf(stderr, "codec not found\n");
            exit(1);
        }

        c = avcodec_alloc_context();
        picture = avcodec_alloc_frame();

        /* 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};
        c->gop_size = 10; /* emit one intra frame every ten frames */
        c->max_b_frames=1;
        c->pix_fmt = PIX_FMT_YUV420P;

        /* open it */
        if (avcodec_open(c, codec) &lt; 0)
        {
            fprintf(stderr, "could not open codec\n");
            exit(1);
        }

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

        /* alloc image and output buffer */
        outbuf_size = 100000;
        outbuf = malloc(outbuf_size);
        size = c->width * c->height;
        picture_buf = malloc((size * 3) / 2); /* size for YUV 420 */

        picture->data[0] = picture_buf;
        picture->data[1] = picture->data[0] + size;
        picture->data[2] = picture->data[1] + size / 4;
        picture->linesize[0] = c->width;
        picture->linesize[1] = c->width / 2;
        picture->linesize[2] = c->width / 2;

        /* encode 1 second of video */
        for(i=0; i&lt;25; i++)
        {
            fflush(stdout);
            /* prepare a dummy image */
            /* Y */
            for(y=0; y &lt; c->height; y++)
            {
                for(x=0; x &lt; c->width; x++)
                {
                    picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3;
                }
            }

            /* Cb and Cr */
            for(y=0; y &lt; c->height/2; y++)
            {
                for(x=0; x &lt; c->width/2; x++)
                {
                    picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2;
                    picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5;
                }
            }

            /* encode the image */
            out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
            printf("encoding frame %3d (size=%5d)\n", i, out_size);
            fwrite(outbuf, 1, out_size, f);
        }

        /* get the delayed frames */
        for(; out_size; i++)
        {
            fflush(stdout);

            out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
            printf("write frame %3d (size=%5d)\n", i, out_size);
            fwrite(outbuf, 1, out_size, f);
        }

        /* add sequence end code to have a real mpeg file */
        outbuf[0] = 0x00;
        outbuf[1] = 0x00;
        outbuf[2] = 0x01;
        outbuf[3] = 0xb7;
        fwrite(outbuf, 1, 4, f);
        fclose(f);
        free(picture_buf);
        free(outbuf);

        avcodec_close(c);
        av_free(c);
        av_free(picture);
        printf("\n");
    }

    /*
     * Video decoding example
     */

    static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
                         char *filename)
    {
        FILE *f;
        int i;

        f=fopen(filename,"w");
        fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255);
        for(i=0; i* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
        memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);

        printf("Video decoding\n");

        /* find the mpeg1 video decoder */
        codec = avcodec_find_decoder(CODEC_ID_MPEG1VIDEO);
        if (!codec) {
            fprintf(stderr, "codec not found\n");
            exit(1);
        }

        c = avcodec_alloc_context();
        picture = avcodec_alloc_frame();

        if(codec->capabilities&amp;CODEC_CAP_TRUNCATED)
            c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */

        /* For some codecs, such as msmpeg4 and mpeg4, width and height
           MUST be initialized there because this information is not
           available in the bitstream. */

        /* open it */
        if (avcodec_open(c, codec) &lt; 0) {
            fprintf(stderr, "could not open codec\n");
            exit(1);
        }

        /* the codec gives us the frame size, in samples */

        f = fopen(filename, "rb");
        if (!f) {
            fprintf(stderr, "could not open file! %s\n", filename);
            exit(1);
        }

        frame = 0;
        for(;;) {
            avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
            if (avpkt.size == 0)
                break;

            /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)
               and this is the only method to use them because you cannot
               know the compressed data size before analysing it.

               BUT some other codecs (msmpeg4, mpeg4) are inherently frame
               based, so you must call them with all the data for one
               frame exactly. You must also initialize &#39;width&#39; and
               &#39;height&#39; before initializing them. */

            /* NOTE2: some codecs allow the raw parameters (frame size,
               sample rate) to be changed at any frame. We handle this, so
               you should also take care of it */

            /* here, we use a stream based decoder (mpeg1video), so we
               feed decoder and see if it could decode a frame */

            avpkt.data = inbuf;
            while (avpkt.size > 0)
            {
                len = avcodec_decode_video2(c, picture, &amp;got_picture, &amp;avpkt);
                if (len &lt; 0)
                {
                    fprintf(stderr, "Error while decoding frame %d\n", frame);
                    exit(1);
                }
                if (got_picture)
                {
                    printf("saving frame %3d\n", frame);
                    fflush(stdout);

                    /* the picture is allocated by the decoder. no need to
                       free it */
                    snprintf(buf, sizeof(buf), outfilename, frame);
                    pgm_save(picture->data[0], picture->linesize[0],
                             c->width, c->height, buf);
                    frame++;
                }
                avpkt.size -= len;
                avpkt.data += len;
            }
        }

        /* some codecs, such as MPEG, transmit the I and P frame with a
           latency of one frame. You must do the following to have a
           chance to get the last frame of the video */

        avpkt.data = NULL;
        avpkt.size = 0;
        len = avcodec_decode_video2(c, picture, &amp;got_picture, &amp;avpkt);
        if (got_picture)
        {
            printf("saving last frame %3d\n", frame);
            fflush(stdout);

            /* the picture is allocated by the decoder. no need to
               free it */
            snprintf(buf, sizeof(buf), outfilename, frame);
            pgm_save(picture->data[0], picture->linesize[0],
                     c->width, c->height, buf);
            frame++;
        }

        fclose(f);

        avcodec_close(c);
        av_free(c);
        av_free(picture);
        printf("\n");
    }

    int main(int argc, char **argv)
    {
        const char *filename;

        /* must be called before using avcodec lib */
        avcodec_init();

        /* register all the codecs */
        avcodec_register_all();

        if (argc &lt;= 1)
        {
            video_encode_example("asdf.mpg");
            filename = "asdf.mpg";
        }
        else
        {
            filename = argv[1];
        }

        video_decode_example("%d.pgm", filename);

        return 0;
    }