Recherche avancée

Médias (91)

Autres articles (63)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

Sur d’autres sites (9091)

  • Generate video from bitmap images using FFMPEG

    29 juin 2013, par Pferd

    I'm trying to encode a bunch of images into a video using FFMPEG in visual studio. However I couldnt get it. Can some one please tell me where am I going wrong. please find the attached code here !

    void Encode::encodeVideoFromImage(char* filename){


     // gET THE encoder here. ~ try with mpeg1Video as a start!
     int i;
     AVCodec* codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
    //AVCodec* codec = avcodec_find_encoder(CODEC_ID_MPEG4);
    //AVCodec* codec = avcodec_find_encoder(CODEC_ID_MPEG2VIDEO);

    if (!codec)
    {
       MessageBox(_T("can't find codec"), _T("Warning!"), MB_ICONERROR | MB_OK);
    }

    // Initialize codec

    AVCodecContext* c = avcodec_alloc_context();

    // Put sample parameters
    c->bit_rate = 400000;
    // Resolution must be a multiple of two
    c->width = 800;
    c->height = 600;  
    c->time_base.num = 1;
    c->time_base.den = 25;
    c->gop_size = 8; // Emit one intra frame every ten frames
    c->max_b_frames=1;
    c->pix_fmt = PIX_FMT_YUV420P;

    // Open the codec.
    if (avcodec_open(c, codec) < 0)
    {
      // fprintf(stderr, "could not open codec\n");
        MessageBox(_T("can't open codec"), _T("Warning!"), MB_ICONERROR | MB_OK);
    }


    // Open the output file
    FILE* f = fopen(filename, "wb");
    if (!f)
    {
       // fprintf(stderr, "could not open %s\n", filename);
        MessageBox(_T("Unable to open file"), _T("Warning!"), MB_ICONERROR | MB_OK);
    }

    // alloc image and output buffer
    int in_width, in_height, out_width, out_height;

    //here, make sure inbuffer points to the input BGR32 data,
    //and the input and output dimensions are set correctly.

    int out_size=1000000;

    in_width=c->width;
    out_width=c->width;
    in_height=c->height;
    out_height=c->height;

       //create ffmpeg frame structures.  
    AVFrame* inpic = avcodec_alloc_frame();
    AVFrame* outpic = avcodec_alloc_frame();

    // bytes needed for the output image
    int nbytes = avpicture_get_size(PIX_FMT_BGR32, out_width, out_height);

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

    CImage capImage;
    CString pictureNumber;

    /* encode 1 frame of video */

    for(i=0;i<50;i++) {
        fflush(stdout);
        /* Use existing images */
        pictureNumber="";          
        pictureNumber.Format(_T("%d"),i+1);

    capImage.Load(_T("C:\\imageDump\\test")+pictureNumber+_T(".bmp")); // TBD from memory!
       //MessageBox(_T("C:\\imageDump\\test")+pictureNumber+_T(".bmp"), _T("Warning!"), MB_ICONERROR | MB_OK);
    inbuffer =  (uint8_t*)capImage.GetBits();


           // convert RGB to YUV 420 here!
           //  RGBtoYUV420P(pBits,picture_buf,bpp,true,c->width,c->height,false);
    //inbuffer=pBits;

    avpicture_fill((AVPicture*)inpic, inbuffer, PIX_FMT_BGR32, in_width, in_height);
    avpicture_fill((AVPicture*)outpic, outbuffer, PIX_FMT_YUV420P, out_width, out_height);

    //create the conversion context
    SwsContext* fooContext = sws_getContext(in_width, in_height, PIX_FMT_BGR32, out_width, out_height, PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);

    //perform the conversion
    sws_scale(fooContext, inpic->data, inpic->linesize, 0, in_height, outpic->data, outpic->linesize);

    out_size = avcodec_encode_video(c, outbuffer, out_size, inpic);
       //printf("encoding frame %3d (size=%5d)\n", i, out_size);
    fwrite(outbuffer, 1, out_size, f);
    capImage.Destroy();
    //free(inbuffer);
    }

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

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

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

    avcodec_close(c);
    av_free(c);
    av_free(inpic);
    av_free(outpic);
    //printf("\n");

    }

    Thank you !

  • Convert MPEG4 to MPEGTS on Android with FFmpeg

    3 juin 2013, par Ardoramor

    Ok, so obviously I know very little to none about ffmpeg API when I made the original post... it is quite overwhelming when one starts learning about digital media and conversion details. After reading quite a bit more and going through ffmpeg source, I was able to get a working output from mp4 to mpegts. The concept is similar to executing :

    ffmpeg -i in.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb out.ts

    But as I mentioned before, I need to implement it with ffmpeg API in C.

    So, although I am able to generate a playable .ts file, its video and audio streams are not synced. That is, playing them back on Android tablet plays the video very slowly while audio is playing at normal speed and then (once audio stream ends) video plays at normal speed to the end. Playing the same generated .ts file in VLC produces a very condensed audio (as though fast-forwarded) and plays video fine.

    There are still many aspects of media conversion that I am not familiar with. I am sure that some of them prevent me from successful conversion.

    Here is some information (via ffprobe) about the files :
    - in.mp4 - file generated via Android recording - MPEG4 (H.264 + AAC)
    - ffmpeg.ts - file generated via ffmpeg conversion - MPEG2TS (H.264 + AAC)
    - out.ts - file generated via my code - MPEGTS (H.264 + AAC)

    in.mp4

    filename=in.mp4
    nb_streams=2
    format_name=mov,mp4,m4a,3gp,3g2,mj2
    format_long_name=QuickTime/MPEG-4/Motion JPEG 2000 format
    start_time=0:00:00.000000
    duration=0:00:09.961383
    size=4.730 Mibyte
    bit_rate=3.983 Mbit/s
    TAG:major_brand=isom
    TAG:minor_version=0
    TAG:compatible_brands=isom3gp4
    TAG:creation_time=2013-05-28 17:06:57

    ffmpeg.ts

    filename=ffmpeg.ts
    nb_streams=2
    format_name=mpegts
    format_long_name=MPEG-2 transport stream format
    start_time=0:00:01.400000
    duration=0:00:09.741267
    size=5.132 Mibyte
    bit_rate=4.419 Mbit/s

    out.ts

    filename=out.ts
    nb_streams=2
    format_name=mpegts
    format_long_name=MPEG-2 transport stream format
    start_time=0:00:00.000000
    duration=0:00:09.741267
    size=5.166 Mibyte
    bit_rate=4.449 Mbit/s

    Firstly, I was unable to affect my output file's start_time. Next, upon examining the -show_packets output of probe, I saw the following :

    ffmpeg.ts

    [PACKET]
    codec_type=video
    stream_index=0
    pts=N/A
    pts_time=N/A
    dts=N/A
    dts_time=N/A
    duration=0
    duration_time=0:00:00.000000
    size=20.506 Kibyte
    pos=564
    flags=K
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=N/A
    pts_time=N/A
    dts=N/A
    dts_time=N/A
    duration=0
    duration_time=0:00:00.000000
    size=11.727 Kibyte
    pos=22936
    flags=_
    [/PACKET]
    ...
    [PACKET]
    codec_type=audio
    stream_index=1
    pts=126000
    pts_time=0:00:01.400000
    dts=126000
    dts_time=0:00:01.400000
    duration=2089
    duration_time=0:00:00.023211
    size=285.000 byte
    pos=109416
    flags=K
    [/PACKET]
    [PACKET]
    codec_type=audio
    stream_index=1
    pts=128089
    pts_time=0:00:01.423211
    dts=128089
    dts_time=0:00:01.423211
    duration=2089
    duration_time=0:00:00.023211
    size=374.000 byte
    pos=-1
    flags=K
    [/PACKET]
    ...
    [PACKET]
    codec_type=video
    stream_index=0
    pts=N/A
    pts_time=N/A
    dts=N/A
    dts_time=N/A
    duration=0
    duration_time=0:00:00.000000
    size=20.000 Kibyte
    pos=87232
    flags=_
    [/PACKET]
    [PACKET]
    codec_type=video
    stream_index=0
    pts=N/A
    pts_time=N/A
    dts=N/A
    dts_time=N/A
    duration=0
    duration_time=0:00:00.000000
    size=16.852 Kibyte
    pos=112800
    flags=_
    [/PACKET]

    out.ts

    [PACKET]
    codec_type=audio
    stream_index=1
    pts=0
    pts_time=0:00:00.000000
    dts=0
    dts_time=0:00:00.000000
    duration=2089
    duration_time=0:00:00.023211
    size=285.000 byte
    pos=22936
    flags=K
    [/PACKET]
    [PACKET]
    codec_type=audio
    stream_index=1
    pts=1024
    pts_time=0:00:00.011378
    dts=1024
    dts_time=0:00:00.011378
    duration=2089
    duration_time=0:00:00.023211
    size=374.000 byte
    pos=23312
    flags=K
    [/PACKET]
    ...

    [PACKET]
    codec_type=video
    stream_index=0
    pts=N/A
    pts_time=N/A
    dts=N/A
    dts_time=N/A
    duration=0
    duration_time=0:00:00.000000
    size=11.727 Kibyte
    pos=25004
    flags=_
    [/PACKET]
    [PACKET]
    codec_type=audio
    stream_index=1
    pts=7168
    pts_time=0:00:00.079644
    dts=7168
    dts_time=0:00:00.079644
    duration=2089
    duration_time=0:00:00.023211
    size=299.000 byte
    pos=55460
    flags=K
    [/PACKET]

    As you can see, ffmpeg.ts starts out with video packets that do not have pts/dts. The audio packets that follow contain pts/dts. This repeats until the end. All video packets do not have pts/dts according to ffprobe output.

    However, out.ts starts with audio packets and alternate with video packets. Here, video packets also do not have pts/dts. The difference is that here there is one video packet between a series of audio packets. What happened to the rest of the video packets (ffmpeg.ts has 5 audio followed by 5 video).

    Obviously, I'm still learning and don't know way too much yet... Does anything jump out as obvious a problem to anyone ? I will greatly appreciate any info / suggestions but will continue to grind at it !!

  • Encoded images into H264 video are skipped and/or missing ?

    25 juillet 2013, par Jona

    I'm trying to encode images into an H264 MP4 video. The issues I'm having is that some of the images are skipped or at the end of the video simply missing. I need the video to play every single image I encode since it is an animation.

    Any help setting the encoder properly would be greatly appreciated !

    Encoder settings :

    AVCodecContext *c;
    ...
    c->codec_id = AV_CODEC_ID_H264;
    c->bit_rate = mOutputWidth*mOutputHeight*4;//400000;
    /* Resolution must be a multiple of two. */
    c->width    = mOutputWidth;
    c->height   = mOutputHeight;
       /* timebase: This is the fundamental unit of time (in seconds) in terms
        * of which frame timestamps are represented. For fixed-fps content,
        * timebase should be 1/framerate and timestamp increments should be
        * identical to 1. */
    c->time_base.den = mFps;
    c->time_base.num = 1;
    c->gop_size      = 12; /* emit one intra frame every twelve frames at most */
    c->pix_fmt       = AV_PIX_FMT_YUV420P;
    ...
    av_dict_set(&pOptions, "preset", "medium", 0);
    av_dict_set(&pOptions, "tune", "animation", 0);

    /* open the codec */
    ret = avcodec_open2(c, codec, &pOptions);
    if (ret < 0) {
       LOGE("Could not open video codec: %s", av_err2str(ret));
       return -1;
    }

    Update 07/24/13 :
    I was able to achieve a better video by setting the gop_size=FPS and writing the last video frame repeatedly FPS+1 times seemed to resolve all issues. To me it seems odd to do that but might be something standard in the video encoding world ? Any tips feedback about this ?