Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add stereo mode and screen type from file name #3

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

```bash
# Copy the example environment file to .env
# Change the WEB_HOST value to your domain name or IP address
# Set DEOVR_JSON_GEN_URL to the URL of your domain (if any), else
# Change the WEB_HOST value to your IP address
cp .env.example .env

# Create an empty deovr file on project root
Expand Down
32 changes: 29 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,32 @@ def strtobool(value: Any) -> bool | None:
return None


def get_stereo_mode(path: Path) -> StereoMode:
file_name = path.name.lower()
if any([True for i in {"tb", "top-bottom", "over-under", "3dv"} if i in file_name]):
return StereoMode.TOP_BOTTOM
elif any([True for i in {"cuv", "custom_uv"} if i in file_name]):
return StereoMode.CUSTOM_UV
elif any([True for i in {"off", "2d", "mono", "single"} if i in file_name]):
return StereoMode.MONOSCOPIC
else: # "sbs", "lr", "left-right", "side-by-side", "3dh"
return StereoMode.SIDE_BY_SIDE


def get_screen_type(path: Path) -> ScreenType:
file_name = path.name.lower()
if any([True for i in {"rf52", "190", "fisheye190"} if i in file_name]):
return ScreenType.FISHEYE_190
elif any([True for i in {"mkx200", "200", "fisheye200"} if i in file_name]):
return ScreenType.FISHEYE_200
elif any([True for i in {"sphere", "360", "full"} if i in file_name]):
return ScreenType.EQUIRECT_360
elif any([True for i in {"fisheye"} if i in file_name]):
return ScreenType.FISHEYE_180
else: # "dome", "180", "half"
return ScreenType.EQUIRECT_180


def get_video_length(path: Path) -> int:
media_info = MediaInfo.parse(path)
general_tracks = [t for t in media_info.tracks if t.track_type == "General"]
Expand Down Expand Up @@ -116,9 +142,9 @@ def get_scene(path: Path) -> Scene:
videoLength=get_video_length(path),
thumbnailUrl="https://www.iconsdb.com/icons/preview/red/video-play-xxl.png",
video_url=get_video_url(path),
is3d=True,
stereoMode=StereoMode.SIDE_BY_SIDE,
screenType=ScreenType.EQUIRECT_180,
is3d=True, # always true
stereoMode=get_stereo_mode(path),
screenType=get_screen_type(path),
)


Expand Down