Search in the same directory as ffmpeg
335333
function(ffprobe, cb) {
        if (ffprobe.length) {
          return cb(null, ffprobe);
        }

        self._getFfmpegPath(function(err, ffmpeg) {
          if (err) {
            cb(err);
          } else if (ffmpeg.length) {
            var name = utils.isWindows ? 'ffprobe.exe' : 'ffprobe';
            var ffprobe = path.join(path.dirname(ffmpeg), name);
            fs.exists(ffprobe, function(exists) {
              cb(null, exists ? ffprobe : '');
            });
          } else {
            cb(null, '');
          }
        });
      }
314904
def search_configuration_files(findstr, replacestr = None):
    ''''''

    F = open(configurationFilesLocation, "r")
    lines = F.readlines()
    F.close()
    allerrors = {}
    alloutput = {}

    for line in lines:
        line = line.strip()
        if line:
            if line.endswith("generate_fragments.py"):
                # Do not parse the Python script but check that it exists
                if not(os.path.exists(line)):
                    allerrors[line] = "File/directory %s does not exist." % line
            else:
                cmd = ["grep", "-n", "-i",  findstr, line]
                output = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
                errors = output[1]
                output = output[0]
                if errors:
                    errors = errors.strip()
                    allerrors[line] = errors
                if output:
                    output = output.strip()
                    alloutput[line] = output.split("\n")
    return alloutput, allerrors
1294870
def select_directory(self):
        """"""
        self.__redirect_stdio_emit(False)
        directory = getexistingdirectory(
                self, _(""), self.path)
        if directory:
            directory = to_unicode_from_fs(osp.abspath(directory))
        self.__redirect_stdio_emit(True)
        return directory
454691
def skip(self, video_name, out, start, duration):
        
        cfilter = (r"[0:v]trim=duration={start}[av];"
                   r"[0:a]atrim=duration={start}[aa];"
                   r"[0:v]trim=start={offset},setpts=PTS-STARTPTS[bv];"
                   r"[0:a]atrim=start={offset},asetpts=PTS-STARTPTS[ba];"
                   r"[av][bv]concat[outv];[aa][ba]concat=v=0:a=1[outa]")\
            .format(start=start, offset=start + duration)\
            .replace(' ', '')

        command = ['ffmpeg', '-i', video_name,
            '-filter_complex', cfilter, '-y',
            '-map', '[outv]',
            '-map', '[outa]', '-c:v', 'huffyuv', '-preset', 'veryslow',
            out]

        if self.verbose:
            print 'Skipping {0} into {1}'.format(video_name, out)
            print ' '.join(command)

        call(command)
723685
def _search_archive(pattern, archive, verbosity=0, interactive=True):
    """"""
    grep = util.find_program("grep")
    if not grep:
        msg = "The grep(1) program is required for searching archive contents, please install it."
        raise util.PatoolError(msg)
    tmpdir = util.tmpdir()
    try:
        path = _extract_archive(archive, outdir=tmpdir, verbosity=-1)
        return util.run_checked([grep, "-r", "-e", pattern, "."], ret_ok=(0, 1), verbosity=1, cwd=path)
    finally:
        shutil.rmtree(tmpdir, onerror=rmtree_log_error)
168834
def create_m3u_playlist(section_dir):
    
    path_to_return = os.getcwd()

    for (_path, subdirs, files) in os.walk(section_dir):
        os.chdir(_path)
        globbed_videos = sorted(glob.glob("*.mp4"))
        m3u_name = os.path.split(_path)[1] + ".m3u"

        if len(globbed_videos):
            with open(m3u_name, "w") as m3u:
                for video in globbed_videos:
                    m3u.write(video + "\n")
            os.chdir(path_to_return)
    os.chdir(path_to_return)
1071205
def _fs_match(pattern, filename, sep, follow, symlinks):
    

    matched = False

    base = None
    m = pattern.fullmatch(filename)
    if m:
        matched = True
        # Lets look at the captured `globstar` groups and see if that part of the path
        # contains symlinks.
        if not follow:
            groups = m.groups()
            last = len(groups)
            for i, star in enumerate(m.groups(), 1):
                if star:
                    parts = star.strip(sep).split(sep)
                    if base is None:
                        base = filename[:m.start(i)]
                    for part in parts:
                        base = os.path.join(base, part)
                        is_link = symlinks.get(base, None)
                        if is_link is not None:
                            matched = not is_link
                        elif i != last or os.path.isdir(base):
                            is_link = os.path.islink(base)
                            symlinks[base] = is_link
                            matched = not is_link
                        if not matched:
                            break
                if matched:
                    break
    return matched
432008
function command(os) {
  var z = 'ffmpeg';
  var os = os||[];
  for(var o of os) {
    var o = o||{};
    for(var k in o) {
      if(o[k]==null) continue;
      if(k==='stdio') continue;
      if(k==='o' || k==='outfile') z += ` "${o[k]}"`;
      else if(typeof o[k]==='boolean') z += o[k]? ` -${k}`:'';
      else z += ` -${k} ${JSON.stringify(o[k])}`;
    }
  }
  return z;
}
251060
def _recursive_search_file_in_directory(self, directory, searched_file):
        
        s = os.path.split(searched_file)

        for root, dirs, files in os.walk(directory):
            for file in files:
                # If filename is the same
                if s[1] == file and (s[0] == '' or s[0] == os.path.basename(root)):
                    path = os.path.normpath(os.path.join(root, s[1]))
                    if os.path.exists(path):
                        return path
        return None
407574
function(ffmpeg, cb) {
        if (ffmpeg.length) {
          return cb(null, ffmpeg);
        }

        utils.which('ffmpeg', function(err, ffmpeg) {
          cb(err, ffmpeg);
        });
      }
131625
function find_program(program_dir) {

  const files_in_program_dir = fs.readdirSync(program_dir);

  for (let i = 0; i < files_in_program_dir.length; i++) {
    const file = files_in_program_dir[i];
    if (file.includes('Adobe After Effects'))
      return path.join(program_dir, file);
  }

  return null;
}
122679
function watchFilter(fileName) {
  var watchDirectory = this.watchDirectory,//this is array if multiple --watchDirectory options given, treat as array always
      result = true;

  if (!Array.isArray(watchDirectory)) {
    watchDirectory = [watchDirectory];
  }

  watchDirectory.forEach(function(directory) {
    var relFileName = path.relative(directory, fileName),
        length = this.watchIgnorePatterns.length,
        testName,
        i;

    if (this.watchIgnoreDotFiles && path.basename(fileName)[0] === '.') {
      result = false;
    }

    for (i = 0; i < length; i++) {
      if (this.watchIgnorePatterns[i].length > 0) {
        testName = (this.watchIgnorePatterns[i].charAt(0) !== '/') ? relFileName : fileName;
        if (minimatch(testName, this.watchIgnorePatterns[i], { matchBase: directory })) {
          result = false;
        }
      }
    }
  }.bind(this));

  return result;
}
1045549
def main(args=None):
    """"""

    dlx = Downloader()
    epilog = dlx.epilog()

    options, arguments = parse(args, epilog)

    # create list of video files that don't have accompanying 'srt' subtitles
    targets = [p for p in arguments if os.path.isfile(p) and not
               os.path.exists(os.path.splitext(p)[0] + '.srt')]

    if not targets:
        fatal('No valid targets were specified')

    if options.rename:
        videos = [rename(p) for p in targets]
    else:
        videos = targets

    dlx.download(videos, options.downloader, options.language)

    subtitles = []

    for video_path in videos:
        srt_path = os.path.splitext(video_path)[0] + '.srt'
        if os.path.isfile(srt_path):
            subtitles.append(srt_path)
        elif not options.quiet:
            failure(video_path, options.downloader)

    if options.scan and subtitles:
        scan(subtitles)
1095536
def find_by_ext(dirname, ext):
    """"""
    # Get all fasta-files
    try: 
        files = os.listdir(dirname) 
    except OSError: 
        if os.path.exists(dirname): 
            cmd = "find {0} -maxdepth 1 -name \"*\"".format(dirname) 
            p = sp.Popen(cmd, shell=True, stdout=sp.PIPE, stderr=sp.PIPE) 
            stdout, _stderr = p.communicate() 
            files = [os.path.basename(fname) for fname in stdout.decode().splitlines()] 
        else: 
            raise 
     
    retfiles = [os.path.join(dirname, fname) for fname in files if 
                    os.path.splitext(fname)[-1] in ext] 
 
    return retfiles
287011
def _where(filename, dirs=[], env="PATH"):
    """"""
    if not isinstance(dirs, list):
        dirs = [dirs]
    if glob(filename):
        return filename
    paths = [os.curdir] + os.environ[env].split(os.path.pathsep) + dirs
    for path in paths:
        for match in glob(os.path.join(path, filename)):
            if match:
                return os.path.normpath(match)
    raise IOError("File not found: %s" % filename)
11768
def detectFpsFromMovie(cls, movieFile, default = 23.976):
        """"""

        # initialize with a default FPS value, but not with a movieFile
        videoInfo = VideoInfo(float(default))

        command = ['mplayer',
            '-really-quiet', '-vo', 'null', '-ao', 'null', '-frames', '0', '-identify', movieFile]

        try:
            mpOut, mpErr = Popen(command, stdout=PIPE, stderr=PIPE).communicate()
            log.debug(mpOut)
            log.debug(mpErr)

            # Overwrite default (not fetched from video) values.
            # If there's any error on changing videoInfo.fps, whole videoInfo won't be changed at
            # all.
            videoInfo.fps = float(re.search(r'ID_VIDEO_FPS=([\w/.]+)\s?', str(mpOut)).group(1))
            videoInfo.videoPath = movieFile
        except OSError:
            log.warning(_("Couldn't run mplayer. It has to be installed and placed in your $PATH "
                "to detect FPS."))
        except AttributeError:
            log.warning(_("Couldn't get FPS from %(movie)s. Using default value: %(fps)s.") %
                {"movie": movieFile, "fps": videoInfo.fps})
        else:
            pass
            log.debug(P_(
                "Got %(fps)s FPS from '%(movie)s'.",
                "Got %(fps)s FPS from '%(movie)s'.",
                int(videoInfo.fps)) % {"fps": videoInfo.fps, "movie": videoInfo.videoPath})

        return videoInfo
600394
def iterplayables():
    '''  '''
    ls = DirScanner(stripdot=True)
    ## filter out just mp3 files (and dirs to support recursion)
    filt = lambda x: ( os.path.isdir(x) or x[-4:].lower() in ALLOWED_TYPES )
    ## take the last two segments of the path as the label
    func = lambda x: '/'.join(x.split('/')[-2:])
    ## iterate over all the files (excluding dirs), filtering for .mp3 and .m4a
    for x,y in ls.iteritems(want_files=True, want_dirs=False, func=func, filt=filt):
        yield {      'name': x.decode('utf-8'),
                'file_name': escape_utf8(y)     }