Silent timeline removed when hitting export

This commit is contained in:
2026-02-27 00:23:51 -08:00
parent c82ac37358
commit 96e99d2029
4 changed files with 42 additions and 17 deletions

View File

@@ -14,6 +14,13 @@ import (
type exportRequest struct {
Filename string `json:"filename"`
Segments []transcode.Segment `json:"segments"`
Duration float64 `json:"duration"`
}
type updateTimeLine struct {
Type string `json:"type"`
Segments []transcode.Segment `json:"segments"`
Duration float64 `json:"duration"`
}
func ExportHandler(st *store.Store, hub *ws.Hub) http.HandlerFunc {
@@ -28,6 +35,7 @@ func ExportHandler(st *store.Store, hub *ws.Hub) http.HandlerFunc {
http.Error(w, "bad JSON: "+err.Error(), http.StatusBadRequest)
return
}
if len(req.Segments) == 0 {
http.Error(w, "no segments", http.StatusBadRequest)
return
@@ -50,15 +58,30 @@ func ExportHandler(st *store.Store, hub *ws.Hub) http.HandlerFunc {
return
}
msg, _ := json.Marshal(map[string]string{
doneMsg, _ := json.Marshal(map[string]string{
"type": "done",
"message": outputKey,
})
hub.Broadcast(msg)
hub.Broadcast(doneMsg)
// Build normalized segments for the exported video: timestamps start at 0
// with no gaps, so the timeline reflects the exported file's layout.
var normalized []transcode.Segment
cursor := 0.0
for _, seg := range req.Segments {
dur := seg.End - seg.Start
normalized = append(normalized, transcode.Segment{Start: cursor, End: cursor + dur})
cursor += dur
}
timelineMsg, _ := json.Marshal(updateTimeLine{
Type: "timeline",
Segments: normalized,
Duration: cursor,
})
hub.Broadcast(timelineMsg)
}()
w.WriteHeader(http.StatusAccepted)
log.Println("Export handler works")
}
}

View File

@@ -27,8 +27,7 @@ func ZoomHandler(hub *ws.Hub) http.HandlerFunc {
return
}
h := transcode.HandlerZoom{Center: req.Center}
result := h.TimelineZoom(req.Zoom, req.Duration)
result := transcode.TimelineZoom(req.Center, req.Zoom, req.Duration)
data, _ := json.Marshal(result)
hub.Broadcast(data)