Skip to content

Commit 008d63e

Browse files
committed
Adding support for only setting stereo mode in v1 version of
the spec.
1 parent 83c4ffe commit 008d63e

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

spatialmedia/__main__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ def main():
5757
choices=["none", "top-bottom", "left-right"],
5858
default="none",
5959
help="stereo mode (none | top-bottom | left-right)")
60+
video_group.add_argument("-p",
61+
"--projection",
62+
action="store",
63+
dest="projection",
64+
choices=["none", "equirectangular"],
65+
default="equirectangular",
66+
help="projection (none | equirectangular)")
6067
video_group.add_argument(
6168
"-c",
6269
"--crop",
@@ -85,7 +92,8 @@ def main():
8592
return
8693

8794
metadata = metadata_utils.Metadata()
88-
metadata.video = metadata_utils.generate_spherical_xml(args.stereo_mode,
95+
metadata.video = metadata_utils.generate_spherical_xml(args.projection,
96+
args.stereo_mode,
8997
args.crop)
9098

9199
if args.spatial_audio:

spatialmedia/metadata_utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
"</GSpherical:StitchingSoftware>"\
5050
"<GSpherical:ProjectionType>equirectangular</GSpherical:ProjectionType>"
5151

52+
NOT_SPHERICAL_XML_CONTENTS = \
53+
"<GSpherical:Spherical>false</GSpherical:Spherical>"\
54+
"<GSpherical:Stitched>false</GSpherical:Stitched>"\
55+
"<GSpherical:StitchingSoftware>"\
56+
"Spherical Metadata Tool"\
57+
"</GSpherical:StitchingSoftware>"\
58+
"<GSpherical:ProjectionType>rectangular</GSpherical:ProjectionType>"
59+
5260
SPHERICAL_XML_CONTENTS_TOP_BOTTOM = \
5361
"<GSpherical:StereoMode>top-bottom</GSpherical:StereoMode>"
5462
SPHERICAL_XML_CONTENTS_LEFT_RIGHT = \
@@ -176,6 +184,7 @@ def mpeg4_add_spherical(mpeg4_file, in_fh, metadata):
176184
mpeg4_file.resize()
177185
return True
178186

187+
179188
def mpeg4_add_spatial_audio(mpeg4_file, in_fh, audio_metadata, console):
180189
"""Adds spatial audio metadata to the first audio track of the input
181190
mpeg4_file. Returns False on failure.
@@ -433,7 +442,7 @@ def inject_metadata(src, dest, metadata, console):
433442
console("Unknown file type")
434443

435444

436-
def generate_spherical_xml(stereo=None, crop=None):
445+
def generate_spherical_xml(projection="equiretangular", stereo=None, crop=None):
437446
# Configure inject xml.
438447
additional_xml = ""
439448
if stereo == "top-bottom":
@@ -499,7 +508,8 @@ def generate_spherical_xml(stereo=None, crop=None):
499508
cropped_offset_left_pixels, cropped_offset_top_pixels)
500509

501510
spherical_xml = (SPHERICAL_XML_HEADER +
502-
SPHERICAL_XML_CONTENTS +
511+
(SPHERICAL_XML_CONTENTS if projection == "equirectangular"
512+
else NOT_SPHERICAL_XML_CONTENTS) +
503513
additional_xml +
504514
SPHERICAL_XML_FOOTER)
505515
return spherical_xml

0 commit comments

Comments
 (0)