Changeset 6401 in orxonox.OLD for branches/avi_play/src/lib/graphics/importer/media_container.cc
- Timestamp:
- Jan 3, 2006, 7:47:05 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/avi_play/src/lib/graphics/importer/media_container.cc
r6382 r6401 40 40 41 41 if (filename != NULL) 42 this->loadMedia(filename); 42 { 43 if(!this->loadMedia(filename)) 44 PRINTF(1)("MediaContainer::loadMedia() failed for %s\n", filename); 45 } 43 46 } 44 47 … … 74 77 } 75 78 76 voidMediaContainer::loadMedia(const char* filename)79 bool MediaContainer::loadMedia(const char* filename) 77 80 { 78 81 // register all formats and codecs … … 81 84 // Open video file 82 85 if (av_open_input_file(&format_context, filename, NULL, 0, NULL) !=0 ) 86 { 83 87 PRINTF(1)("Could not open %s\n", filename); 88 return false; 89 } 84 90 85 91 // Retrieve stream information 86 92 if (av_find_stream_info(format_context) < 0) 93 { 87 94 PRINTF(1)("Could not find stream information in %s\n", filename); 95 return false; 96 } 88 97 89 98 // Find the first video stream and take it … … 91 100 92 101 if(video_stream == -1) 102 { 93 103 PRINTF(1)("Could not find a video stream in %s\n", filename); 104 return false; 105 } 94 106 95 107 // Get a pointer to the codec context for the video stream … … 101 113 codec = avcodec_find_decoder(codec_context->codec_id); 102 114 if (codec == NULL) 115 { 103 116 PRINTF(1)("Could not find codec\n"); 117 return false; 118 } 104 119 105 120 // Open codec 106 121 if (avcodec_open(codec_context, codec) < 0) 122 { 107 123 PRINTF(1)("Could not open codec\n"); 124 return false; 125 } 108 126 109 127 // Allocate video frame … … 123 141 // Calculate fps 124 142 fps = av_q2d(format_context->streams[video_stream]->r_frame_rate); 143 // NOTE: fix this fps problem!! 144 if(fps < 0 || fps > 1000) 145 fps = 30; 125 146 126 147 // read the frames and save them in a sequence as textures 127 148 this->loadFrames(); 149 150 return true; 128 151 } 129 152
Note: See TracChangeset
for help on using the changeset viewer.