Browse Source

Merge branch 'master' into fix-initial-offline-state

pull/10/head
Bradley Hilton 5 years ago committed by GitHub
parent
commit
5611f4d00e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .gitignore
  2. 4
      ffmpeg.go
  3. 2
      scripts/build.sh
  4. BIN
      static/logo.png
  5. 18
      thumbnailGenerator.go
  6. 6
      utils.go
  7. 2
      webroot/index.html

2
.gitignore vendored

@ -18,7 +18,7 @@ vendor/ @@ -18,7 +18,7 @@ vendor/
config/config.yaml
config/stats.json
owncast
webroot/thumbnail.png
webroot/thumbnail.jpg
webroot/hls
webroot/static/content.md
hls/

4
ffmpeg.go

@ -51,7 +51,7 @@ func showStreamOfflineState(configuration Config) { @@ -51,7 +51,7 @@ func showStreamOfflineState(configuration Config) {
// "-stream_loop 100",
// "-fflags", "+genpts",
"-i", configuration.VideoSettings.OfflineImage,
"-i", "webroot/thumbnail.png",
"-i", "webroot/thumbnail.jpg",
"-filter_complex", "\"[0:v]scale=2640:2360[bg];[bg][1:v]overlay=200:250:enable='between(t,0,3)'\"",
videoMapsString, // All the different video variants
"-f hls",
@ -81,7 +81,7 @@ func showStreamOfflineState(configuration Config) { @@ -81,7 +81,7 @@ func showStreamOfflineState(configuration Config) {
ffmpegCmd := configuration.FFMpegPath + " " + ffmpegFlagsString
fmt.Println(ffmpegCmd)
// fmt.Println(ffmpegCmd)
_, err := exec.Command("sh", "-c", ffmpegCmd).Output()
fmt.Println(err)

2
scripts/build.sh

@ -21,7 +21,7 @@ GIT_COMMIT=$(git rev-list -1 HEAD) @@ -21,7 +21,7 @@ GIT_COMMIT=$(git rev-list -1 HEAD)
cd $(git rev-parse --show-toplevel)
echo "Cleaning working directories..."
rm -rf ./webroot/hls/* ./hls/* ./webroot/thumbnail.png
rm -rf ./webroot/hls/* ./hls/* ./webroot/thumbnail.jpg
echo "Creating version ${VERSION} from commit ${GIT_COMMIT}"

BIN
static/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

18
thumbnailGenerator.go

@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"path"
"strings"
"time"
)
@ -30,7 +31,9 @@ func startThumbnailGenerator(chunkPath string) { @@ -30,7 +31,9 @@ func startThumbnailGenerator(chunkPath string) {
func fireThumbnailGenerator(chunkPath string) {
framePath := path.Join(chunkPath, "0")
files, err := ioutil.ReadDir(framePath)
outputFile := path.Join("webroot", "thumbnail.png")
// JPG takes less time to encode than PNG
outputFile := path.Join("webroot", "thumbnail.jpg")
// fmt.Println("Generating thumbnail from", framePath, "to", outputFile)
@ -63,7 +66,18 @@ func fireThumbnailGenerator(chunkPath string) { @@ -63,7 +66,18 @@ func fireThumbnailGenerator(chunkPath string) {
mostRecentFile := path.Join(framePath, names[0])
ffmpegCmd := "ffmpeg -y -i " + mostRecentFile + " -ss 00:00:01.000 -vframes 1 " + outputFile
thumbnailCmdFlags := []string{
configuration.FFMpegPath,
"-y", // Overwrite file
"-threads 1", // Low priority processing
"-t 1", // Pull from frame 1
"-i", mostRecentFile, // Input
"-f image2", // format
"-vframes 1", // Single frame
outputFile,
}
ffmpegCmd := strings.Join(thumbnailCmdFlags, " ")
// fmt.Println(ffmpegCmd)

6
utils.go

@ -63,7 +63,7 @@ func resetDirectories(configuration Config) { @@ -63,7 +63,7 @@ func resetDirectories(configuration Config) {
os.MkdirAll(configuration.PrivateHLSPath, 0777)
// Remove the previous thumbnail
os.Remove("webroot/thumbnail.png")
os.Remove("webroot/thumbnail.jpg")
// Create private hls data dirs
if !configuration.VideoSettings.EnablePassthrough || len(configuration.VideoSettings.StreamQualities) == 0 {
@ -79,8 +79,8 @@ func resetDirectories(configuration Config) { @@ -79,8 +79,8 @@ func resetDirectories(configuration Config) {
func createInitialOfflineState() {
// Provide default files
if !fileExists("webroot/thumbnail.png") {
copy("static/logo-900x720.png", "webroot/thumbnail.png")
if !fileExists("webroot/thumbnail.jpg") {
copy("static/logo.png", "webroot/thumbnail.jpg")
}
showStreamOfflineState(configuration)

2
webroot/index.html

@ -74,7 +74,7 @@ GW TODO: @@ -74,7 +74,7 @@ GW TODO:
autoplay
playsinline
muted
poster="/thumbnail.png"
poster="/thumbnail.jpg"
>
</video>
</div>

Loading…
Cancel
Save