Recherche avancée

Médias (0)

Mot : - Tags -/acrobat

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

Autres articles (75)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Récupération d’informations sur le site maître à l’installation d’une instance

    26 novembre 2010, par

    Utilité
    Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
    Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...)

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

Sur d’autres sites (6793)

  • Anomalie #4430 : image_reduire gère mal les arrondis

    4 février 2020, par jluc -

    J’ai ajouté des logs et vu que le pb est créé par image_ratio. La fonction n’est pas compliquée pourtant : https://code.spip.net/autodoc/tree/ecrire/inc/filtres_images_lib_mini.php.html#function_image_ratio

    J’ai testé sur l’image carrée en 427x427.
    À la fin j’ai ajouté un log à l’entrée qui témoigne que la fonction reçoit les arguments suivants : (427, 427, 200, 200) et un log à la fin qui montre ce qui va être renvoyé

    log("image_ratio renvoie ceil($destWidth)=".ceil($destWidth)
            .", ceil($destHeight)=".ceil($destHeight)
            .", max($ratioWidth, $ratioHeight)=".max($ratioWidth, $ratioHeight)) ;
    


    Et ça donne ça :

    image_ratio renvoie ceil(200)=200, ceil(200)=201, max(2.135, 2.135)=2.135
    

    Le 2eme "200" traîne un karma nano-décimal inconscient issu d’une mauvaise expérience d’arrondi à sa naissance ($destHeight = $srcHeight / $ratioWidth ; dans les lignes précédentes) et le ceil PHP en abuse violemment.

  • FFmpeg api iOS "Resource temporarily unavailable"

    8 octobre 2017, par Julius Naeumann

    I’ve spent hours trying to fix this :

    I’m trying to use the ffmpeg api on iOS. My Xcode project is building and I can call ffmpeg api functions. I am trying to write code that decodes a video (Without outputting anything for now), and I keep getting error -35 : "Resource temporarily unavailable".

    The input file is from the camera roll (.mov) and I’m using Mpeg-4 for decoding. All I’m currently doing is getting data from the file, parsing it and sending the parsed packets to the decoder. When I try to get frames, all I get is an error. Does anyone know what I’m doing wrong ?

    +(void)test: (NSString*)filename outfile:(NSString*)outfilename {

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

    AVCodec *codec;
    AVCodecParserContext *parser;
    AVCodecContext *c= NULL;
    int frame_count;
    FILE* f;
    AVFrame* frame;
    AVPacket* avpkt;
    avpkt = av_packet_alloc();
    //av_init_packet(avpkt);
    char buf[1024];

    uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
    uint8_t *data;
    size_t   data_size;

    /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
    memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);

    printf("Decode video file %s to %s\n", [filename cStringUsingEncoding:NSUTF8StringEncoding], [outfilename cStringUsingEncoding:NSUTF8StringEncoding]);
    /* find the h264 video decoder */
    codec = avcodec_find_decoder(AV_CODEC_ID_MPEG4);
    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(1);
    }
    if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
       c->flags |= AV_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_open2(c, codec, NULL) < 0) {
       fprintf(stderr, "Could not open codec\n");
       exit(1);
    }
    f = fopen([filename cStringUsingEncoding:NSUTF8StringEncoding], "rb");
    if (!f) {
       fprintf(stderr, "Could not open %s\n", [filename cStringUsingEncoding:NSUTF8StringEncoding]);
       exit(1);
    }
    frame = av_frame_alloc();
    if (!frame) {
       fprintf(stderr, "Could not allocate video frame\n");
       exit(1);
    }
    frame_count = 0;

    parser = av_parser_init(codec->id);
    if (!parser) {
       fprintf(stderr, "parser not found\n");
       exit(1);
    }

    while (!feof(f)) {
       /* read raw data from the input file */
       data_size = fread(inbuf, 1, INBUF_SIZE, f);
       if (!data_size)
           break;
       /* use the parser to split the data into frames */
       data = inbuf;
       while (data_size > 0) {
           int ret = av_parser_parse2(parser, c, &avpkt->data, &avpkt->size, data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
           if (ret < 0) {
               fprintf(stderr, "Error while parsing\n");
               exit(1);
           }
           data      += ret;
           data_size -= ret;
           if (avpkt->size){
               char buf[1024];

               ret = avcodec_send_packet(c, avpkt);
               if (ret < 0) {

                   fprintf(stderr, "Error sending a packet for decoding\n");
                   continue;
                   exit(1);
               }

               while (ret >= 0) {
                   ret = avcodec_receive_frame(c, frame);
                   if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF){
                       char e [1024];
                       av_strerror(ret, e, 1024);
                       fprintf(stderr, "Fail: %s !\n", e);
    // ~~~~~~~~ This is where my program exits ~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       return;
                   }
                   else if (ret < 0) {
                       fprintf(stderr, "Error during decoding\n");
                       exit(1);
                   }
               }


           }
       }
    }
    /* 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 */

    fclose(f);
    avcodec_close(c);
    av_free(c);
    av_frame_free(&frame);
    printf("\n");

    }

  • Increase Duration of a video FFMPEG C++

    9 avril 2015, par Shahroz Tariq

    I am using the code from the samples of FFmpeg which encodes a picture into a video. All I want to do is to give it a series of pictures and it gives me a video with each picture is taking one second`Code below is just taking one picture from my file system & creating video from it

    AVCodec *codec;
    AVCodecContext *c = NULL;
    int i, ret, x, y, got_output;
    FILE *f;

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

    /* put sample parameters */
    c->bit_rate = 400000;
    /* resolution must be a multiple of two */
    c->width = 200;
    c->height = 200;
    /* frames per second */
    AVRational rational;
    rational.num = 1;
    rational.den = 25;
    c->time_base = rational;
    /* 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(1);
    }

    fopen_s(&f, filename, "wb");
    if (!f)
    {
       fprintf(stderr, "Could not open %s\n", filename);
       exit(1);
    }
    AVFrame *frame = OpenImage("..\\..\\..\\..\\..\\..\\1.jpg");
    //frame = av_frame_alloc();
    if (!frame)
    {
       fprintf(stderr, "Could not allocate video frame\n");
       exit(1);
    }

    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 */

    int screenHeight = 200;
    int screenWidth = 200;
    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);



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

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

       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]);
    av_frame_free(&frame);
    printf("\n");`