Get the data out of the file using ffmpeg
    @param filename: mp4 filename
484503
def extract_stream(source, dest, stream_id):
    '''
    
    '''
    if not os.path.isfile(source):
        raise IOError('No such file: ' + source)

    subprocess.check_output([
        'ffmpeg',
        '-i', source,
        '-y',  # overwrite - potentially dangerous
        '-nostats',
        '-loglevel', '0',
        '-codec', 'copy',
        '-map', '0:' + str(stream_id),
        '-f', 'rawvideo',
        dest,
    ])
628764
public static String getFileExt(String fileName) {
        int dotPos = fileName.lastIndexOf('.');
        if (dotPos != -1 && dotPos != fileName.length() - 1) {
            return fileName.substring(dotPos);
        } else {
            return null;
        }
    }
969946
public static long generationFromSegmentsFileName(String fileName) {
    if (fileName.equals(IndexFileNames.SEGMENTS)) {
      return 0;
    } else if (fileName.startsWith(IndexFileNames.SEGMENTS)) {
      return Long.parseLong(
          fileName.substring(1 + IndexFileNames.SEGMENTS.length()),
          Character.MAX_RADIX);
    } else {
      throw new IllegalArgumentException("fileName \"" + fileName
          + "\" is not a segments file");
    }
  }
374343
private AbstractTransform getTransform(String fileName) {
        File file = new File(fileName);
        
        for (Transform transform : transforms) {
            if (transform.filter.accept(file)) {
                return transform.transform;
            }
        }
        
        return null;
    }
812734
def decode_filename(filename):
    """"""
    if isinstance(filename, unicode):
        return filename

    return filename.decode(sys.getfilesystemencoding())
998941
def write_wav(self, filename):
        

        wave_output = None
        try:
            wave_output = wave.open(filename, 'w')

            wave_output.setparams(WAVE_PARAMS)

            frames = bytearray([x << 4 for x in self.sample_data])

            wave_output.writeframes(frames)
        finally:
            if wave_output is not None:
                wave_output.close()
690758
def data_from_file(file):
    """"""
    fp = wave.open(file, 'r')
    data = fp.readframes(fp.getnframes())
    channels = fp.getnchannels()
    freq = fp.getframerate()
    bits = fp.getsampwidth()

    # Unpack bytes -- warning currently only tested with 16 bit wavefiles. 32
    # bit not supported.
    data = struct.unpack(('%sh' % fp.getnframes()) * channels, data)

    # Only use first channel
    channel1 = []
    n = 0
    for d in data:
        if n % channels == 0:
            channel1.append(d)
        n += 1
    fp.close()
    return (channel1, freq, bits)
509159
public static MediaInfo mediaInfo(String filename) {
        MediaInfo result;
        LibMediaInfo lib = LibMediaInfo.INSTANCE;
        Pointer handle = lib.MediaInfo_New();
        if (handle != null) {
            try {
                int opened = lib.MediaInfo_Open(handle, new WString(filename));
                if (opened == 1) {
                    WString data = lib.MediaInfo_Inform(handle);
                    lib.MediaInfo_Close(handle);
                    result = new Parser(data.toString()).parse();
                }
                else {
                    result = null;
                }
            }
            finally {
                lib.MediaInfo_Delete(handle);
            }
        }
        else {
            result = null;
        }
        return result;
    }
867726
def dump(self, filename):
        
        flags = os.O_WRONLY|os.O_CREAT|os.O_NOFOLLOW|os.O_EXCL
        fd = os.open(filename, flags, 0600)
        os.write(fd, str(self))
        os.close(fd)
1213351
def unload(filename):
    
    if isinstance(filename, list):
        for f in filename:
            libspice.unload_c(stypes.stringToCharP(f))
        return
    filename = stypes.stringToCharP(filename)
    libspice.unload_c(filename)
198591
def read_info(
    filename
):
    

    cmd = [
        'ffprobe',
        filename,
        '-v', 'error',
        '-print_format', 'json',
        '-show_format', '-show_streams',
    ]

    out = sp.check_output(cmd)
    info = json.loads(out.decode('utf-8'))
    return info
1080260
private static int getIndexFromFilename(String fileName) {
        // remove the beginning of the file name
        String resStr = fileName.replace(
                latestMOTDSerializedFileName.substring(0, latestMOTDSerializedFileName.indexOf("{index}")), "");

        // remove the end of the file name
        resStr = resStr.replace(
                latestMOTDSerializedFileName.substring(latestMOTDSerializedFileName.indexOf("{index}") + 7), "");

        return Integer.parseInt(resStr);
    }
1266230
def to_file(self, filename):
		
		with open(filename, 'wb') as f:
			f.write(self.to_bytes())
815576
def _read_file(self, filename):
        
        with open(filename, 'r') as stream:
            return self._read_stream(stream=stream)
1236126
static String[] decode(String filename) {
        int i = filename.indexOf("+");
        if (i == -1) return new String[] { decodePart(filename), null, null };
        int j = filename.lastIndexOf("+");
        return new String[] { decodePart(filename.substring(0, i)),
                decodePart(filename.substring(i + 1, j)),
                decodePart(filename.substring(j + 1)) };
    }
1213354
def dump_data(self, filename, queryset):
        
        with gzip.open(filename, "wb") as f:
            for outbound in queryset.iterator():
                data = OutboundArchiveSerializer(outbound).data
                data = JSONRenderer().render(data)
                f.write(data)
                f.write("\n".encode("utf-8"))
838863
def dump(self, filename):
        
        with open(filename, "w") as f:
            for name in sorted(self._fields):
                self._fields[name].dump(f, name)