Recherche avancée

Médias (91)

Autres articles (41)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • MediaSPIP Init et Diogène : types de publications de MediaSPIP

    11 novembre 2010, par

    À l’installation d’un site MediaSPIP, le plugin MediaSPIP Init réalise certaines opérations dont la principale consiste à créer quatre rubriques principales dans le site et de créer cinq templates de formulaire pour Diogène.
    Ces quatre rubriques principales (aussi appelées secteurs) sont : Medias ; Sites ; Editos ; Actualités ;
    Pour chacune de ces rubriques est créé un template de formulaire spécifique éponyme. Pour la rubrique "Medias" un second template "catégorie" est créé permettant d’ajouter (...)

Sur d’autres sites (3785)

  • Stuttering rendering using ffmpeg and sdl2

    22 décembre 2020, par Wiesen_Walle

    With the following Code I get a stuttering rendering of the movie file. Interesstingly, when dumping information with ffmpeg it says it has 25 fps and a duration of 00:01:32.90 ; however when counting the frames and time it runs by myself it gives a time of about 252 seconds, I guess the code receiving the frames and sending the package (int cap(vid v)) draws the same frame multiple of times. But I cannot see what's wrong ?

    


    //PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/usr/lib64/pkgconfig/   --> add path to PKF_Config search path&#xA;//export PKG_CONFIG_PATH --> export PKG_Config search path to become visible for gcc&#xA;//gcc ffmpeg_capture_fl.c -Wall -pedantic -fPIC `pkg-config --cflags --libs libavdevice libavformat libavcodec libavutil libavdevice libavfilter libswscale libswresample sdl2`&#xA;&#xA;&#xA;#include <libavdevice></libavdevice>avdevice.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;#include &#xA;#include &#xA;#include <libavutil></libavutil>rational.h>&#xA;#include <sys></sys>time.h>&#xA;#include &#xA;&#xA;&#xA;typedef struct vid{&#xA;AVFormatContext *inc;&#xA;AVInputFormat *iformat;&#xA;AVCodecContext  *pCodecCtx;&#xA;AVCodec         *pCodec;&#xA;AVFrame         *pFrame;&#xA;int videoStream;} vid;&#xA;&#xA;typedef struct sws{&#xA;struct SwsContext *ctx;&#xA;uint8_t **buffer;&#xA;int *linesize;&#xA;} sws;&#xA;&#xA;&#xA;vid cap_init_fl(char *fl);&#xA;int cap(vid v);&#xA;void cap_close(vid v);&#xA;&#xA;sws init_swsctx(int width, int height, enum AVPixelFormat pix_fmt, int new_width, int new_height, enum AVPixelFormat new_pxf);&#xA;void conv_pxlformat(sws scale, uint8_t **src_data, int *src_linesize, int height);&#xA;void free_sws(sws inp);&#xA;&#xA;#include <sdl2></sdl2>SDL.h>&#xA;&#xA;typedef struct sdl_window{&#xA;    SDL_Window *window;&#xA;    SDL_Renderer *renderer;&#xA;    SDL_Texture *texture;&#xA;    SDL_Event *event;&#xA;    int width;&#xA;    int height;&#xA;    int pitch;&#xA;    uint32_t sdl_pxl_frmt;&#xA;    }sdl_window;&#xA;&#xA;sdl_window init_windowBGR24_ffmpg(int width, int height);&#xA;int render_on_texture_update(sdl_window wow, uint8_t *data);&#xA;void close_window(sdl_window wow);&#xA;&#xA;&#xA;vid cap_init_fl(char *fl){&#xA;    vid v = {NULL, NULL, NULL, NULL, NULL, -1};&#xA;    int i;&#xA;    &#xA;    av_register_all();&#xA;    avdevice_register_all();&#xA;&#xA;    if( 0 > avformat_open_input( &amp;(v.inc), fl , v.iformat, NULL)) {&#xA;        printf("Input device could not been opened\n");&#xA;        cap_close(v);&#xA;        exit(1);&#xA;        }&#xA;&#xA;    if(avformat_find_stream_info(v.inc, NULL)&lt;0){&#xA;        printf("Stream information could not been found.\n");&#xA;        cap_close(v);&#xA;        exit(2);&#xA;    }&#xA;&#xA;    // Dump information about file onto standard error&#xA;    av_dump_format(v.inc, 0, fl, 0);&#xA;&#xA;    // Find the first video stream&#xA;    v.videoStream=-1;&#xA;    for(i=0; inb_streams; i&#x2B;&#x2B;){&#xA;      if(v.inc->streams[i]->codecpar->codec_type==AVMEDIA_TYPE_VIDEO) {&#xA;        v.videoStream=i;&#xA;        break;&#xA;      }}&#xA;&#xA;    if(v.videoStream==-1){&#xA;        printf("Could not find video stream.\n");&#xA;        cap_close(v);&#xA;        exit(3);&#xA;        }&#xA;&#xA;    // Find the decoder for the video stream&#xA;    v.pCodec=avcodec_find_decoder(v.inc->streams[v.videoStream]->codecpar->codec_id);&#xA;        if(v.pCodec==NULL) {&#xA;          printf("Unsupported codec!\n");&#xA;        cap_close(v);&#xA;        exit(4);&#xA;           // Codec not found&#xA;        }&#xA;&#xA;    &#xA;&#xA;    // Get a pointer to the codec context for the video stream&#xA;    &#xA;    if((v.pCodecCtx=avcodec_alloc_context3(NULL)) == NULL){&#xA;        printf("Could not allocate codec context\n");&#xA;        cap_close(v);&#xA;        exit(10);}&#xA;&#xA;    avcodec_parameters_to_context (v.pCodecCtx, v.inc->streams[v.videoStream]->codecpar);       &#xA;    &#xA;    // Open codec&#xA;    if(avcodec_open2(v.pCodecCtx, v.pCodec, NULL)&lt;0){&#xA;        printf("Could not open codec");&#xA;        cap_close(v);&#xA;        exit(5);&#xA;        }&#xA;        &#xA;    &#xA;    // Allocate video frame&#xA;    v.pFrame=av_frame_alloc();&#xA;    if(v.pFrame==NULL){&#xA;        printf("Could not allocate AVframe");&#xA;        cap_close(v);&#xA;        exit(6);}&#xA;&#xA;    &#xA;    return v;&#xA;}&#xA;&#xA;&#xA;&#xA;int cap(vid v){&#xA;    int errorCodeRF, errorCodeSP, errorCodeRecFR;&#xA;    AVPacket pkt;&#xA;        &#xA;    if((errorCodeRF = av_read_frame(v.inc, &amp;pkt))  >= 0){&#xA;        &#xA;        if (pkt.stream_index == v.videoStream) {&#xA;            &#xA;            errorCodeSP = avcodec_send_packet(v.pCodecCtx, &amp;pkt);&#xA;            &#xA;            if (errorCodeSP >= 0 || errorCodeSP == AVERROR(EAGAIN)){&#xA;                &#xA;                errorCodeRecFR = avcodec_receive_frame(v.pCodecCtx, v.pFrame);&#xA;                &#xA;                if (errorCodeRecFR &lt; 0){ &#xA;                    av_packet_unref(&amp;pkt);&#xA;                    return errorCodeRecFR;&#xA;                    }&#xA;                else{&#xA;                    av_packet_unref(&amp;pkt);&#xA;                    return 0;&#xA;                    }&#xA;                &#xA;                }&#xA;            else{&#xA;                 av_packet_unref(&amp;pkt);&#xA;                 return errorCodeSP;}&#xA;                &#xA;        }}&#xA;                &#xA;    else{&#xA;        return errorCodeRF;}&#xA;        return 1;&#xA;        }&#xA;    &#xA;    &#xA;&#xA;void cap_close(vid v){&#xA;    if(v.pFrame != NULL) av_free(v.pFrame);&#xA;    avcodec_close(v.pCodecCtx);&#xA;    avformat_close_input(&amp;(v.inc));&#xA;    if(v.inc != NULL) avformat_free_context(v.inc);&#xA;    &#xA;    v.inc = NULL;&#xA;    v.iformat = NULL;&#xA;    v.pCodecCtx = NULL;&#xA;    v.pCodec = NULL;&#xA;    v.pFrame = NULL;&#xA;    v.videoStream=-1;}&#xA;&#xA;&#xA;&#xA;sws init_swsctx(int width, int height, enum AVPixelFormat pix_fmt, int new_width, int new_height, enum AVPixelFormat new_pxf){&#xA;&#xA;int nwidth, nheight;&#xA;sws scale;&#xA;&#xA;scale.buffer = (uint8_t **) malloc(4 * sizeof(uint8_t *));&#xA;scale.linesize = (int *) malloc(4 * sizeof(int));&#xA;&#xA;&#xA;nwidth = (new_width &lt;= 0) ?  width : new_width;&#xA;nheight = (new_height &lt;= 0) ?  height : new_height;&#xA;&#xA;av_image_alloc(scale.buffer, scale.linesize, nwidth, nheight, new_pxf, 1);&#xA;scale.ctx = sws_getContext(width, height, pix_fmt, nwidth, nheight, new_pxf, SWS_BILINEAR, NULL, NULL, NULL);&#xA;&#xA;if(scale.ctx==NULL){&#xA;    printf("Could not allocate SWS-Context\n");&#xA;    av_freep(&amp;(scale.buffer)[0]);&#xA;    free(scale.buffer);&#xA;    free(scale.linesize);&#xA;    exit(12);&#xA;    }&#xA;            &#xA;return scale;}&#xA;&#xA;&#xA;void conv_pxlformat(sws scale, uint8_t **src_data, int *src_linesize, int height){  &#xA;    sws_scale(scale.ctx, (const uint8_t **) src_data, src_linesize, 0, height, scale.buffer, scale.linesize);&#xA;    }&#xA;&#xA;&#xA;void free_sws(sws inp){&#xA;    av_freep(&amp;(inp.buffer)[0]);&#xA;    free(inp.buffer);&#xA;    free(inp.linesize); &#xA;}&#xA;&#xA;&#xA;sdl_window init_windowBGR24_ffmpg(int width, int height){&#xA;&#xA; sdl_window wow;&#xA;    &#xA; if (SDL_Init(SDL_INIT_VIDEO) &lt; 0) {&#xA;    printf("Couldn&#x27;t initialize SDL in function: create_sdl_window(...)\n");&#xA;    exit(7);}&#xA;    &#xA; wow.window = SDL_CreateWindow("SDL_CreateTexture",&#xA;                        SDL_WINDOWPOS_UNDEFINED,&#xA;                        SDL_WINDOWPOS_UNDEFINED,&#xA;                        width, height,&#xA;                        SDL_WINDOW_RESIZABLE);&#xA;&#xA; wow.renderer = SDL_CreateRenderer(wow.window, -1, SDL_RENDERER_ACCELERATED);&#xA; wow.texture = SDL_CreateTexture(wow.renderer, SDL_PIXELFORMAT_BGR24, SDL_TEXTUREACCESS_STREAMING, width, height);&#xA; wow.width = width;&#xA; wow.height = height;&#xA; wow.pitch = width * 3;  //only true for 3 byte / 24bit packed formats like bgr24&#xA; wow.sdl_pxl_frmt = SDL_PIXELFORMAT_BGR24;&#xA; SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); &#xA; SDL_SetHint(SDL_HINT_RENDER_VSYNC, "enable"); &#xA; SDL_RenderSetLogicalSize(wow.renderer, wow.width, wow.height);&#xA; return wow;&#xA;}&#xA;&#xA;&#xA;int render_on_texture_update(sdl_window wow, uint8_t *data){&#xA;    &#xA;    if (SDL_UpdateTexture(wow.texture, NULL, data, wow.pitch)&lt; 0){&#xA;        printf("SDL_render_on_texture_update_failed: %s\n", SDL_GetError());&#xA;        return -1;&#xA;        }&#xA;    SDL_RenderClear(wow.renderer);&#xA;    SDL_RenderCopy(wow.renderer, wow.texture, NULL, NULL);&#xA;    SDL_RenderPresent(wow.renderer);&#xA;&#xA;    return 0; &#xA;}&#xA;&#xA;&#xA;void close_window(sdl_window wow){&#xA;    SDL_DestroyRenderer(wow.renderer);&#xA;    SDL_Quit();&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;int main(){&#xA;    int n, vid_error;&#xA;    long int time_per_frame_usec, duration_usec;&#xA;    vid v;&#xA;    sdl_window wow;&#xA;    struct timeval tval_start, tval_start1, tval_end, tval_duration;&#xA;    sws scale;&#xA;    SDL_Event event;&#xA;   &#xA;    vid_error = AVERROR(EAGAIN);&#xA;    v = cap_init_fl("mw_maze_test.mp4"); &#xA;    &#xA;    while(vid_error == AVERROR(EAGAIN)){&#xA;        vid_error =cap(v);}&#xA;        &#xA;    if(vid_error &lt; 0){&#xA;        printf("Could not read from Capture\n");&#xA;        cap_close(v);&#xA;        return 0;&#xA;        }&#xA;&#xA;    wow = init_windowBGR24_ffmpg((v.pCodecCtx)->width, (v.pCodecCtx)->height);&#xA;    scale = init_swsctx((v.pCodecCtx)->width, (v.pCodecCtx)->height, (v.pCodecCtx)->pix_fmt, 0, 0, AV_PIX_FMT_BGR24);&#xA;        &#xA;    time_per_frame_usec =  ((long int)((v.inc)->streams[v.videoStream]->avg_frame_rate.den) *  1000000 / (long int) ((v.inc)->streams[v.videoStream]->avg_frame_rate.num));&#xA;    &#xA;    printf("Time per frame: %ld\n", time_per_frame_usec);&#xA;    n = 0;&#xA;    &#xA;    gettimeofday(&amp;tval_start, NULL);&#xA;    gettimeofday(&amp;tval_start1, NULL);&#xA;    &#xA;    while ((vid_error =cap(v)) >= 0) {&#xA;                &#xA;                if (SDL_PollEvent(&amp;event) != 0) {&#xA;                        if (event.type == SDL_QUIT)&#xA;                        break;}&#xA;                    &#xA;                conv_pxlformat(scale, (v.pFrame)->data, (v.pFrame)->linesize, (v.pCodecCtx)->height);&#xA;                gettimeofday(&amp;tval_end, NULL);&#xA;                timersub(&amp;tval_end, &amp;tval_start, &amp;tval_duration);&#xA;                duration_usec = (long int)tval_duration.tv_sec * 1000000 &#x2B; (long int)tval_duration.tv_usec;&#xA;                &#xA;                while(duration_usec &lt; time_per_frame_usec) {&#xA;                gettimeofday(&amp;tval_end, NULL);&#xA;                timersub(&amp;tval_end, &amp;tval_start, &amp;tval_duration);&#xA;                duration_usec = (long int)tval_duration.tv_sec * 1000000 &#x2B; (long int)tval_duration.tv_usec;&#xA;                    }&#xA;                &#xA;                gettimeofday(&amp;tval_start, NULL);&#xA;                render_on_texture_update(wow, *(scale.buffer)); &#xA;                n&#x2B;&#x2B;;&#xA;        }&#xA;  &#xA;    gettimeofday(&amp;tval_end, NULL);&#xA;    timersub(&amp;tval_end, &amp;tval_start1, &amp;tval_duration);&#xA;    duration_usec = (long int)tval_duration.tv_sec * 1000000 &#x2B; (long int)tval_duration.tv_usec;&#xA;    &#xA;    printf("Total time and frames; %ld %i\n", duration_usec, n);&#xA;    &#xA;    if(vid_error == AVERROR(EAGAIN)){&#xA;                    printf("AVERROR(EAGAIN) occured\n)");&#xA;                    }   &#xA;                &#xA;    &#xA;    sws_freeContext(scale.ctx);&#xA;    free_sws(scale);&#xA;    close_window(wow);&#xA;    cap_close(v); &#xA;    return 0;   &#xA;}&#xA;&#xA;

    &#xA;

    the output is:&#xA;&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;mw_maze_test.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : mp42&#xA;    minor_version   : 0&#xA;    compatible_brands: isommp42&#xA;    creation_time   : 2014-02-14T21:09:52.000000Z&#xA;  Duration: 00:01:32.90, start: 0.000000, bitrate: 347 kb/s&#xA;    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 384x288 [SAR 1:1 DAR 4:3], 249 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)&#xA;    Metadata:&#xA;      handler_name    : VideoHandler&#xA;    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2014-02-14T21:09:53.000000Z&#xA;      handler_name    : IsoMedia File Produced by Google, 5-11-2011&#xA;Time per frame: 40000&#xA;Total time and frames; 252881576 6322&#xA;&#xA;&#xA;

    &#xA;

  • AR.Drone 2, ffmpeg avcodec_decode_video2( ) segmentation fault

    21 avril 2014, par mechanicalmanb

    I have been trying to decode the video stream from an AR.Drone 2.0 (http://ardrone2.parrot.com/) for a while now with no success. Despite several examples that I have been following closely (I’d paste links, but I am not allowed) I cannot escape a segmentation fault inside of the ffmpeg libavcodec library. I thought that perhaps I was making some kind of mistake in the multi-threaded structure I was building, so I cut out everything except the bare minimum you need to connect to the drone, collect a frame from the drone, and send it to ffmpeg’s avcodec_decode_video2() function.

    I compiled the ffmpeg source (I’ve actually tried three different releases !) and can get the ffplay utility to display the drone’s video TCP stream. The video lags significantly, but at least I know the drone isn’t sending me complete gibberish.

    Has anyone encountered a problem like this before ? What could be causing this segmentation fault, and what can I do about it ? Is there a way to isolate a test on ffmpeg so that I can be sure it is the library and not something I’ve been doing this entire time ?

    Thanks for your time.

    A pastebin with my code :
    http://pastebin.com/NYTf0NeT

    Some details on my ffmpeg and compiler set up :

    ffmpeg version 2.2.git Copyright (c) 2000-2014 the FFmpeg developers
     built on Mar  3 2014 18:05:42 with gcc 4.8 (Ubuntu 4.8.1-2ubuntu1~12.04)
     configuration:
     libavutil      52. 66.100 / 52. 66.100
     libavcodec     55. 52.102 / 55. 52.102
     libavformat    55. 33.100 / 55. 33.100
     libavdevice    55. 10.100 / 55. 10.100
     libavfilter     4.  2.100 /  4.  2.100
     libswscale      2.  5.101 /  2.  5.101
     libswresample   0. 18.100 /  0. 18.100

    The output of my code and a backtrace at the segmentation fault :

    *********************** START ***********************



    booting...

    [h264 @ 0x604040] err{or,}_recognition separate: 1; 1

    [h264 @ 0x604040] err{or,}_recognition combined: 1; 1

    [h264 @ 0x604040] Unsupported bit depth: 0

    asked for 40000 bytes, received packet of 1448 bytes

    PaVE synchronized. YIPEEEEEEEEEEEEEEEEEEEEEEEE



    ---------------------------

    Codec : H264

    StreamID : 1

    Timestamp : 1031517 ms

    Encoded dims : 640 x 368

    Display dims : 640 x 360

    Header size : 76

    Payload size : 17583

    Size of SPS inside payload : 14

    Size of PPS inside payload : 10

    Slices in the frame : 1

    Frame Type / Number : IDR-Frame : 31467 : slide 1/1

    ---------------------------




    gathering payload...

    asked for 16211 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 14763 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 13315 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 11867 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 10419 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 8971 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 7523 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 6075 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 4627 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 3179 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 1731 bytes, received packet of 1448 bytes

    gathering payload...

    asked for 283 bytes, received packet of 283 bytes

    payload complete, attempting to decode frame




    Program received signal SIGSEGV, Segmentation fault.

    0x00007ffff73fccba in ?? () from /usr/lib/x86_64-linux-gnu/libavcodec.so.53

    (gdb) bt

    #0  0x00007ffff73fccba in ?? () from /usr/lib/x86_64-linux-gnu/libavcodec.so.53

    #1  0x00007ffff73fd8f5 in avcodec_decode_video2 () from /usr/lib/x86_64-linux-gnu/libavcodec.so.53

    #2  0x000000000040159f in fetch_and_decode(int, parrot_video_encapsulation_t, AVCodecContext*, AVFrame*)

       ()

    #3  0x00000000004019c6 in main ()

    EDIT : I used Valgrind to try and get a better picture of the seg fault, and received the following :

    ==4730== Invalid read of size 1
    ==4730==    at 0x5265CBA: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0)
    ==4730==    by 0x52668F4: avcodec_decode_video2 (in /usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0)
    ==4730==    by 0x40140E: fetch_and_decode(int, AVCodecContext*, AVFrame*) (main.cpp:176)
    ==4730==    by 0x401757: main (main.cpp:273)
    ==4730==  Address 0x280056c46f9 is not stack'd, malloc'd or (recently) free'd
    ==4730==
    ==4730==
    ==4730== Process terminating with default action of signal 11 (SIGSEGV)
    ==4730==  Access not within mapped region at address 0x280056C46F9
    ==4730==    at 0x5265CBA: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0)
    ==4730==    by 0x52668F4: avcodec_decode_video2 (in /usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0)
    ==4730==    by 0x40140E: fetch_and_decode(int, AVCodecContext*, AVFrame*) (main.cpp:176)
    ==4730==    by 0x401757: main (main.cpp:273)

    "Invalid read size of 1" refers to trying to access a byte outside the bounds of an array. Does this mean that the library is trying to access something outside the bounds of an array I’m giving it ? I’ve checked the AVPkt, and that seems fine. I’m still stumped !

  • add username as random position watermark to video using PHP [duplicate]

    12 novembre 2020, par mohamed.nabil

    Iam working on video learning courses website

    &#xA;

    I want to put a dynamic watermark appears in random positions on top of video with username or email of the logedin user.

    &#xA;

    is it possible to do this example by using ffmpeg or require Ai ?, website is php wordpress site.

    &#xA;

    This link provide an example of What I mean from vdocipher website&#xA;https://www.vdocipher.com/blog/2014/12/add-text-to-videos-with-watermark/

    &#xA;