Changeset 386 for trunk/uploadr

Show
Ignore:
Timestamp:
05/03/08 00:00:56 (4 months ago)
Author:
mygrant
Message:

Seek directly to the time we want and grab that frame instead of looping through all of them

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/uploadr/MacUploadr.app/Contents/Resources/components/flGM.cpp

    r381 r386  
    874874        // Play through 15% of the video 
    875875        int64_t seek = (int64_t)(0.00000015 * (double)format_ctx->duration * fps); 
    876         int i = 0; 
    877876        AVPacket packet; 
    878877        int have_frame; 
    879878        struct SwsContext *toRGB_convert_ctx; 
     879         
     880        // Seek to the exact frame we want 
     881        av_seek_frame(format_ctx, stream, seek, 0); 
     882         
    880883        while (0 <= av_read_frame(format_ctx, &packet)) { 
    881884                if (packet.stream_index == stream) { 
     
    883886                                 packet.data, packet.size); 
    884887                         
    885                         if (have_frame && seek == ++i) { 
     888                        if (have_frame) { 
    886889                                //img_convert((AVPicture *)img_frame, PIX_FMT_RGB24, 
    887890                                //      (AVPicture*)video_frame, codec_ctx->pix_fmt, 
     
    893896                                        sws_flags, NULL, NULL, NULL); 
    894897                                if (toRGB_convert_ctx == NULL) { 
    895                                         av_log(NULL, AV_LOG_ERROR, 
    896                                                 "Cannot initialize the toRGB conversion context\n"); 
    897                                         exit(1); 
     898                                        return NS_ERROR_NULL_POINTER; 
    898899                                } 
    899900