Skip to content

Commit

Permalink
feat: detect alpha passthrough from filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Alderamin committed Jan 8, 2025
1 parent 5f58753 commit 2aeb533
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
20 changes: 17 additions & 3 deletions pkg/api/deovr.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
return cuepoints[i].TS < cuepoints[j].TS
})

var hasAlpha bool = false

// Set Scene projection IF either single video or all videos have same projection type
if sceneMultiProjection {
if videoFiles[0].VideoProjection == "mkx200" ||
Expand Down Expand Up @@ -496,6 +498,8 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
stereoMode = "off"
screenType = "dome"
}

hasAlpha = videoFiles[0].HasAlpha
}

title := scene.Title
Expand All @@ -522,6 +526,8 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
fmt.Println("Error:", err)
}
chromaKey = gjson.ParseBytes(ckup)
} else if hasAlpha {
chromaKey = gjson.Parse(`{"enabled":true,"hasAlpha":true,"h":0,"opacity":0,"s":0,"threshold":0,"v":0}`)
}

// set date to EPOCH in case it is missing or 0001-01-01
Expand Down Expand Up @@ -561,7 +567,7 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
deoScene.VideoPreview = fmt.Sprintf("%v/api/dms/preview/%v", session.DeoRequestHost, scene.SceneID)
}

if gjson.Valid(scene.ChromaKey) {
if gjson.Valid(scene.ChromaKey) || hasAlpha {
deoPtScene := DeoScenePassthrough{
ID: scene.ID,
Authorized: 1,
Expand All @@ -587,8 +593,16 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
Categories: categories,
Fleshlight: deoScriptFiles,
HSProfile: deoHSPFiles,
ChromaKey: DeoSceneChromaKey{Enabled: chromaKey.Get("enabled").String(), HasAlpha: chromaKey.Get("hasAlpha").String(), H: chromaKey.Get("h").Float(), Opacity: chromaKey.Get("opacity").Float(), S: chromaKey.Get("s").Float(), Threshold: chromaKey.Get("threshold").Float(), V: chromaKey.Get("v").Float()},
VideoPreview: deoScene.VideoPreview,
ChromaKey: DeoSceneChromaKey{
Enabled: chromaKey.Get("enabled").String(),
HasAlpha: chromaKey.Get("hasAlpha").String(),
H: chromaKey.Get("h").Float(),
Opacity: chromaKey.Get("opacity").Float(),
S: chromaKey.Get("s").Float(),
Threshold: chromaKey.Get("threshold").Float(),
V: chromaKey.Get("v").Float(),
},
VideoPreview: deoScene.VideoPreview,
}
resp.WriteHeaderAndEntity(http.StatusOK, deoPtScene)
} else {
Expand Down
5 changes: 4 additions & 1 deletion pkg/api/heresphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,10 @@ func (i HeresphereResource) getHeresphereScene(req *restful.Request, resp *restf
}

var alphaPackedSettings *HereSphereAlphaPackedSettings = nil
if gjson.Valid(scene.ChromaKey) {
if videoFiles[0].HasAlpha {
alphaPackedSettings = &HereSphereAlphaPackedSettings{DefaultSettings: true}
addFeatureTag("Is Alpha Passthrough")
} else if gjson.Valid(scene.ChromaKey) {
result := gjson.Get(scene.ChromaKey, "hasAlpha")
if result.Exists() && result.Bool() {
alphaPackedSettings = &HereSphereAlphaPackedSettings{DefaultSettings: true}
Expand Down
9 changes: 9 additions & 0 deletions pkg/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,15 @@ func Migrate() {
return nil
},
},
{
ID: "0081-file-has-alpha",
Migrate: func(tx *gorm.DB) error {
type File struct {
HasAlpha bool `json:"has_alpha" gorm:"default:false"`
}
return tx.AutoMigrate(File{}).Error
},
},

// ===============================================================================================
// Put DB Schema migrations above this line and migrations that rely on the updated schema below
Expand Down
1 change: 1 addition & 0 deletions pkg/models/model_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type File struct {
VideoCodecName string `json:"video_codec_name" xbvrbackup:"video_codec_name"`
VideoDuration float64 `json:"duration" xbvrbackup:"duration"`
VideoProjection string `json:"projection" xbvrbackup:"projection"`
HasAlpha bool `json:"has_alpha" xbvrbackup:"has_alpha"`

HasHeatmap bool `json:"has_heatmap" xbvrbackup:"-"`
IsSelectedScript bool `json:"is_selected_script" xbvrbackup:"is_selected_script"`
Expand Down
10 changes: 10 additions & 0 deletions pkg/tasks/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ func scanLocalVolume(vol models.Volume, db *gorm.DB, tlog *logrus.Entry) {
} else if ffdata.Format.DurationSeconds > 0.0 {
fl.VideoDuration = ffdata.Format.DurationSeconds
}
fl.HasAlpha = false

if vs.Height*2 == vs.Width || vs.Width > vs.Height {
fl.VideoProjection = "180_sbs"
Expand All @@ -312,6 +313,15 @@ func scanLocalVolume(vol models.Volume, db *gorm.DB, tlog *logrus.Entry) {
break
}
}
if fl.VideoProjection == "mkx200" || fl.VideoProjection == "mkx220" || fl.VideoProjection == "rf52" || fl.VideoProjection == "fisheye190" || fl.VideoProjection == "vrca220" {
// alpha passthrough only works with fisheye projections
for _, part := range nameparts {
if part == "alpha" {
fl.HasAlpha = true
break
}
}
}
}

if vs.Height == vs.Width {
Expand Down

0 comments on commit 2aeb533

Please sign in to comment.