Exemple #1
0
def main():
    """Main function for printing / injecting spherical metadata."""

    parser = OptionParser(usage="%prog [options] [files...]\n\n"
                          "By default prints out spherical metadata from"
                          "specified files.")
    parser.add_option("-i",
                      "--inject",
                      action="store_true",
                      help="injects spherical metadata into a MP4/WebM file, "
                      "saving the result to a new file")
    parser.add_option(
        "-s",
        "--stereo",
        type="choice",
        action="store",
        dest="stereo",
        choices=["none", "top-bottom", "left-right"],
        default="none",
        help="stereo frame order (top-bottom|left-right)",
    )
    parser.add_option(
        "-c",
        "--crop",
        type="string",
        action="store",
        default=None,
        help=("crop region. Must specify 6 integers in the form "
              "of \"w:h:f_w:f_h:x:y\" where "
              "w=CroppedAreaImageWidthPixels "
              "h=CroppedAreaImageHeightPixels "
              "f_w=FullPanoWidthPixels "
              "f_h=FullPanoHeightPixels "
              "x=CroppedAreaLeftPixels "
              "y=CroppedAreaTopPixels"),
    )

    (opts, args) = parser.parse_args()

    if opts.inject:
        if len(args) != 2:
            console("Injecting metadata requires both"
                    "a source and destination.")
            return

        spherical_xml = generate_spherical_xml(opts.stereo, opts.crop)
        if spherical_xml:
            inject_metadata(args[0], args[1], spherical_xml, console)
        else:
            print "Failed to generate XML metadata."
        return

    if len(args) > 0:
        for src in args:
            parse_metadata(src, console)
        return

    parser.print_help()
    return
Exemple #2
0
def main():
    """Main function for printing / injecting spherical metadata."""

    parser = OptionParser(usage="%prog [options] [files...]\n\n"
                                "By default prints out spherical metadata from"
                                "specified files.")
    parser.add_option("-i", "--inject",
                      action="store_true",
                      help="injects spherical metadata into a MP4/WebM file, "
                           "saving the result to a new file")
    parser.add_option("-s", "--stereo",
                      type="choice",
                      action="store",
                      dest="stereo",
                      choices=["none", "top-bottom", "left-right"],
                      default="none",
                      help="stereo frame order (top-bottom|left-right)",)
    parser.add_option("-c", "--crop",
                      type="string",
                      action="store",
                      default=None,
                      help=("crop region. Must specify 6 integers in the form "
                            "of \"w:h:f_w:f_h:x:y\" where "
                            "w=CroppedAreaImageWidthPixels "
                            "h=CroppedAreaImageHeightPixels "
                            "f_w=FullPanoWidthPixels "
                            "f_h=FullPanoHeightPixels "
                            "x=CroppedAreaLeftPixels "
                            "y=CroppedAreaTopPixels"),)

    (opts, args) = parser.parse_args()


    if opts.inject:
        if len(args) != 2:
            console("Injecting metadata requires both"
                    "a source and destination.")
            return

        spherical_xml = generate_spherical_xml(opts.stereo, opts.crop)
        if spherical_xml:
            inject_metadata(args[0], args[1], spherical_xml, console)
        else:
            print "Failed to generate XML metadata."
        return

    if len(args) > 0:
        for src in args:
            parse_metadata(src, console)
        return

    parser.print_help()
    return
Exemple #3
0
    def action_open(self):
        """Triggers open file diaglog, reading a new file's metadata."""
        tmp_in_file = tkFileDialog.askopenfilename(**self.open_options)
        if not tmp_in_file:
            return
        self.in_file = tmp_in_file

        self.set_message("Opened file: %s\n" % ntpath.basename(self.in_file))

        console = Console()
        metadata = spherical.parse_metadata(self.in_file, console.append)

        for line in console.log:
            if "Error" in line:
                self.set_error("Failed to load file %s" %
                               ntpath.basename(self.in_file))
                self.var_spherical.set(0)
                self.disable_state()
                self.button_open.configure(state="normal")
                self.button_quit.configure(state="normal")
                return

        self.enable_state()
        self.checkbox_spherical.configure(state="normal")

        if not metadata:
            self.set_message("No metadata found.")
            self.var_spherical.set(0)
            self.var_3d.set(0)

        if metadata:
            metadata = metadata.itervalues().next()
            self.var_spherical.set(1)

            self.set_message("Metadata found in %s\n" %
                             ntpath.basename(self.in_file))
            if metadata.get("Spherical", "") == "true":
                self.var_spherical.set(1)
            else:
                self.var_spherical.set(0)

            if metadata.get("StereoMode", "") == "top-bottom":
                self.var_3d.set(1)
            else:
                self.var_3d.set(0)

        self.update_state()
Exemple #4
0
    def action_open(self):
        """Triggers open file diaglog, reading a new file's metadata."""
        tmp_in_file = tkFileDialog.askopenfilename(**self.open_options)
        if not tmp_in_file:
            return
        self.in_file = tmp_in_file

        self.set_message("Opened file: %s\n" % ntpath.basename(self.in_file))

        console = Console()
        metadata = spherical.parse_metadata(self.in_file, console.append)

        for line in console.log:
            if "Error" in line:
                self.set_error("Failed to load file %s" % ntpath.basename(self.in_file))
                self.var_spherical.set(0)
                self.disable_state()
                self.button_open.configure(state="normal")
                self.button_quit.configure(state="normal")
                return

        self.enable_state()
        self.checkbox_spherical.configure(state="normal")

        if not metadata:
            self.set_message("No metadata found.")
            self.var_spherical.set(0)
            self.var_3d.set(0)

        if metadata:
            metadata = metadata.itervalues().next()
            self.var_spherical.set(1)

            self.set_message("Metadata found in %s\n" % ntpath.basename(self.in_file))
            if metadata.get("Spherical", "") == "true":
                self.var_spherical.set(1)
            else:
                self.var_spherical.set(0)

            if metadata.get("StereoMode", "") == "top-bottom":
                self.var_3d.set(1)
            else:
                self.var_3d.set(0)

        self.update_state()
Exemple #5
0
    def action_open(self):
        """Triggers open file diaglog, reading a new file's metadata."""
        tmp_in_file = tkFileDialog.askopenfilename(**self.open_options)
        if not tmp_in_file:
            return
        self.in_file = tmp_in_file

        self.set_message("Opened file: %s\n" % ntpath.basename(self.in_file))

        console = Console()
        parsedMetadata = spherical.parse_metadata(self.in_file, console.append)

        metadata = None
        audio_metadata = None
        if parsedMetadata:
            metadata = parsedMetadata.video
            audio_metadata = parsedMetadata.audio

        for line in console.log:
            if "Error" in line:
                self.set_error("Failed to load file %s"
                               % ntpath.basename(self.in_file))
                self.var_spherical.set(0)
                self.var_spatial_audio.set(0)
                self.disable_state()
                self.button_open.configure(state="normal")
                self.button_quit.configure(state="normal")
                return

        self.enable_state()
        self.checkbox_spherical.configure(state="normal")

        infile = os.path.abspath(self.in_file)
        file_extension = os.path.splitext(infile)[1].lower()
        self.enable_spatial_audio =\
            True if (file_extension == ".mp4") else False

        if not metadata:
            self.var_spherical.set(0)
            self.var_3d.set(0)

        if not audio_metadata:
            self.var_spatial_audio.set(0)

        if metadata:
            metadata = metadata.itervalues().next()
            self.var_spherical.set(1)

            if metadata.get("Spherical", "") == "true":
                self.var_spherical.set(1)
            else:
                self.var_spherical.set(0)

            if metadata.get("StereoMode", "") == "top-bottom":
                self.var_3d.set(1)
            else:
                self.var_3d.set(0)

        if audio_metadata:
            self.var_spatial_audio.set(1)
            self.options_ambisonics["text"] =\
                audio_metadata.get_metadata_string()


        self.update_state()
Exemple #6
0
 def open(self):
     """Triggers open file diaglog, reading a new file's metadata."""
     self.in_file = tkFileDialog.askopenfilename(**self.open_options)
     if self.in_file:
         self.set_text("Opened file: %s\n" % self.in_file)
         spherical.parse_metadata(self.in_file, self.append_text)
Exemple #7
0
 def open(self):
     """Triggers open file diaglog, reading a new file's metadata."""
     self.in_file = tkFileDialog.askopenfilename(**self.open_options)
     if self.in_file:
         self.set_text("Opened file: %s\n" % self.in_file)
         spherical.parse_metadata(self.in_file, self.append_text)