Recherche avancée

Médias (0)

Mot : - Tags -/tags

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

Autres articles (38)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

  • 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 (...)

  • 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 (4896)

  • Why decoding frames from avi container and encode them to h264/mp4 doesn't work ?

    28 novembre 2013, par theateist

    I started using ffmpeg and I want to convert avi file to mp4/h264 file. I've read many posts including this, but I couldn't find any good example how to save frames to mp4 file. The code below is simplified one that decodes frames from avi file and encode it to H264/mp4 file, but when I save the frames the mp4 file cannot be played. I think I do somethinkg wrong in encoding

    I will appreciate if you could tell me what is wrong and how to fix it.

    const char* aviFileName = "aviFrom.avi";
    const char* mp4FileName = "mp4To.mp4";

    // Filling pFormatCtx by open video file and Retrieve stream information
    // ...
    // Retrieving codecCtxDecode and opening codecDecode
    //...


    // Get encoder
    codecCtxEncode = avcodec_alloc_context();  
    codecCtxEncode->qmax = 69;
    codecCtxEncode->max_qdiff = 4;
    codecCtxEncode->bit_rate = 400000;
    codecCtxEncode->width = codecCtxDecode->width;
    codecCtxEncode->height = codecCtxDecode->height;
    codecCtxEncode->pix_fmt = AV_PIX_FMT_YUV420P;  
    codecEncode = avcodec_find_encoder(CODEC_ID_H264);
    if(codecEncode == NULL)
       return -1;  
    if(avcodec_open2(codecCtxEncode, codecEncode, NULL))
       return -1;

    SwsContext *sws_ctx = sws_getContext(codecCtxDecode->width, codecCtxDecode->height, codecCtxDecode->pix_fmt,
                               codecCtxDecode->width, codecCtxDecode->height, AV_PIX_FMT_YUV420P,
                               SWS_BILINEAR, NULL, NULL, NULL);

    // Allocate an AVFrame structure    
    frameDecoded = avcodec_alloc_frame();
    frameEncoded = avcodec_alloc_frame();    

    avpicture_alloc((AVPicture *)frameEncoded, AV_PIX_FMT_YUV420P, codecCtxDecode->width, codecCtxDecode->height);

    while(av_read_frame(pFormatCtx, &packet)>=0)
    {      
       // Is this a packet from the video stream?
       if(packet.stream_index==videoStreamIndex) {
           avcodec_decode_video2(codecCtxDecode, frameDecoded, &frameFinished, &packet);
           // Did we get a video frame?
           if(frameFinished)
           {          
               fwrite(packet.data, packet.size,
               sws_scale(sws_ctx, frameDecoded->data, frameDecoded->linesize, 0, codecCtxDecode->height,
                           frameEncoded->data, frameEncoded->linesize);



               int64_t pts = packet.pts;
               av_free_packet(&packet);
               av_init_packet(&packet);
               packet.data = NULL;
               packet.size = 0;    
               frameEncoded->pts = pts;                

               int failed = avcodec_encode_video2(codecCtxEncode, &packet, frameEncoded, &got_output);
               if(failed)
               {
                   exit(1);
               }
               fwrite(packet.data,1,packet.size, mp4File);
           }
       }

       av_free_packet(&packet);
    }
  • Encode image to video using ffmpeg (sws_scale)

    26 septembre 2012, par bahar_p

    I'm trying to encode an image to video using ffmpeg library.
    I have these global params :

    //Global params
    AVCodec         *codec;
    AVCodecContext  *codecCtx;
    uint8_t         *output_buffer;
    int             output_buffer_size;

    I divided the encoding to 3 methods :
    Initialize the encoder :

    jint Java_com_camera_simpledoublewebcams2_CameraPreview_initencoder(JNIEnv* env,jobject thiz){
    avcodec_register_all();
    avcodec_init();
    av_register_all();

    int fps = 30;

    /* find the H263 video encoder */
    codec = avcodec_find_encoder(CODEC_ID_H263);
    if (!codec) {
       LOGI("avcodec_find_encoder() run fail.");
       return -5;
    }

    //allocate context
    codecCtx = avcodec_alloc_context();

    /* put sample parameters */
    codecCtx->bit_rate = 400000;
    /* resolution must be a multiple of two */
    codecCtx->width = 176;
    codecCtx->height = 144;
    /* frames per second */
    codecCtx->time_base = (AVRational){1,fps};
    codecCtx->pix_fmt = PIX_FMT_YUV420P;
    codecCtx->codec_id = CODEC_ID_H263;
    codecCtx->codec_type = AVMEDIA_TYPE_VIDEO;

    /* open it */
    if (avcodec_open(codecCtx, codec) < 0) {
       LOGI("avcodec_open() run fail.");
       return -10;
    }

    //init buffer
    output_buffer_size = 500000;
    output_buffer = malloc(output_buffer_size);

    return 0;

    }

    Encoding the image :

    jint Java_com_camera_simpledoublewebcams2_CameraPreview_encodejpeg(JNIEnv* env,jobject thiz,jchar* cImage, jint imageSize){
    int             out_size;
    AVFrame         *picture;
    AVFrame         *outpic;
    uint8_t         *outbuffer;

    //allocate frame    
    picture = avcodec_alloc_frame();    
    outpic = avcodec_alloc_frame();

    int nbytes = avpicture_get_size(PIX_FMT_YUV420P, codecCtx->width, codecCtx->height);
    outbuffer = (uint8_t*)av_malloc(nbytes);
    outpic->pts = 0;

    //fill picture with image
    avpicture_fill((AVPicture*)picture, (uint8_t*)cImage, PIX_FMT_RGBA, codecCtx->width, codecCtx->height);
    //fill outpic with empty image
    avpicture_fill((AVPicture*)outpic, outbuffer, PIX_FMT_YUV420P, codecCtx->width, codecCtx->height);

    //rescale the image
    struct SwsContext* fooContext = sws_getContext(codecCtx->width, codecCtx->height,
                                                          PIX_FMT_RGBA,
                                                          codecCtx->width, codecCtx->height,
                                                          PIX_FMT_YUV420P,
                                                          SWS_FAST_BILINEAR, NULL, NULL, NULL);
    sws_scale(fooContext, picture->data, picture->linesize, 0, codecCtx->height, outpic->data, outpic->linesize);  

    //encode the image
    out_size = avcodec_encode_video(codecCtx, output_buffer, output_buffer_size, outpic);
    out_size += avcodec_encode_video(codecCtx, output_buffer, output_buffer_size, outpic);

    //release pictures
    av_free(outbuffer);
    av_free(picture);
    av_free(outpic);

    return out_size;

    }

    And closing the encoder :

    void Java_com_camera_simpledoublewebcams2_CameraPreview_closeencoder(JNIEnv* env,jobject thiz){
    free(output_buffer);
    avcodec_close(codecCtx);
    av_free(codecCtx);

    }

    When I send the first image, I get a result from the encoder. When I try to send another image the program crashes.
    I tried calling init once and then the images, then the close - didn't work.
    I tried calling the init and the close for every image - didn't work.

    Any suggestions ?

    Thanks !

    EDIT : After further research I found that the problem is at sws_scale method.
    Still don't know what is causing this issue...

  • screenrecorder appliaction. video output size issues [closed]

    25 juin 2022, par jNc

    Having working github project
https://github.com/abdullahfarwees/screen-recorder-ffmpeg-cpp

    


    All works perfectly fine, but output video resolution is not correct
I need to change output video resolution

    


    Using ubuntu/gcc/opencv/

    


    [...]
outAVCodecContext->bit_rate = 400000; // 2500000
outAVCodecContext->width = 1920; // <- change this one
outAVCodecContext->height = 1080; // <- and also this one
outAVCodecContext->gop_size = 3;
[...]