mirror of
https://github.com/owncast/owncast.git
synced 2024-11-24 21:59:43 +03:00
f81e8dcda7
* Mute the 'stream ended' clip's audio The 'stream ended' clip plays at the at the end of every stream broadcast using owncast. It currently contains audio that peaks at -7.1db. (according to ffmpeg's volumedetect audio filter) This can result in a bad experience for viewers if the stream that they were just watching had a much lower average volume, and they had turned up their speakers or headphones to compensate. In extreme cases this could theoretically cause harm to viewers and/or their equipment. As an admin running owncast, there is no way to remove this audio *except* for patching the file. Even if you do patch the file, you need to notify your viewers to clear their browser caches if they have ever seen the clip, because offline.ts has a cache-control max-age header specifying 365 days. The caching of the previous version of this clip is out of scope of this PR. This issue is discussed in more detail in #1965. Unlike my previous attempt in #3332, which removed the audio track, this PR *mutes* the audio. Specifically, I used this ffmpeg command: ``` ffmpeg -i offline.ts -filter:a "volume=0.0" output.ts ``` There are no other modifications to the clip. * Commit updated API documentation * feat(video): make compatible muted offline clip. Rename clip as a v2 so it is not cached * Fix conflict * force add new offline file --------- Co-authored-by: vivlim <vivlim@vivl.im> Co-authored-by: Owncast <owncast@owncast.online> Co-authored-by: Gabe Kangas <gabek@real-ity.com>
140 lines
3.4 KiB
Go
140 lines
3.4 KiB
Go
package core
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
"path/filepath"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"github.com/owncast/owncast/auth"
|
|
"github.com/owncast/owncast/config"
|
|
"github.com/owncast/owncast/core/chat"
|
|
"github.com/owncast/owncast/core/data"
|
|
"github.com/owncast/owncast/core/rtmp"
|
|
"github.com/owncast/owncast/core/transcoder"
|
|
"github.com/owncast/owncast/core/user"
|
|
"github.com/owncast/owncast/core/webhooks"
|
|
"github.com/owncast/owncast/models"
|
|
"github.com/owncast/owncast/notifications"
|
|
"github.com/owncast/owncast/utils"
|
|
"github.com/owncast/owncast/yp"
|
|
)
|
|
|
|
var (
|
|
_stats *models.Stats
|
|
_storage models.StorageProvider
|
|
_transcoder *transcoder.Transcoder
|
|
_yp *yp.YP
|
|
_broadcaster *models.Broadcaster
|
|
handler transcoder.HLSHandler
|
|
fileWriter = transcoder.FileWriterReceiverService{}
|
|
)
|
|
|
|
// Start starts up the core processing.
|
|
func Start() error {
|
|
resetDirectories()
|
|
|
|
data.PopulateDefaults()
|
|
|
|
if err := data.VerifySettings(); err != nil {
|
|
log.Error(err)
|
|
return err
|
|
}
|
|
|
|
if err := setupStats(); err != nil {
|
|
log.Error("failed to setup the stats")
|
|
return err
|
|
}
|
|
|
|
// The HLS handler takes the written HLS playlists and segments
|
|
// and makes storage decisions. It's rather simple right now
|
|
// but will play more useful when recordings come into play.
|
|
handler = transcoder.HLSHandler{}
|
|
|
|
if err := setupStorage(); err != nil {
|
|
log.Errorln("storage error", err)
|
|
}
|
|
|
|
user.SetupUsers()
|
|
auth.Setup(data.GetDatastore())
|
|
|
|
fileWriter.SetupFileWriterReceiverService(&handler)
|
|
|
|
if err := createInitialOfflineState(); err != nil {
|
|
log.Error("failed to create the initial offline state")
|
|
return err
|
|
}
|
|
|
|
_yp = yp.NewYP(GetStatus)
|
|
|
|
if err := chat.Start(GetStatus); err != nil {
|
|
log.Errorln(err)
|
|
}
|
|
|
|
// start the rtmp server
|
|
go rtmp.Start(setStreamAsConnected, setBroadcaster)
|
|
|
|
rtmpPort := data.GetRTMPPortNumber()
|
|
if rtmpPort != 1935 {
|
|
log.Infof("RTMP is accepting inbound streams on port %d.", rtmpPort)
|
|
}
|
|
|
|
webhooks.SetupWebhooks(GetStatus)
|
|
|
|
notifications.Setup(data.GetStore())
|
|
|
|
return nil
|
|
}
|
|
|
|
func createInitialOfflineState() error {
|
|
transitionToOfflineVideoStreamContent()
|
|
|
|
return nil
|
|
}
|
|
|
|
// transitionToOfflineVideoStreamContent will overwrite the current stream with the
|
|
// offline video stream state only. No live stream HLS segments will continue to be
|
|
// referenced.
|
|
func transitionToOfflineVideoStreamContent() {
|
|
log.Traceln("Firing transcoder with offline stream state")
|
|
|
|
_transcoder := transcoder.NewTranscoder()
|
|
_transcoder.SetIdentifier("offline")
|
|
_transcoder.SetLatencyLevel(models.GetLatencyLevel(4))
|
|
_transcoder.SetIsEvent(true)
|
|
|
|
offlineFilePath, err := saveOfflineClipToDisk("offline-v2.ts")
|
|
if err != nil {
|
|
log.Fatalln("unable to save offline clip:", err)
|
|
}
|
|
|
|
_transcoder.SetInput(offlineFilePath)
|
|
go _transcoder.Start(false)
|
|
|
|
// Copy the logo to be the thumbnail
|
|
logo := data.GetLogoPath()
|
|
dst := filepath.Join(config.TempDir, "thumbnail.jpg")
|
|
if err = utils.Copy(filepath.Join("data", logo), dst); err != nil {
|
|
log.Warnln(err)
|
|
}
|
|
|
|
// Delete the preview Gif
|
|
_ = os.Remove(path.Join(config.DataDirectory, "preview.gif"))
|
|
}
|
|
|
|
func resetDirectories() {
|
|
log.Trace("Resetting file directories to a clean slate.")
|
|
|
|
// Wipe hls data directory
|
|
utils.CleanupDirectory(config.HLSStoragePath)
|
|
|
|
// Remove the previous thumbnail
|
|
logo := data.GetLogoPath()
|
|
if utils.DoesFileExists(logo) {
|
|
err := utils.Copy(path.Join("data", logo), filepath.Join(config.DataDirectory, "thumbnail.jpg"))
|
|
if err != nil {
|
|
log.Warnln(err)
|
|
}
|
|
}
|
|
}
|