Esempio n. 1
0
    def action_inject_delay(self):
        stereo = self.var_layout

        metadata = metadata_utils.Metadata()

        metadata.stereo = self.var_layout.get()
        metadata.spherical = "equirectangular"
        metadata.clip_left_right = self.var_degrees.get()

        if self.var_spatial_audio.get():
            metadata.audio = metadata_utils.SPATIAL_AUDIO_DEFAULT_METADATA

        console = Console()

        if metadata.stereo or metadata.spherical or metadata.audio:
            metadata.orientation = {"yaw": 0, "pitch": 0, "roll": 0}
            metadata_utils.inject_metadata(self.in_file, self.save_file,
                                           metadata, console.append)
            self.set_message("Successfully saved file to %s\n" %
                             ntpath.basename(self.save_file))
            self.button_open.configure(state="normal")
            self.update_state()
        else:
            console("Failed to generate metadata.")
        return
Esempio n. 2
0
    def action_inject_delay(self):
        stereo = None
        if (self.var_3d.get()):
            stereo = "top-bottom"

        metadata = metadata_utils.Metadata()
        metadata.video = metadata_utils.generate_spherical_xml(stereo=stereo)

        if self.var_spatial_audio.get():
            metadata.audio = metadata_utils.SPATIAL_AUDIO_DEFAULT_METADATA 

        console = Console()
        metadata_utils.inject_metadata(
            self.in_file, self.save_file, metadata, console.append)
        self.set_message("Successfully saved file to %s\n"
                         % ntpath.basename(self.save_file))
        self.button_open.configure(state="normal")
        self.update_state()
Esempio n. 3
0
    def action_inject_delay(self):
        stereo = None
        if (self.var_3d.get()):
            stereo = "top-bottom"

        metadata = metadata_utils.Metadata()
        metadata.video = metadata_utils.generate_spherical_xml(stereo=stereo)

        if self.var_spatial_audio.get():
            metadata.audio = metadata_utils.SPATIAL_AUDIO_DEFAULT_METADATA

        console = Console()
        metadata_utils.inject_metadata(self.in_file, self.save_file, metadata,
                                       console.append)
        self.set_message("Successfully saved file to %s\n" %
                         ntpath.basename(self.save_file))
        self.button_open.configure(state="normal")
        self.update_state()
Esempio n. 4
0
    def action_inject_delay(self):
        stereo = None
        if (self.var_3d):
            stereo = "top-bottom"

        metadata = metadata_utils.Metadata()
        metadata.video = metadata_utils.generate_spherical_xml(stereo=stereo)

        if self.var_spatial_audio:
            metadata.audio = metadata_utils.get_spatial_audio_metadata(
                self.spatial_audio_description.order,
                self.spatial_audio_description.has_head_locked_stereo)

        console = Console()
        metadata_utils.inject_metadata(self.in_file, self.save_file, metadata,
                                       console.append)
        print("Successfully saved file to %s\n" %
              ntpath.basename(self.save_file))
Esempio n. 5
0
    def action_inject_delay(self):
        
        
        stereo = self.char_layout.get()
        spherical = self.char_format.get()
        degrees = self.char_degrees.get()
        
        if spherical == "fisheye":
            spherical = "mesh"
            stereo = "left-right"
            degrees = "180"
        elif spherical == "equi-rectangular":
            spherical = "equirectangular"
        
        if stereo == 'mono':
            if degrees == "180":
                stereo = "left-right"
            else:
                stereo = "none"
            
        metadata = metadata_utils.Metadata()
        
        metadata.stereo = stereo
        metadata.spherical = spherical
        if degrees == "180":
            metadata.clip_left_right = 1073741823
        else:
            metadata.clip_left_right = 0

        if self.var_spatial_audio.get():
            metadata.audio = metadata_utils.SPATIAL_AUDIO_DEFAULT_METADATA

        console = Console()
    
        if metadata.stereo or metadata.spherical or metadata.audio:
            metadata.orientation = {"yaw": 0, "pitch": 0, "roll": 0}
            metadata_utils.inject_metadata(self.in_file, self.save_file, metadata, console.append)
            self.set_message("Successfully saved file to %s\n"
                     % ntpath.basename(self.save_file))
            self.button_open.configure(state="normal")
            self.update_state()
        else:
            console("Failed to generate metadata.")
        return
Esempio n. 6
0
def main():
    """Main function for printing and injecting spatial media metadata."""

    parser = argparse.ArgumentParser(
        usage=
        "%(prog)s [options] [files...]\n\nBy default prints out spatial media "
        "metadata from specified files.")
    parser.add_argument(
        "-i",
        "--inject",
        action="store_true",
        help=
        "injects spatial media metadata into the first file specified (.mp4 or "
        ".mov) and saves the result to the second file specified")
    parser.add_argument(
        "-b",
        "--show-atoms",
        action="store_true",
        help=
        "Displays the atom layout for the movie. Note the MOV/MP4 format is not self-parsable"
        "e.g. there is no way to know the containts of a container atom without documentation."
    )

    video_group = parser.add_argument_group("Spherical Video")
    video_group.add_argument(
        "-s",
        "--stereo",
        action="store",
        dest="stereo_mode",
        metavar="STEREO-MODE",
        choices=["none", "top-bottom", "left-right", "custom"],
        default=None,
        help="stereo mode (none | top-bottom | left-right | custom)")
    video_group.add_argument(
        "-m",
        "--projection",
        action="store",
        dest="projection",
        metavar="SPHERICAL-MODE",
        choices=[
            "equirectangular", "cubemap", "mesh", "full-frame", "equi-mesh"
        ],
        default=None,
        help=
        "projection (equirectangular | cubemap | mesh | full-frame | equi-mesh)"
    )
    video_group.add_argument("-y",
                             "--yaw",
                             action="store",
                             dest="yaw",
                             metavar="YAW",
                             default=0,
                             help="yaw")
    video_group.add_argument("-p",
                             "--pitch",
                             action="store",
                             dest="pitch",
                             metavar="PITCH",
                             default=0,
                             help="pitch")
    video_group.add_argument("-r",
                             "--roll",
                             action="store",
                             dest="roll",
                             metavar="ROLL",
                             default=0,
                             help="roll")
    video_group.add_argument("-d",
                             "--degrees",
                             action="store",
                             dest="degrees",
                             metavar="DEGREES",
                             choices=["180", "360"],
                             default=180,
                             help="degrees")
    video_group.add_argument(
        "-c",
        "--correction",
        action="store",
        dest="fisheye_correction",
        metavar="FISHEYE-CORRECTION",
        default="0:0:0:0",
        help=
        "polynomial fisheye lens correction (n1:n2:n3:n4) e.g 0.5:-0.1:0.2:-0.0005"
    )
    video_group.add_argument(
        "-v",
        "--view",
        action="store",
        dest="field_of_view",
        metavar="FIELD-OF-VIEW",
        default="0x0",
        help="Field of view for equi_mesh or full frame. e.g. 180x180 or 16x9")
    video_group.add_argument(
        "-1",
        "--force_v1_360_equi_metadata",
        action="store_true",
        help="Add v1 metadata as well as v2 metadata to the video."
        "This is only really valid for 360 equirectangular videos, but some video players only enable VR if they recognise v1 metadata"
    )

    audio_group = parser.add_argument_group("Spatial Audio")
    audio_group.add_argument(
        "-a",
        "--spatial-audio",
        action="store_true",
        help="spatial audio. First-order periphonic ambisonics with ACN channel "
        "ordering and SN3D normalization")
    parser.add_argument("file", nargs="+", help="input/output files")

    args = parser.parse_args()

    if args.inject:
        if len(args.file) != 2:
            console(
                "Injecting metadata requires both an input file and output file."
            )
            return

        metadata = metadata_utils.Metadata()

        if args.stereo_mode:
            metadata.stereo = args.stereo_mode

        if args.projection:
            metadata.spherical = args.projection
            if metadata.spherical == "equirectangular":
                metadata.clip_left_right = 0 if args.degrees == "360" else 1073741823

        if args.spatial_audio:
            parsed_metadata = metadata_utils.parse_metadata(
                args.file[0], console)
            if not metadata.audio:
                spatial_audio_description = metadata_utils.get_spatial_audio_description(
                    parsed_metadata.num_audio_channels)
                if spatial_audio_description.is_supported:
                    metadata.audio = metadata_utils.get_spatial_audio_metadata(
                        spatial_audio_description.order,
                        spatial_audio_description.has_head_locked_stereo)
                else:
                    console("Audio has %d channel(s) and is not a supported "
                            "spatial audio format." %
                            (parsed_metadata.num_audio_channels))
                    return

        if args.fisheye_correction:
            metadata.fisheye_correction = [
                float(x) for x in args.fisheye_correction.split(':')
            ]

        if args.field_of_view:
            metadata.fov = [float(x) for x in args.field_of_view.split('x')]
            if metadata.fov[0] == 0 or metadata.fov[1] == 0:
                if args.projection == "full-frame":
                    metadata.fov[0] = 16.0
                    metadata.fov[1] = 9.0
                else:
                    metadata.fov[0] = 180
                    metadata.fov[1] = 180

        if args.force_v1_360_equi_metadata:
            console("generating metadata.")
            metadata.v1_xml = metadata_utils.generate_spherical_xml(
                args.stereo_mode)
            console(metadata.v1_xml)

        if metadata.stereo or metadata.spherical or metadata.audio:
            metadata.orientation = {
                "yaw": args.yaw,
                "pitch": args.pitch,
                "roll": args.roll
            }
            metadata_utils.inject_metadata(args.file[0], args.file[1],
                                           metadata, console,
                                           args.force_v1_360_equi_metadata)
        else:
            console("Failed to generate metadata.")
        return

    if len(args.file) > 0:
        for input_file in args.file:
            if args.spatial_audio:
                parsed_metadata = metadata_utils.parse_metadata(
                    input_file, console)
                metadata.audio = metadata_utils.get_spatial_audio_description(
                    parsed_metadata.num_channels)
            metadata_utils.parse_metadata(input_file, console)
            metadata_utils.show_atoms(input_file, console)

        return

    parser.print_help()
    return
Esempio n. 7
0
def main():
    """Main function for printing and injecting spatial media metadata."""

    parser = argparse.ArgumentParser(
        usage=
        "%(prog)s [options] [files...]\n\nBy default prints out spatial media "
        "metadata from specified files.")
    parser.add_argument(
        "-i",
        "--inject",
        action="store_true",
        help=
        "injects spatial media metadata into the first file specified (.mp4 or "
        ".mov) and saves the result to the second file specified")

    video_group = parser.add_argument_group("Spherical Video")
    video_group.add_argument(
        "-s",
        "--stereo",
        action="store",
        dest="stereo_mode",
        metavar="STEREO-MODE",
        choices=["none", "top-bottom", "left-right"],
        default=None,
        help="stereo mode (none | top-bottom | left-right)")
    video_group.add_argument("-m",
                             "--projection",
                             action="store",
                             dest="projection",
                             metavar="SPHERICAL-MODE",
                             choices=["equirectangular", "cubemap"],
                             default=None,
                             help="projection (equirectangular | cubemap)")
    video_group.add_argument("-y",
                             "--yaw",
                             action="store",
                             dest="yaw",
                             metavar="YAW",
                             default=0,
                             help="yaw")
    video_group.add_argument("-p",
                             "--pitch",
                             action="store",
                             dest="pitch",
                             metavar="PITCH",
                             default=0,
                             help="pitch")
    video_group.add_argument("-r",
                             "--roll",
                             action="store",
                             dest="roll",
                             metavar="ROLL",
                             default=0,
                             help="roll")
    video_group.add_argument("-d",
                             "--degrees",
                             action="store",
                             dest="degrees",
                             metavar="DEGREES",
                             choices=["180", "360"],
                             default=180,
                             help="degrees")

    audio_group = parser.add_argument_group("Spatial Audio")
    audio_group.add_argument(
        "-a",
        "--spatial-audio",
        action="store_true",
        help="spatial audio. First-order periphonic ambisonics with ACN channel "
        "ordering and SN3D normalization")
    parser.add_argument("file", nargs="+", help="input/output files")

    args = parser.parse_args()

    if args.inject:
        if len(args.file) != 2:
            console(
                "Injecting metadata requires both an input file and output file."
            )
            return

        metadata = metadata_utils.Metadata()

        if args.stereo_mode:
            metadata.stereo = args.stereo_mode

        if args.projection:
            metadata.spherical = args.projection
            if metadata.spherical == "equirectangular":
                metadata.clip_left_right = 0 if args.degrees == "360" else 1073741823

        if args.spatial_audio:
            metadata.audio = metadata_utils.SPATIAL_AUDIO_DEFAULT_METADATA

        if metadata.stereo or metadata.spherical or metadata.audio:
            metadata.orientation = {
                "yaw": args.yaw,
                "pitch": args.pitch,
                "roll": args.roll
            }
            metadata_utils.inject_metadata(args.file[0], args.file[1],
                                           metadata, console)
        else:
            console("Failed to generate metadata.")
        return

    if len(args.file) > 0:
        for input_file in args.file:
            metadata_utils.parse_metadata(input_file, console)
        return

    parser.print_help()
    return
Esempio n. 8
0
def main():
    """Main function for printing and injecting spatial media metadata."""

    parser = argparse.ArgumentParser(
        usage=
        "%(prog)s [options] [files...]\n\nBy default prints out spatial media "
        "metadata from specified files.")
    parser.add_argument(
        "-i",
        "--inject",
        action="store_true",
        help=
        "injects spatial media metadata into the first file specified (.mp4 or "
        ".mov) and saves the result to the second file specified")
    video_group = parser.add_argument_group("Spherical Video")
    video_group.add_argument(
        "-s",
        "--stereo",
        action="store",
        dest="stereo_mode",
        metavar="STEREO-MODE",
        choices=["none", "top-bottom", "left-right"],
        default="none",
        help="stereo mode (none | top-bottom | left-right)")
    video_group.add_argument(
        "-c",
        "--crop",
        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")
    audio_group = parser.add_argument_group("Spatial Audio")
    audio_group.add_argument(
        "-a",
        "--spatial-audio",
        action="store_true",
        help="spatial audio. First-order periphonic ambisonics with ACN channel "
        "ordering and SN3D normalization")
    parser.add_argument("file", nargs="+", help="input/output files")

    args = parser.parse_args()

    if args.inject:
        if len(args.file) != 2:
            console(
                "Injecting metadata requires both an input file and output file."
            )
            return

        metadata = metadata_utils.Metadata()
        metadata.video = metadata_utils.generate_spherical_xml(
            args.stereo_mode, args.crop)

        if args.spatial_audio:
            metadata.audio = metadata_utils.SPATIAL_AUDIO_DEFAULT_METADATA

        if metadata.video:
            metadata_utils.inject_metadata(args.file[0], args.file[1],
                                           metadata, console)
        else:
            console("Failed to generate metadata.")
        return

    if len(args.file) > 0:
        for input_file in args.file:
            metadata_utils.parse_metadata(input_file, console)
        return

    parser.print_help()
    return
Esempio n. 9
0
def main():
    """Main function for printing and injecting spatial media metadata."""

    parser = argparse.ArgumentParser(
        usage=
        "%(prog)s [options] [files...]\n\nBy default prints out spatial media "
        "metadata from specified files.")
    parser.add_argument(
        "-i",
        "--inject",
        action="store_true",
        help=
        "injects spatial media metadata into the first file specified (.mp4 or "
        ".mov) and saves the result to the second file specified")

    video_group = parser.add_argument_group("Spherical Video")
    video_group.add_argument(
        "-s",
        "--stereo",
        action="store",
        dest="stereo_mode",
        metavar="STEREO-MODE",
        choices=["none", "top-bottom", "left-right", "custom"],
        default=None,
        help="stereo mode (none | top-bottom | left-right | custom)")
    video_group.add_argument(
        "-m",
        "--projection",
        action="store",
        dest="projection",
        metavar="SPHERICAL-MODE",
        choices=[
            "equirectangular", "cubemap", "mesh", "full-frame", "equi-mesh"
        ],
        default=None,
        help=
        "projection (equirectangular | cubemap | mesh | full-frame | equi-mesh)"
    )
    video_group.add_argument("-y",
                             "--yaw",
                             action="store",
                             dest="yaw",
                             metavar="YAW",
                             default=0,
                             help="yaw")
    video_group.add_argument("-p",
                             "--pitch",
                             action="store",
                             dest="pitch",
                             metavar="PITCH",
                             default=0,
                             help="pitch")
    video_group.add_argument("-r",
                             "--roll",
                             action="store",
                             dest="roll",
                             metavar="ROLL",
                             default=0,
                             help="roll")
    video_group.add_argument("-d",
                             "--degrees",
                             action="store",
                             dest="degrees",
                             metavar="DEGREES",
                             choices=["180", "360"],
                             default=180,
                             help="degrees")
    video_group.add_argument(
        "-c",
        "--correction",
        action="store",
        dest="fisheye_correction",
        metavar="FISHEYE-CORRECTION",
        default="0:0:0:0",
        help=
        "polynomial fisheye lens correction (n1:n2:n3:n4) e.g 0.5:-0.1:0.2:-0.0005"
    )
    video_group.add_argument(
        "-v",
        "--view",
        action="store",
        dest="field_of_view",
        metavar="FIELD-OF-VIEW",
        default="0x0",
        help="Field of view for equi_mesh or full frame. e.g. 180x180 or 16x9")

    audio_group = parser.add_argument_group("Spatial Audio")
    audio_group.add_argument(
        "-a",
        "--spatial-audio",
        action="store_true",
        help="spatial audio. First-order periphonic ambisonics with ACN channel "
        "ordering and SN3D normalization")
    parser.add_argument("file", nargs="+", help="input/output files")

    args = parser.parse_args()

    if args.inject:
        if len(args.file) != 2:
            console(
                "Injecting metadata requires both an input file and output file."
            )
            return

        metadata = metadata_utils.Metadata()

        if args.stereo_mode:
            metadata.stereo = args.stereo_mode

        if args.projection:
            metadata.spherical = args.projection
            if metadata.spherical == "equirectangular":
                metdaadata.clip_left_right = 0 if args.degrees == "360" else 1073741823

        if args.spatial_audio:
            metadata.audio = metadata_utils.SPATIAL_AUDIO_DEFAULT_METADATA

        if args.fisheye_correction:
            metadata.fisheye_correction = [
                float(x) for x in args.fisheye_correction.split(':')
            ]

        if args.field_of_view:
            metadata.fov = [float(x) for x in args.field_of_view.split('x')]
            if metadata.fov[0] == 0 or metadata.fov[1] == 0:
                if args.projection == "full-frame":
                    metadata.fov[0] = 16.0
                    metadata.fov[1] = 9.0
                else:
                    metadata.fov[0] = 180
                    metadata.fov[1] = 180

        if metadata.stereo or metadata.spherical or metadata.audio:
            metadata.orientation = {
                "yaw": args.yaw,
                "pitch": args.pitch,
                "roll": args.roll
            }
            metadata_utils.inject_metadata(args.file[0], args.file[1],
                                           metadata, console)
        else:
            console("Failed to generate metadata.")
        return

    if len(args.file) > 0:
        for input_file in args.file:
            metadata_utils.parse_metadata(input_file, console)
        return

    parser.print_help()
    return
Esempio n. 10
0
def main():
  """Main function for printing and injecting spatial media metadata."""

  parser = argparse.ArgumentParser(
      usage=
      "%(prog)s [options] [files...]\n\nBy default prints out spatial media "
      "metadata from specified files.")
  parser.add_argument(
      "-i",
      "--inject",
      action="store_true",
      help=
      "injects spatial media metadata into the first file specified (.mp4 or "
      ".mov) and saves the result to the second file specified")
  video_group = parser.add_argument_group("Spherical Video")
  video_group.add_argument("-s",
                           "--stereo",
                           action="store",
                           dest="stereo_mode",
                           metavar="STEREO-MODE",
                           choices=["none", "top-bottom", "left-right"],
                           default="none",
                           help="stereo mode (none | top-bottom | left-right)")
  video_group.add_argument(
      "-c",
      "--crop",
      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")
  audio_group = parser.add_argument_group("Spatial Audio")
  audio_group.add_argument(
      "-a",
      "--spatial-audio",
      action="store_true",
      help=
      "spatial audio. First-order periphonic ambisonics with ACN channel "
      "ordering and SN3D normalization")
  parser.add_argument("file", nargs="+", help="input/output files")

  args = parser.parse_args()

  if args.inject:
    if len(args.file) != 2:
      console("Injecting metadata requires both an input file and output file.")
      return

    metadata = metadata_utils.Metadata()
    metadata.video = metadata_utils.generate_spherical_xml(args.stereo_mode,
                                                           args.crop)

    if args.spatial_audio:
      metadata.audio = metadata_utils.SPATIAL_AUDIO_DEFAULT_METADATA

    if metadata.video:
      metadata_utils.inject_metadata(args.file[0], args.file[1], metadata,
                                     console)
    else:
      console("Failed to generate metadata.")
    return

  if len(args.file) > 0:
    for input_file in args.file:
      metadata_utils.parse_metadata(input_file, console)
    return

  parser.print_help()
  return