Switch back to hls from dash, change out flag default from hls to stream_cache, rename hls.html to stream.html
This commit is contained in:
parent
c39c08c0cd
commit
725f1dd71d
5 changed files with 16 additions and 23 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
result
|
||||
.DS_Store
|
||||
hls
|
||||
stream_cache
|
||||
.direnv
|
|
@ -15,8 +15,8 @@
|
|||
<h1 class="text-center">Best livestream website ever</h1>
|
||||
<div class="first-ui-row">
|
||||
<div>
|
||||
<video id="livestream" class="video-js" controls preload="auto" data-setup="{}">
|
||||
<source src="/media/stream.mpd" type="application/dash+xml" />
|
||||
<video id="livestream" class="video-js" controls preload="auto" data-setup='{"responsive": true}'>
|
||||
<source src="/media/stream.m3u8" type="application/x-mpegURL" />
|
||||
<p class="vjs-no-js">
|
||||
To view this video please enable JavaScript, and consider upgrading to a
|
||||
web browser that
|
6
main.go
6
main.go
|
@ -77,7 +77,7 @@ var embedHTML embed.FS
|
|||
var ErrMediaFolderNotSpecified = errors.New("Please specify media folder to use")
|
||||
|
||||
func parseFlags() (config Config, err error) {
|
||||
flag.StringVar(&config.OutDir, "out", "hls", "location to dump hls/m3u8 livestream files")
|
||||
flag.StringVar(&config.OutDir, "out", "stream_cache", "location to dump hls/m3u8 livestream files")
|
||||
flag.StringVar(&config.FallbackFile, "fallback", "family_guy_wheel.mp4", "Fallback video that is played when main stream is down")
|
||||
flag.StringVar(&config.MediaFolder, "media", "", "Folder to play random media from")
|
||||
flag.IntVar(&config.PublicPort, "public_port", 3000, "Port to run public website on")
|
||||
|
@ -122,12 +122,12 @@ func main() {
|
|||
}
|
||||
|
||||
if ready {
|
||||
c.FileFromFS("html/hls.html", http.FS(embedHTML))
|
||||
c.FileFromFS("html/stream.html", http.FS(embedHTML))
|
||||
} else {
|
||||
c.FileFromFS("html/loading.html", http.FS(embedHTML))
|
||||
}
|
||||
})
|
||||
// public.StaticFileFS("/", "html/hls.html", http.FS(embedHTML))
|
||||
|
||||
public.Static("/static", "static")
|
||||
public.Static("/media", config.OutDir)
|
||||
public.Any("/ws", func(c *gin.Context) {
|
||||
|
|
25
play.go
25
play.go
|
@ -10,7 +10,7 @@ import (
|
|||
ffmpeg "github.com/u2takey/ffmpeg-go"
|
||||
)
|
||||
|
||||
const OUTFILE = "stream.mpd"
|
||||
const OUTFILE = "stream.m3u8"
|
||||
|
||||
type ffmpegProcess struct {
|
||||
cancel func() error
|
||||
|
@ -35,19 +35,14 @@ func playffmpeg(loop bool, input string, output string, WhenVideoEnds func(force
|
|||
}
|
||||
|
||||
outputArgs := ffmpeg.KwArgs{
|
||||
"c:v": "libx264",
|
||||
"c:a": "copy",
|
||||
"streaming": "1",
|
||||
"window_size": "10",
|
||||
"remove_at_exit": "1",
|
||||
"hls_playlist": "1",
|
||||
"hls_master_name": "live.m3u8",
|
||||
"ldash": "1",
|
||||
"seg_duration": "1",
|
||||
"frag_duration": "1",
|
||||
"write_prft": "1",
|
||||
"target_latency": "1",
|
||||
"f": "dash",
|
||||
"c:v": "libx264",
|
||||
"c:a": "aac",
|
||||
"b:a": "128k",
|
||||
"ac": "2",
|
||||
"preset": "ultrafast",
|
||||
"hls_flags": "delete_segments+append_list+omit_endlist",
|
||||
"hls_time": "1",
|
||||
"f": "hls",
|
||||
}
|
||||
|
||||
if has_subs {
|
||||
|
@ -67,8 +62,6 @@ func playffmpeg(loop bool, input string, output string, WhenVideoEnds func(force
|
|||
ffmpegCmd := ffmpeg.Input(input, inputArgs).Output(output, outputArgs).Compile()
|
||||
f.cancel = ffmpegCmd.Cancel
|
||||
|
||||
log.Println("[DEBUG] Starting ffmpeg with flags:", strings.Join(ffmpegCmd.Args, " "))
|
||||
|
||||
go func() {
|
||||
out, err := ffmpegCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
@ -46,7 +46,7 @@ websocket.onmessage = (event) => {
|
|||
currently_playing.innerText = data.message
|
||||
|
||||
stream.one('error', function() {
|
||||
stream.src({ type: 'application/dash+xml', src: '/media/stream.mpd' });
|
||||
stream.src({ type: 'application/x-mpegURL', src: '/media/stream.m3u8' });
|
||||
stream.play();
|
||||
console.log("trying again")
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue