Recherche avancée

Médias (0)

Mot : - Tags -/interaction

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

Autres articles (67)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

Sur d’autres sites (5973)

  • FFmpeg : avcodec_encode_video() and JPEG images

    2 février 2012, par user105909

    I'm trying to encode a series of .jpg files into a video using the ffmpeg library, and I can't seem to get the frames to encode. (I have to use the ffmpeg library, and using ffmpeg from a command line is not an option in my case.)

    Except for the part where I'm trying to open JPG files as AVFrames, my code is more or less the same thing as found in api-example.c from the ffmpeg library. When I populate the frames as the example does, everything works as expected. In the code below, I fail to encode any frames. Obviously the trouble is related to how I'm opening the JPG files, but I can't figure out what.

    I'm opening the image like this :

    AVFrame* open_image(const char* imageFileName, int width, int height, long * bufSize)
    {
       AVFormatContext *pFormatCtx;

       if(av_open_input_file(&pFormatCtx, imageFileName, NULL, 0, NULL)!=0)
       {
           printf("Can't open image file '%s'\n", imageFileName);
           return NULL;
       }      

       AVCodecContext *pCodecCtx;

       pCodecCtx = pFormatCtx->streams[0]->codec;
       pCodecCtx->width = width;
       pCodecCtx->height = height;
       pCodecCtx->pix_fmt = PIX_FMT_YUV420P;

       // Find the decoder for the video stream
       AVCodec *pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
       if (!pCodec)
       {
           printf("Codec not found\n");
           return NULL;
       }

       // Open codec
       if(avcodec_open(pCodecCtx, pCodec)<0)
       {
           printf("Could not open codec\n");
           return NULL;
       }

       AVFrame *pFrame = avcodec_alloc_frame();
       if (!pFrame)
       {
           LOGV(TAG, "Can't allocate memory for AVFrame\n");
           return NULL;
       }

       int frameFinished;
       int numBytes;

       // Determine required buffer size and allocate buffer
       numBytes = avpicture_get_size(PIX_FMT_YUVJ420P, pCodecCtx->width, pCodecCtx->height);

       // ***
       *bufSize = numBytes;
       // ***

       uint8_t *buffer = (uint8_t *) av_malloc(numBytes * sizeof(uint8_t));

       avpicture_fill((AVPicture *) pFrame, buffer, PIX_FMT_YUVJ420P, pCodecCtx->width, pCodecCtx->height);

       // Read frame

       AVPacket packet;

       int framesNumber = 0;
       while (av_read_frame(pFormatCtx, &packet) >= 0)
       {
           if(packet.stream_index != 0)
               continue;

           int ret = avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
           if (ret > 0)
           {
               sprintf(buf, "Frame is decoded, size %d", ret);
               LOGV(TAG, buf);
               pFrame->quality = 4;
               return pFrame;
           }
           else {
               // printf("Error [%d] while decoding frame: %s\n", ret, strerror(AVERROR(ret)));
               sprintf(buf, "Error %d decoding frame: %s", ret, strerror(AVERROR(ret)));
               LOGV(TAG, buf);
           }
       }
    }

    ...and attempting to encode them like this :

    DIR * dir = opendir(path);
    int i = 0;

    if (dir != NULL) {

       for(struct dirent *ent = readdir(dir); ent != NULL; ent = readdir(dir)) {
           fflush(stdout);

           printf("%s/%s", path, ent->d_name);
           LOGV(TAG, filename);

           // If not a jpg file, pass it over
           const char * ext = strrchr(filename, '.');
           if((!ext) || (strcmp(ext, ".jpg"))) {
               continue;
           }

           /*** NOTE: Is this where I've gone wrong? Bufsize is set in open_image based on av_picture_size() */
           long bufSize = 0L;
           AVFrame * frame = open_image(filename, width, height, &bufSize);
           if(frame) {
               // This is what it needs to do, and it does not work.
               // Causes:
               // Wrong format?
               // Wrong buffer size?
               uint8_t * picBuf = (uint8_t *)malloc(bufSize);

               out_size = avcodec_encode_video(c, picBuf, bufSize, frame);

               printf("encoding frame %3d (size=%5d)\n", i++, out_size);
               /** On the first image, out_size is 0. On the next, it's -1, and fails. */

               if(out_size < 0) {
                   printf("Error encoding frame");
                   return -6;
               }

               fwrite(picBuf, 1, bufSize, f);

               free(picBuf);
               av_free(frame);
           }
           else {
               printf("Couldn't open image");
               return -5;
           }
       }

       closedir(dir);
    }
    else {
       printf("Couldn't open directory %s\n", path);
       return -4;
    }

    Could someone point me in the right direction ?

  • Change file format from flv to anything android will play

    19 octobre 2011, par Bilthon

    I need to take this file which encoded is in h264 but in a flv container and just put it in a mp4, 3gp or whatever file format the android MediaPlayer will understand.

    I want to do this natively. As I will not be decoding nor encoding anything I think I will not be wasting a lot of power (am I wrong ?)

    I followed the instructions from here http://www.roman10.net/?p=394 and could sucessfully compile and use ffmpeg and use it with mp4 and 3gp files.

    But when it comes to flv files it fails. I understand there is no format definition for flv files in that specific port of ffmpeg for android.

    There is no libavformat/flv.h header file for instance.

    Maybe that's why this works :

    extern AVInputFormat ff_mov_demuxer ;
    av_register_input_format(&ff_mov_demuxer) ;

    While this fails :

    extern AVInputFormat ff_flv_demuxer;
    av_register_input_format(&ff_flv_demuxer);

    Question is, is there a light at the end of the tunnel ? has someone done something similar ? is it useful ? I mean, I can always just throw the flv media file into a flash player and voila.. the thing is that this would be a parcial solution, as it will not work for all those folks running slower devices that can't yet run Flash.

    Nelson

    PS. Just in case. Here's some info about the file I'm talking about :

    ffmpeg -i rio.flv
    ffmpeg version N-32624-gea8de10, Copyright (c) 2000-2011 the FFmpeg developers
     built on Sep 15 2011 23:31:42 with gcc 4.5.2
     configuration: --enable-libfaac --enable-libmp3lame --enable-librtmp --enable-libtheora --enable-libx264 --enable-libxvid --enable-gpl --enable-nonfree
     libavutil    51. 16. 0 / 51. 16. 0
     libavcodec   53. 15. 0 / 53. 15. 0
     libavformat  53. 12. 0 / 53. 12. 0
     libavdevice  53.  3. 0 / 53.  3. 0
     libavfilter   2. 42. 0 /  2. 42. 0
     libswscale    2.  1. 0 /  2.  1. 0
     libpostproc  51.  2. 0 / 51.  2. 0

    Seems stream 0 codec frame rate differs from container frame rate: 2000.00 (2000/1) -> 14.99 (15000/1001)
    Input #0, flv, from 'rio.flv':
     Duration: 00:01:00.06, start: 0.000000, bitrate: 783 kb/s
       Stream #0.0: Video: h264 (Main), yuv420p, 704x480 [SAR 10:11 DAR 4:3], 14.99 tbr, 1k tbn, 2k tbc
  • Is using QtFFmpegWrapper+QLabel+QTimer a good way to play video in a Qt application ?

    21 décembre 2012, par Vi.

    I'm looking how to portably play video on Qt, but not Phonon.

    Using ffmpeg seems to be a good idea (it should work the same way on all platforms).

    Currently It uses QLabel for video output and does QPixmap::fromImage for each frame ; frames which are decoded and buffered by QtFFmpegWrapper in a background thread. QTimer decides when to show the next frame.

    The whole thing looks a bit hacky (Video ? In a label ?). Am I doing it right ? Is there a better portable way of playing ffmpeg-decoded video in a Qt application ?