| 61 | } |
| 62 | |
| 63 | void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata) |
| 64 | { |
| 65 | avformat_network_init(); |
| 66 | |
| 67 | string inputFile = filename == "-" ? "pipe:" : filename; |
| 68 | m_AllowSeek = (filename != "-") && (filename.find("rtsp://") != 0) && (filename.find("udp://") != 0); |
| 69 | |
| 70 | if ((!m_FormatContextWasGiven) && avformat_open_input(&m_pFormatContext, inputFile.c_str(), nullptr, nullptr) != 0) { |
| 71 | destroy(); |
| 72 | throw logic_error(string("Could not open input file: ") + filename); |
| 73 | } |
| 74 | |
| 75 | if (avformat_find_stream_info(m_pFormatContext, nullptr) < 0) { |
| 76 | destroy(); |
| 77 | throw logic_error("Could not find stream information"); |
| 78 | } |
| 79 | |
| 80 | initializeVideo(preferEmbeddedMetadata); |
| 81 | m_pFrame = av_frame_alloc(); |
| 82 | } |
| 83 | |
| 84 | void MovieDecoder::destroy() |
| 85 | { |