Recherche avancée

Médias (2)

Mot : - Tags -/plugins

Autres articles (70)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

Sur d’autres sites (8245)

  • FFMpeg encoded video will only play in FFPlay

    8 novembre 2013, par mohM

    I've been debugging my program for a couple of weeks now with the output video only showing a blank screen (was testing with VLC, WMP and WMPClassic). I happened to try using FFPlay and lo and behold the video works perfectly. I've read that this is usually caused by an incorrect pixel format, and that switching to PIX_FMT_YUV420P will make it work universally...but I'm already using that pixel format in the encoding process. Is there anything else that is causing this ?

    AVCodec* codec;
    AVCodecContext* c = NULL;
    uint8_t* outbuf;
    int i, out_size, outbuf_size;

    avcodec_register_all();

    printf("Video encoding\n");

    // Find the mpeg1 video encoder
    codec = avcodec_find_encoder(CODEC_ID_H264);
    if (!codec) {
       fprintf(stderr, "Codec not found\n");
       exit(1);
    }
    else printf("H264 codec found\n");

    c = avcodec_alloc_context3(codec);

    c->bit_rate = 400000;
    c->width = 1920;                                        // resolution must be a multiple of two (1280x720),(1900x1080),(720x480)
    c->height = 1200;
    c->time_base.num = 1;                                   // framerate numerator
    c->time_base.den = 25;                                  // framerate denominator
    c->gop_size = 10;                                       // emit one intra frame every ten frames
    c->max_b_frames = 1;                                    // maximum number of b-frames between non b-frames
    //c->keyint_min = 1;                                        // minimum GOP size
    //c->i_quant_factor = (float)0.71;                      // qscale factor between P and I frames
    //c->b_frame_strategy = 20;
    //c->qcompress = (float)0.6;
    //c->qmin = 20;                                         // minimum quantizer
    //c->qmax = 51;                                         // maximum quantizer
    //c->max_qdiff = 4;                                     // maximum quantizer difference between frames
    //c->refs = 4;                                          // number of reference frames
    //c->trellis = 1;                                           // trellis RD Quantization
    c->pix_fmt = PIX_FMT_YUV420P;
    c->codec_id = CODEC_ID_H264;
    //c->codec_type = AVMEDIA_TYPE_VIDEO;

    // Open the encoder
    if (avcodec_open2(c, codec,NULL) < 0) {
       fprintf(stderr, "Could not open codec\n");
       exit(1);
    }
    else printf("H264 codec opened\n");

    outbuf_size = 100000 + c->width*c->height*(32>>3);//*(32>>3);           // alloc image and output buffer
    outbuf = static_cast(malloc(outbuf_size));
    printf("Setting buffer size to: %d\n",outbuf_size);

    FILE* f = fopen("example.mpg","wb");
    if(!f) printf("x  -  Cannot open video file for writing\n");
    else printf("Opened video file for writing\n");

    // encode 5 seconds of video
    for(i=0;iwidth, c->height);
       uint8_t* outbuffer = (uint8_t*)av_malloc(nbytes*sizeof(uint8_t));

       AVFrame* inpic = avcodec_alloc_frame();
       AVFrame* outpic = avcodec_alloc_frame();

       outpic->pts = (int64_t)((float)i * (1000.0/((float)(c->time_base.den))) * 90);
       avpicture_fill((AVPicture*)inpic, (uint8_t*)pPixels, PIX_FMT_RGB32, c->width, c->height);                   // Fill picture with image
       avpicture_fill((AVPicture*)outpic, outbuffer, PIX_FMT_YUV420P, c->width, c->height);
       av_image_alloc(outpic->data, outpic->linesize, c->width, c->height, c->pix_fmt, 1);

       inpic->data[0] += inpic->linesize[0]*(screenHeight-1);                                                      // Flipping frame
       inpic->linesize[0] = -inpic->linesize[0];                                                                   // Flipping frame

       struct SwsContext* fooContext = sws_getContext(screenWidth, screenHeight, PIX_FMT_RGB32, c->width, c->height, PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
       sws_scale(fooContext, inpic->data, inpic->linesize, 0, c->height, outpic->data, outpic->linesize);

       // encode the image
       out_size = avcodec_encode_video(c, outbuf, outbuf_size, outpic);
       printf("Encoding frame %3d (size=%5d)\n", i, out_size);
       fwrite(outbuf, 1, out_size, f);
       delete [] pPixels;
       av_free(outbuffer);    
       av_free(inpic);
       av_free(outpic);
    }

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

       out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
       printf("Writing 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);

    avcodec_close(c);
    free(outbuf);
    av_free(c);
    printf("Closed codec and Freed\n");
  • iOS FFMPEG encode images to video

    10 avril 2013, par brad.roush

    I am trying to take a set of UIImages and create a video file out of them with FFMPEG. Seems there are lots of questions about this topic but non have been able to get this working correctly for me. This one was particularly helpful in giving me a starting point. This iFrameExtractor example was also very helpful but I want to do this in reverse, then add audio.

    This is the closest I have gotten and it creates a short silent video with flashing colors and no images :

    // Register all formats and codecs
    av_register_all();

    AVCodec *codec;
    AVCodecContext *c= NULL;

    int i, out_size, size, outbuf_size;
    FILE *file;
    AVFrame *picture;
    uint8_t *outbuf;

    NSLog(@"Video encoding");

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

    c= avcodec_alloc_context3(codec);
    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_open2(c, codec, nil) < 0) {
       fprintf(stderr, "could not open codec\n");
       exit(1);
    }

    // Put file in place

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docs_dir = [paths objectAtIndex:0];
    NSString *filePath = [docs_dir stringByAppendingPathComponent:@"test.mpeg"];

    // Seed file
    NSString *sourcePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mov"];
    NSError* error = nil;
    if (![[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:filePath error:&error]) {
       NSLog(@"Test Video creation failed:%@",[error userInfo]);
    } else NSLog(@"Test Video Created");

    const char *filename = [filePath UTF8String];
    file = fopen(filename, "wb");
    if (!file) {
       fprintf(stderr, "could not open %s\n", "filename");
       exit(1);
    }

    /* alloc image and output buffer */
    outbuf_size = 100000;
    outbuf = malloc(outbuf_size);
    size = c->width * c->height;

    //#pragma mark -
    AVFrame* outpic = avcodec_alloc_frame();
    int nbytes = avpicture_get_size(PIX_FMT_YUV420P, c->width, c->height);

    //create buffer for the output image
    uint8_t* outbuffer = (uint8_t*)av_malloc(nbytes);


    AVPacket packet;
    av_init_packet(&packet);


    //#pragma mark -
    for(i=1;i<50;i++) {
       fflush(stdout);

       int numBytes = avpicture_get_size(PIX_FMT_YUV420P, c->width, c->height);
       uint8_t *buffer = (uint8_t *)av_malloc(numBytes*sizeof(uint8_t));

       UIImage *image = [UIImage imageWithContentsOfFile:[docs_dir stringByAppendingPathComponent:[NSString stringWithFormat:@"%d.png",i]]];
       CGImageRef newCgImage = [image CGImage];

       CGDataProviderRef dataProvider = CGImageGetDataProvider(newCgImage);
       CFDataRef bitmapData = CGDataProviderCopyData(dataProvider);
       buffer = (uint8_t *)CFDataGetBytePtr(bitmapData);

       avpicture_fill((AVPicture*)picture, buffer, PIX_FMT_RGB8, c->width, c->height);
       avpicture_fill((AVPicture*)outpic, outbuffer, PIX_FMT_YUV420P, c->width, c->height);

       struct SwsContext* fooContext = sws_getContext(c->width, c->height,
                                                      PIX_FMT_RGB8,
                                                      c->width, c->height,
                                                      PIX_FMT_YUV420P,
                                                      SWS_FAST_BILINEAR, NULL, NULL, NULL);

       //perform the conversion

       sws_scale(fooContext, outpic->data, outpic->linesize,
                 0, c->height, outpic->data, outpic->linesize);
       // Tried This but it didn't work
       //sws_scale(fooContext, picture->data, picture->linesize, 0, c->height, outpic->data, outpic->linesize);


       out_size = avcodec_encode_video(c, outbuf, outbuf_size, outpic);
       // Tried this but it didn't work
       //int test = 0;
       //out_size = avcodec_encode_video2(c, &packet, outpic, &test);



       printf("encoding frame %3d (size=%5d)\n", i, out_size);
       fwrite(outbuf, 1, out_size, file);

       free(buffer);
       buffer = NULL;

    }

    /* 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, outbuf_size, file);
    }
    */

    /* 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, file);
    fclose(file);
    free(outbuf);

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

    Any ideas will be helpful here. If anyone knows of any other good objective-c examples, this would also be great.

  • Codec not found while H.264 encoding using FFMPEG in iOS

    12 juin 2013, par Sukhpal Singh

    I am trying to encode video in h.264 format using FFMpeg in iOS. Actually I am receiving sample buffer from iPhone Camera and then converting it AVFrame and further from AVFrame to H.264 video. But while h.264 encoding if I use :

    codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);

    Then codec is found but if I use :

    codec = avcodec_find_encoder(CODEC_ID_H264);

    Then codec is nil means codec not found. Full code is as below :

    static void encode(AVFrame *picture)
    {
        AVCodec *codec;
        AVCodecContext *c= NULL;
        int i, out_size, size,  outbuf_size;
        uint8_t *outbuf, *picture_buf;

        printf("Video encoding\n");

        /* find the mpeg1 video encoder */

        //avcodec_init() ; // Also tried this but giving warning and not worked
        avcodec_register_all();

        codec = avcodec_find_encoder(CODEC_ID_H264);
        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) < 0) {
            fprintf(stderr, "could not open codec\n");
            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 */

        out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);

        NSLog(@"NSdada===%@",[NSData dataWithBytes:(const void *)outbuf length:out_size]);

        free(picture_buf);
        free(outbuf);

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