1 #include "ffmpeg_util.h"
14 string search_for_file(const string &filename)
16 if (!filename.empty() && filename[0] == '/') {
21 // See if we match ^[a-z]:/, which is probably a URL of some sort
22 // (FFmpeg understands various forms of these).
23 for (size_t i = 0; i < filename.size() - 1; ++i) {
24 if (filename[i] == ':' && filename[i + 1] == '/') {
27 if (!isalpha(filename[i])) {
32 // Look for the file in all theme_dirs until we find one;
33 // that will be the permanent resolution of this file, whether
34 // it is actually valid or not.
35 // We store errors from all the attempts, and show them
36 // once we know we can't find any of them.
37 vector<string> errors;
38 for (const string &dir : global_flags.theme_dirs) {
39 string pathname = dir + "/" + filename;
40 if (access(pathname.c_str(), O_RDONLY) == 0) {
44 snprintf(buf, sizeof(buf), "%s: %s", pathname.c_str(), strerror(errno));
45 errors.push_back(buf);
49 for (const string &error : errors) {
50 fprintf(stderr, "%s\n", error.c_str());
55 string search_for_file_or_die(const string &filename)
57 string pathname = search_for_file(filename);
58 if (pathname.empty()) {
59 fprintf(stderr, "Couldn't find %s in any directory in --theme-dirs, exiting.\n",
66 int find_stream_index(AVFormatContext *ctx, AVMediaType media_type)
68 for (unsigned i = 0; i < ctx->nb_streams; ++i) {
69 if (ctx->streams[i]->codecpar->codec_type == media_type) {