Exemplo n.º 1
0
def with_fps(root_dir):
    for dir_path, subdirList, fileList in os.walk(root_dir):
        print(','.join(dir_path.split("//")[-1:][0].split("_")))

        for file_name in fileList:
            abs_file_path = os.path.join(dir_path, file_name)
            index = processor.get_index(open(abs_file_path, "rb"))

            for atom, pos, size in index:
                if atom == "\x00\x00\x00\x00":
                    atom = "----"
                if "moov" in str(atom):
                    print("%s" % (str(size)))
Exemplo n.º 2
0
def have_moov(video_file):
    if not SKIP_MOOV:
        atoms = {}
        log.info("Checking moov data of %s", video_file)
        try:
            atom_data = get_index(open(video_file, 'rb'))
            for atom in atom_data:
                atoms[atom.name] = atom.position
            log.debug("moov:%(moov)s mdat:%(mdat)s ftyp:%(ftyp)s free:%(free)s",
                    atoms)

            if atoms['moov'] > atoms['mdat']:
                log.info("moov atom after mdat")
                return True, "after_mdat"
            else:
                log.info("moov atom before mdat")
                return True
        except FastStartException as e:
            log.error("Couldn't get Atoms data: %s", str(e))
            return False
    else:
        return True
Exemplo n.º 3
0
def have_moov(video_file):
    if not SKIP_MOOV:
        atoms = {}
        log.info("Checking moov data of %s", video_file)
        try:
            atom_data = get_index(open(video_file, 'rb'))
            for atom in atom_data:
                atoms[atom.name] = atom.position
            log.debug(
                "moov:%(moov)s mdat:%(mdat)s ftyp:%(ftyp)s free:%(free)s",
                atoms)

            if atoms['moov'] > atoms['mdat']:
                log.info("moov atom after mdat")
                return True, "after_mdat"
            else:
                log.info("moov atom before mdat")
                return True
        except FastStartException as e:
            log.error("Couldn't get Atoms data: %s", str(e))
            return False
    else:
        return True
Exemplo n.º 4
0
def run():
    logging.basicConfig(level=logging.INFO,
                        stream=sys.stdout,
                        format="%(message)s")

    parser = OptionParser(usage="%prog [options] infile [outfile]",
                          version="%prog " + VERSION)

    parser.add_option("-d",
                      "--debug",
                      dest="debug",
                      default=False,
                      action="store_true",
                      help="Enable debug output")
    parser.add_option("-l",
                      "--list",
                      dest="list",
                      default=False,
                      action="store_true",
                      help="List top level atoms")
    parser.add_option("-e",
                      "--to_end",
                      dest="to_end",
                      default=False,
                      action="store_true",
                      help="Move moov atom to the end of file")
    parser.add_option("-s",
                      "--sample",
                      dest="sample",
                      default=False,
                      action="store_true",
                      help="Create a small sample of the input file")

    options, args = parser.parse_args()

    if len(args) < 1:
        parser.print_help()
        raise SystemExit(1)

    if options.debug:
        logging.getLogger().setLevel(logging.DEBUG)

    if options.list:
        index = processor.get_index(open(args[0], "rb"))

        for atom, pos, size in index:
            if atom == "\x00\x00\x00\x00":
                # Strange zero atom... display with dashes rather than
                # an empty string
                atom = "----"

            print(atom, "(" + str(size) + " bytes)")

        raise SystemExit

    if len(args) == 1:
        # Replace the original file!
        if options.sample:
            print("Please pass an output filename when used with --sample!")
            raise SystemExit(1)

        tmp, outfile = tempfile.mkstemp()
        os.close(tmp)
    else:
        outfile = args[1]

    limit = 0
    if options.sample:
        # Create a small sample (4 MiB)
        limit = 4 * (1024**2)

    try:
        processor.process(args[0], outfile, limit=limit, to_end=options.to_end)
    except FastStartException:
        # A log message was printed, so exit with an error code
        raise SystemExit(1)

    if len(args) == 1:
        # Move temp file to replace original
        shutil.move(outfile, args[0])
Exemplo n.º 5
0
def run():
    logging.basicConfig(level = logging.INFO, stream = sys.stdout,
                        format = "%(message)s")

    parser = OptionParser(usage="%prog [options] infile [outfile]",
                          version="%prog " + VERSION)

    parser.add_option("-d", "--debug", dest="debug", default=False,
                      action="store_true",
                      help="Enable debug output")
    parser.add_option("-l", "--list", dest="list", default=False,
                      action="store_true",
                      help="List top level atoms")
    parser.add_option("-s", "--sample", dest="sample", default=False,
                      action="store_true",
                      help="Create a small sample of the input file")

    options, args = parser.parse_args()

    if len(args) < 1:
        parser.print_help()
        raise SystemExit(1)

    if options.debug:
        logging.getLogger().setLevel(logging.DEBUG)

    if options.list:
        index = processor.get_index(open(args[0], "rb"))

        for atom, pos, size in index:
            if atom == "\x00\x00\x00\x00":
                # Strange zero atom... display with dashes rather than
                # an empty string
                atom = "----"

            print(atom, "(" + str(size) + " bytes)")

        raise SystemExit

    if len(args) == 1:
        # Replace the original file!
        if options.sample:
            print("Please pass an output filename when used with --sample!")
            raise SystemExit(1)

        tmp, outfile = tempfile.mkstemp()
        os.close(tmp)
    else:
        outfile = args[1]

    limit = 0
    if options.sample:
        # Create a small sample (4 MiB)
        limit = 4 * (1024 ** 2)

    try:
        processor.process(args[0], outfile, limit = limit)
    except FastStartException:
        # A log message was printed, so exit with an error code
        raise SystemExit(1)

    if len(args) == 1:
        # Move temp file to replace original
        shutil.move(outfile, args[0])
Exemplo n.º 6
0
                   help="List top level atoms")
 parser.add_option("-s", "--sample", dest="sample", default=False,
                   action="store_true",
                   help="Create a small sample of the input file")
 
 options, args = parser.parse_args()
 
 if len(args) < 1:
     parser.print_help()
     raise SystemExit(1)
 
 if options.debug:
     logging.getLogger().setLevel(logging.DEBUG)
 
 if options.list:
     index = processor.get_index(open(args[0], "rb"))
     
     for atom, pos, size in index:
         print atom, "(" + str(size) + " bytes)"
         
     raise SystemExit
 
 if len(args) == 1:
     # Replace the original file!
     if options.sample:
         print "Please pass an output filename when used with --sample!"
         raise SystemExit(1)
         
     tmp, outfile = tempfile.mkstemp()
     os.close(tmp)
 else: