Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

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

Autres articles (79)

  • Les images

    15 mai 2013
  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

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

Sur d’autres sites (9214)

  • How to reliably get thumbnail images with libavcodec for H.264 I Frames

    9 août 2013, par Brad Mitchell

    I'm trying to extract out thumbnails using libavcodec from H.264 encoded video in an MP4 file.

    I'm finding that generating an image from an I-Frame every 30 or so seconds, is not resulting in a correct image. Every I-Frame (about every second) is producing a correct image.

    My understanding is that I-Frames can be decoded independently, and although avcodec_decode_video2 is saying that it was decoded, the encoded PNG doesn't look right at all.

    The basic code I'm using :

    AVIOContext* pIOCtx = avio_alloc_context(pBuffer, iBufSize, 0, mp4Obj, ReadFunc, 0, SeekFunc)
    AVFormatContext *pFormatCtx = avformat_alloc_context();
    pFormatCtx->pb - pIOCtx;
    pFormatCtx->flags = AVFMT_FLAG_CUSTOM_IO;

    if (avformat_open_input(&pFormatCtx, "", 0, 0) != 0)
       return -1;

    if (avformat_find_stream_info(pFormatCtx, NULL) < 0)
       return -1;

    AVCodec* videoDec;
    AVCodec* audioDec;

    int inputVs = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &videoDec, 0);
    int inputAs = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, &audioDec, 0);
    AVCodecContext* videoInCodecContext = pFormatCtx->streams[inputVs]->codec;
    AVCodecContext* audioInCodecContext = pFormatCtx->streams[inputAs]->codec;

    AVCodec* videoInCodec = avcodec_find_decoder(CODEC_ID_H264);
    avcodec_open2(videoInCodecContext, videoInCodec, NULL);

    AVPacket* packet = (AVPacket*)av_mallocz(sizeof(AVPacket));
    while (av_read_frame(pFormatCtx, packet) >= 0)
    {
       AVPacket* pkt = (AVPacket*)av_mallocz(sizeof(AVPacket));
       *pkt = *packet;
       pkt->data = reinterpret_cast(new uint64_t[(packet->size + FF_INPUT_BUFFER_PADDING_SIZE)/sizeof(uint64_t) + 1]);
       // NOTE, copying the packet is for a different purpose, as in the real application
       //       the data is put onto a queue
       memcpy(pkt->data, packet->data, packet->size);

       ...
       ...

       // check in here if the pts > minimum pts etc,
       // minimum is the last video pts + pkt_timebase.den * 30

       if ((videoInCodecContext != NULL) && (firstImage == FALSE ||
                                             firstImage == TRUE && pkt->flags)))
       {
           AVFrame* picture = avcodec_alloc_frame();
           int got_picture = 0;
           int pts = pkt->pts;
           int dts = pkt->dts;
           //pkt->pts = pkt->dts = 0;

           int len = avcodec_decode_video2(videoInCodecContext, picture, &got_picture, pkt);
           if (len < 0)
               // error
           else if (got_picture)
           {
               firstImage = TRUE;

               // calculate thumbnail dimensions
               // encode thumbnail to png
           }
           av_free(picture);
       }
    }
  • How to create a video thumbnail without ffmpeg or HTML5 video canvas ? [duplicate]

    14 mai 2014, par user3631926

    This question already has an answer here :

    I need to create a thumbnail from a video, I have tried the below options but they didn’t work for my case. I am using S3 and CloudFront.

    1. ffmpeg is not supported via my hosting because I am using a shared hosting and I need to upgrade to VPS or dedicated server if I want to use ffmpeg.

    2. I tried taking a screenshot from the video using HTML5 drawImage and toDataURL functions, but it is throwing SecurityError because my video file is located on Amazon CloudFront and my code is hosted somewhere else.

    Is there any other option or a workaround to the second option ? I don’t want to upgrade my server for just the thumbnail issue.

  • FFMpeg video thumbnail frame extraction

    30 mars 2012, par Simone Margaritelli

    i'm trying to extract a thumbnail from a video with ffmpeg, therefore i'm using the command line :

    ffmpeg -i video.mp4 -vframes 1 -an -f image2 -y thumbmail.png 2>&1

    But in most cases, the first frame is completely black.
    So, what i'm doing is :

    for( $i = 1; $i < MAX_FRAME_CHECKING; $i++ )
    {
     $cmd = sprintf( 'ffmpeg -i video.mp4 -vframes 1 -an -vf select="eq(n\,%d)"-f image2 -y thumbmail.png 2>&1', $i );

     @exec( $cmd, $aOutput, $iReturnValue );

     if( self::isGoodKeyFrame( 'thumbmail.png' ) )
       break;
    }

    Where the isGoodKeyFrame method is defined as :

    private static function isGoodKeyFrame( $sImagePath )
    {
     if( class_exists('Imagick') )
     {
       $hImagick = new Imagick();

       try
       {
         if ( $hImagick->readImage($sImagePath) && $hImagick->valid() )
         {
           $hQuantized = @$hImagick->clone( );
           $hQuantized->quantizeImage( 255, Imagick::COLORSPACE_RGB, 0, TRUE, FALSE );

           return count( $hQuantized->getImageHistogram() ) > self::HISTOGRAM_SIZE_THRESHOLD;
         }
         else
           error_log( "'$sImagePath' is not a valid image." );
       }
       catch( Exception $e )
       {
         error_log( $e->getMessage() );
       }

       $hImagick->clear( );
       $hImagick->destroy( );

     }
     else
       error_log( 'Imagick not installed.' );

     return TRUE;
    }

    So basically what i'm doing is capture 1 to MAX_FRAME_CHECKING frames, check their color histogram and when i find something with much colors than my minimum threshold i break the loop and return that frame.

    Is there a way to do this natively with ffmpeg ?

    Thanks