Skip to content

Commit

Permalink
pending: fix and hook up spectrogram viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanyuu committed Jan 4, 2025
1 parent 2172853 commit 730edee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions assets/js/radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,19 @@ function adminPlayerPlayPause() {
}
}

function adminShowSpectrogram() {
let img = document.querySelector("#admin-player-spec-image");
let modal = document.querySelector("#admin-player-spec-modal");
if (img && modal && admin_player.src) {
// Only the pending endpoint supports spectrograms, but
// the player is used for both pending and database.
if (admin_player.src.includes("pending")) {
img.src = admin_player.src + "?spectrum=true";
modal.classList.add("is-active");
}
}
}

// updateTimes looks for all <time> elements and applies timeago logic to it
function updateTimes() {
if (timeUpdateTimer) {
Expand Down
2 changes: 1 addition & 1 deletion streamer/audio/spectrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Spectrum(ctx context.Context, filename string) (*os.File, error) {
"-y", "-v", "error", "-hide_banner",
"-i", filename,
"-filter_complex", "[0:a:0]aresample=48000:resampler=soxr,showspectrumpic=s=640x512,crop=780:544:70:50[o]",
"-map", "[o]", "-frames:v", "1", "-q:v", "3", "-",
"-map", "[o]", "-frames:v", "1", "-q:v", "3", "-f", "webp", "-",
)
cmd.Stdout = f.File

Expand Down

0 comments on commit 730edee

Please sign in to comment.