Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc0260f

Browse files
Alderamin49lyAlderamin
and
Alderamin
authored
feat: detect alpha passthrough from filename (#1900)
Co-authored-by: Alderamin <alderamin49ly@gmail.com>
1 parent4171523 commitdc0260f

File tree

6 files changed

+43
-6
lines changed

6 files changed

+43
-6
lines changed

‎pkg/api/deovr.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
460460
returncuepoints[i].TS<cuepoints[j].TS
461461
})
462462

463+
varhasAlphabool=false
464+
463465
// Set Scene projection IF either single video or all videos have same projection type
464466
ifsceneMultiProjection {
465467
ifvideoFiles[0].VideoProjection=="mkx200"||
@@ -496,6 +498,8 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
496498
stereoMode="off"
497499
screenType="dome"
498500
}
501+
502+
hasAlpha=videoFiles[0].HasAlpha
499503
}
500504

501505
title:=scene.Title
@@ -522,6 +526,8 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
522526
fmt.Println("Error:",err)
523527
}
524528
chromaKey=gjson.ParseBytes(ckup)
529+
}elseifhasAlpha {
530+
chromaKey=gjson.Parse(`{"enabled":true,"hasAlpha":true,"h":0,"opacity":0,"s":0,"threshold":0,"v":0}`)
525531
}
526532

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

564-
ifgjson.Valid(scene.ChromaKey) {
570+
ifgjson.Valid(scene.ChromaKey)||hasAlpha{
565571
deoPtScene:=DeoScenePassthrough{
566572
ID:scene.ID,
567573
Authorized:1,
@@ -587,8 +593,16 @@ func (i DeoVRResource) getDeoScene(req *restful.Request, resp *restful.Response)
587593
Categories:categories,
588594
Fleshlight:deoScriptFiles,
589595
HSProfile:deoHSPFiles,
590-
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()},
591-
VideoPreview:deoScene.VideoPreview,
596+
ChromaKey:DeoSceneChromaKey{
597+
Enabled:chromaKey.Get("enabled").String(),
598+
HasAlpha:chromaKey.Get("hasAlpha").String(),
599+
H:chromaKey.Get("h").Float(),
600+
Opacity:chromaKey.Get("opacity").Float(),
601+
S:chromaKey.Get("s").Float(),
602+
Threshold:chromaKey.Get("threshold").Float(),
603+
V:chromaKey.Get("v").Float(),
604+
},
605+
VideoPreview:deoScene.VideoPreview,
592606
}
593607
resp.WriteHeaderAndEntity(http.StatusOK,deoPtScene)
594608
}else {

‎pkg/api/heresphere.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,10 @@ func (i HeresphereResource) getHeresphereScene(req *restful.Request, resp *restf
704704
}
705705

706706
varalphaPackedSettings*HereSphereAlphaPackedSettings=nil
707-
ifgjson.Valid(scene.ChromaKey) {
707+
ifvideoFiles[0].HasAlpha {
708+
alphaPackedSettings=&HereSphereAlphaPackedSettings{DefaultSettings:true}
709+
addFeatureTag("Is Alpha Passthrough")
710+
}elseifgjson.Valid(scene.ChromaKey) {
708711
result:=gjson.Get(scene.ChromaKey,"hasAlpha")
709712
ifresult.Exists()&&result.Bool() {
710713
alphaPackedSettings=&HereSphereAlphaPackedSettings{DefaultSettings:true}

‎pkg/migrations/migrations.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,15 @@ func Migrate() {
833833
returntx.Exec("update sites set scrape_stash = is_enabled").Error
834834
},
835835
},
836+
{
837+
ID:"0083-file-has-alpha",
838+
Migrate:func(tx*gorm.DB)error {
839+
typeFilestruct {
840+
HasAlphabool`json:"has_alpha" gorm:"default:false"`
841+
}
842+
returntx.AutoMigrate(File{}).Error
843+
},
844+
},
836845

837846
// ===============================================================================================
838847
// Put DB Schema migrations above this line and migrations that rely on the updated schema below

‎pkg/models/model_file.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type File struct {
3737
VideoCodecNamestring`json:"video_codec_name" xbvrbackup:"video_codec_name"`
3838
VideoDurationfloat64`json:"duration" xbvrbackup:"duration"`
3939
VideoProjectionstring`json:"projection" xbvrbackup:"projection"`
40+
HasAlphabool`json:"has_alpha" xbvrbackup:"has_alpha"`
4041

4142
HasHeatmapbool`json:"has_heatmap" xbvrbackup:"-"`
4243
IsSelectedScriptbool`json:"is_selected_script" xbvrbackup:"is_selected_script"`

‎pkg/models/model_scene.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,9 @@ func queryScenes(db *gorm.DB, r RequestSceneList) (*gorm.DB, *gorm.DB) {
878878
case"Is Favourite":
879879
where="scenes.favourite = 1"
880880
case"Is Passthrough":
881-
where="chroma_key <> ''"
881+
where="(chroma_key <> '' or exists (select 1 from files where files.scene_id = scenes.id and files.`type` = 'video' and files.has_alpha = true))"
882882
case"Is Alpha Passthrough":
883-
where=`chroma_key <> '' and chroma_key like '%"hasAlpha":true%'`
883+
where=`((chroma_key <> '' and chroma_key like '%"hasAlpha":true%') or `+"exists (select 1 from files where files.scene_id = scenes.id and files.`type` = 'video' and files.has_alpha = true))"
884884
case"In Wishlist":
885885
where="wishlist = 1"
886886
case"Stashdb Linked":

‎pkg/tasks/volume.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ func scanLocalVolume(vol models.Volume, db *gorm.DB, tlog *logrus.Entry) {
293293
}elseifffdata.Format.DurationSeconds>0.0 {
294294
fl.VideoDuration=ffdata.Format.DurationSeconds
295295
}
296+
fl.HasAlpha=false
296297

297298
ifvs.Height*2==vs.Width||vs.Width>vs.Height {
298299
fl.VideoProjection="180_sbs"
@@ -312,6 +313,15 @@ func scanLocalVolume(vol models.Volume, db *gorm.DB, tlog *logrus.Entry) {
312313
break
313314
}
314315
}
316+
iffl.VideoProjection=="mkx200"||fl.VideoProjection=="mkx220"||fl.VideoProjection=="rf52"||fl.VideoProjection=="fisheye190"||fl.VideoProjection=="vrca220" {
317+
// alpha passthrough only works with fisheye projections
318+
for_,part:=rangenameparts {
319+
ifpart=="alpha" {
320+
fl.HasAlpha=true
321+
break
322+
}
323+
}
324+
}
315325
}
316326

317327
ifvs.Height==vs.Width {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp