Exemplo n.º 1
0
def show_atoms(src, console):
    infile = os.path.abspath(src)

    try:
        in_fh = open(infile, "rb")
        in_fh.close()
    except:
        console("Error: " + infile +
                " does not exist or we do not have permission")

    console("Processing: " + infile)
    extension = os.path.splitext(infile)[1].lower()

    if extension in MPEG_FILE_EXTENSIONS:
        with open(infile, "rb") as in_fh:
            mpeg4_file = mpeg.load(in_fh)
            if mpeg4_file is None:
                console("Error, file could not be opened.")
                return

            console("Loaded file...")
            mpeg4_file.print_structure()
            return

    console("Unknown file type")
    return None
Exemplo n.º 2
0
def inject_mpeg4(input_file, output_file, metadata, console):
    with open(input_file, "rb") as in_fh:

        mpeg4_file = mpeg.load(in_fh)
        if mpeg4_file is None:
            console("Error file could not be opened.")

        if metadata.stereo:
            if not mpeg4_add_stereo(mpeg4_file, in_fh, metadata.stereo,
                                    console):
                console("Error failed to insert stereoscopic data")

        if metadata.spherical:
            if not mpeg4_add_spherical_v2(mpeg4_file, in_fh, metadata,
                                          console):
                console("Error failed to insert spherical data")

        if metadata.audio:
            if not mpeg4_add_audio_metadata(mpeg4_file, in_fh, metadata.audio,
                                            console):
                console("Error failed to insert spatial audio data")

        console("Saved file settings")
        parse_spherical_mpeg4(mpeg4_file, in_fh, console)

        with open(output_file, "wb") as out_fh:
            mpeg4_file.save(in_fh, out_fh)
        return

    console("Error file: \"" + input_file + "\" does not exist or do not have "
            "permission.")
Exemplo n.º 3
0
def parse_mpeg4(input_file, console):
    with open(input_file, "rb") as in_fh:
        mpeg4_file = mpeg.load(in_fh)
        if mpeg4_file is None:
            console("Error, file could not be opened.")
            return

        console("Loaded file...")
        return parse_spherical_mpeg4(mpeg4_file, in_fh, console)

    console("Error \"" + input_file + "\" does not exist or do not have "
            "permission.")
Exemplo n.º 4
0
def parse_mpeg4(input_file, console):
    with open(input_file, "rb") as in_fh:
        mpeg4_file = mpeg.load(in_fh)
        if mpeg4_file is None:
            console("Error, file could not be opened.")
            return

        console("Loaded file settings")
        return parse_spherical_mpeg4(mpeg4_file, in_fh, console)

    console("Error \"" + input_file + "\" does not exist or do not have "
            "permission.")
Exemplo n.º 5
0
def inject_mpeg4(input_file, output_file, metadata, console):
    with open(input_file, "rb") as in_fh:

        mpeg4_file = mpeg.load(in_fh)
        if mpeg4_file is None:
            console("File could not be opened.")

        if not mpeg4_add_spherical(mpeg4_file, in_fh, metadata):
            console("Failed to insert spherical data")

        console("Saved file settings")
        parse_spherical_mpeg4(mpeg4_file, in_fh, console)

        with open(output_file, "wb") as out_fh:
            mpeg4_file.save(in_fh, out_fh)
        return

    console("File: \"" + input_file + "\" does not exist or do not have "
            "permission.")
Exemplo n.º 6
0
def inject_mpeg4(input_file, output_file, metadata, console):
    with open(input_file, "rb") as in_fh:

        mpeg4_file = mpeg.load(in_fh)
        if mpeg4_file is None:
            console("Error file could not be opened.")

        if not mpeg4_add_spherical(mpeg4_file, in_fh, metadata):
            console("Error failed to insert spherical data")

        console("Saved file settings")
        parse_spherical_mpeg4(mpeg4_file, in_fh, console)

        with open(output_file, "wb") as out_fh:
            mpeg4_file.save(in_fh, out_fh)
        return

    console("Error file: \"" + input_file + "\" does not exist or do not have "
            "permission.")