Changeset 6260 in orxonox.OLD for branches/avi_play
- Timestamp:
- Dec 22, 2005, 5:08:39 PM (19 years ago)
- Location:
- branches/avi_play/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/avi_play/src/lib/graphics/importer/media_container.cc
r6254 r6260 75 75 } 76 76 77 SDL_Surface* MediaContainer::getFrame(float time_stamp) 78 { 79 if (time_stamp != AV_NOPTS_VALUE) 77 SDL_Surface* MediaContainer::getFrame(int frame_number) 78 { 79 // seek doesnt work for the first two frames 80 // you will get ugly fragments 81 if(frame_number < 2) 82 return this->getNextFrame(); 83 else 80 84 { 81 /* add the stream start time */ 82 //time_stamp += AV_NOPTS_VALUE; 83 //PRINTF(1)("starttime %f\n", format_context->start_time); 84 //time_stamp += format_context->start_time; 85 int err = av_seek_frame(format_context, video_stream, time_stamp, AVSEEK_FLAG_BACKWARD); 86 if (err < 0) 87 { 88 PRINTF(1)("could not seek to position %f\n", time_stamp); 89 return NULL; 90 } 91 85 // seeks to the nearest keyframe 86 // NOTE: there is only about every 5s a keyframe! 87 av_seek_frame(format_context, video_stream, frame_number, AVSEEK_FLAG_BACKWARD); 88 89 // go from the keyframe to the exact position 90 codec_context->hurry_up = 1; 91 do { 92 av_read_frame(format_context, &packet); 93 if(packet.pts >= frame_number-1) 94 break; 95 int frame_finished; 96 avcodec_decode_video(codec_context, frame, &frame_finished, packet.data, packet.size); 97 av_free_packet(&packet); 98 } while(1); 99 codec_context->hurry_up = 0; 100 92 101 return this->getNextFrame(); 93 102 } 94 95 return this->getNextFrame();96 103 } 97 104 … … 114 121 if(frame_finished) 115 122 { 116 //PRINTF(1)("frame_number: %i\n", this->getFrameNumber());123 PRINTF(1)("frame_number: %i\n", this->getFrameNumber()); 117 124 // Conversion from YUV to RGB 118 125 // Most codecs return images in YUV 420 format … … 128 135 data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)]; 129 136 for(int i = 0; i < codec_context->height; i++) 130 memcpy(&data[i*codec_context->width*3], picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3); 137 memcpy(&data[i*codec_context->width*3], picture->data[0]+i * 138 picture->linesize[0],codec_context->width*sizeof(uint8_t)*3); 131 139 132 140 surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width, … … 285 293 PRINTF(1)("nb_frames: %i\n", format_context->streams[video_stream]->nb_frames); 286 294 PRINTF(1)("r_frame_rate: %i\n", format_context->streams[video_stream]->r_frame_rate.num); 287 PRINTF(1)(" FPS: %f\n", av_q2d(format_context->streams[video_stream]->r_frame_rate));295 PRINTF(1)("fps: %0.2f\n", av_q2d(format_context->streams[video_stream]->r_frame_rate)); 288 296 PRINTF(1)("========================\n"); 289 297 PRINTF(1)("= AVCodecContext =\n"); -
branches/avi_play/src/lib/graphics/importer/media_container.h
r6254 r6260 52 52 ~MediaContainer(); 53 53 54 SDL_Surface* getFrame( float time_stamp);54 SDL_Surface* getFrame(int frame_number); 55 55 SDL_Surface* getNextFrame(); 56 56 vector<SDL_Surface*> getFrameList(); -
branches/avi_play/src/subprojects/importer/multitex.cc
r6254 r6260 54 54 fps = movie->getFPS(); 55 55 56 float start_time = atoi(argv[2]);56 int start_time = atoi(argv[2]); 57 57 58 58 // print information about the media file
Note: See TracChangeset
for help on using the changeset viewer.