| 87 | } |
| 88 | |
| 89 | void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track, const std::map<std::string, std::string> &LAVFOpts) { |
| 90 | AVDictionary *Dict = nullptr; |
| 91 | for (const auto &iter : LAVFOpts) |
| 92 | av_dict_set(&Dict, iter.first.c_str(), iter.second.c_str(), 0); |
| 93 | |
| 94 | if (avformat_open_input(&FormatContext, SourceFile, nullptr, &Dict) != 0) |
| 95 | throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_FILE_READ, |
| 96 | std::string("Couldn't open '") + SourceFile + "'"); |
| 97 | |
| 98 | av_dict_free(&Dict); |
| 99 | |
| 100 | if (avformat_find_stream_info(FormatContext, nullptr) < 0) { |
| 101 | avformat_close_input(&FormatContext); |
| 102 | FormatContext = nullptr; |
| 103 | throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_FILE_READ, |
| 104 | "Couldn't find stream information"); |
| 105 | } |
| 106 | |
| 107 | for (int i = 0; i < (int)FormatContext->nb_streams; i++) |
| 108 | if (i != Track) |
| 109 | FormatContext->streams[i]->discard = AVDISCARD_ALL; |
| 110 | } |
| 111 | |
| 112 | int ResizerNameToSWSResizer(const char *ResizerName) { |
| 113 | if (!ResizerName) |
no test coverage detected