XEPG performance

This commit is contained in:
marmei
2019-10-11 17:53:20 +02:00
parent dc42afcd05
commit 3d9266dabe
7 changed files with 68 additions and 25 deletions

View File

@@ -213,7 +213,7 @@ func bufferingStream(playlistID, streamingURL, channelName string, w http.Respon
case "xteve": case "xteve":
go connectToStreamingServer(streamID, playlistID) go connectToStreamingServer(streamID, playlistID)
case "ffmpeg", "vlc": case "ffmpeg", "vlc":
go bufferWithFfmpeg(streamID, playlistID) go thirdPartyBuffer(streamID, playlistID)
default: default:
break break
@@ -1273,12 +1273,6 @@ func parseM3U8(stream *ThisStream) (err error) {
break break
} }
err := checkFile(stream.Folder + "remove")
if err == nil {
os.RemoveAll(stream.Folder)
break
}
} }
} }
@@ -1338,7 +1332,7 @@ func switchBandwidth(stream *ThisStream) (err error) {
} }
// Buffer mit FFMPEG // Buffer mit FFMPEG
func bufferWithFfmpeg(streamID int, playlistID string) { func thirdPartyBuffer(streamID int, playlistID string) {
if p, ok := BufferInformation.Load(playlistID); ok { if p, ok := BufferInformation.Load(playlistID); ok {
@@ -1354,6 +1348,8 @@ func bufferWithFfmpeg(streamID int, playlistID string) {
var tmpFolder = playlist.Streams[streamID].Folder var tmpFolder = playlist.Streams[streamID].Folder
var url = playlist.Streams[streamID].URL var url = playlist.Streams[streamID].URL
stream.Status = false
bufferType = strings.ToUpper(Settings.Buffer) bufferType = strings.ToUpper(Settings.Buffer)
switch Settings.Buffer { switch Settings.Buffer {
@@ -1393,6 +1389,14 @@ func bufferWithFfmpeg(streamID int, playlistID string) {
return return
} }
err = checkFile(path)
if err != nil {
ShowError(err, 0)
addErrorToStream(err)
return
}
showInfo(fmt.Sprintf("%s path:%s", bufferType, path))
showInfo("Streaming URL:" + stream.URL) showInfo("Streaming URL:" + stream.URL)
var tmpFile = fmt.Sprintf("%s%d.ts", tmpFolder, tmpSegment) var tmpFile = fmt.Sprintf("%s%d.ts", tmpFolder, tmpSegment)
@@ -1435,6 +1439,7 @@ func bufferWithFfmpeg(streamID int, playlistID string) {
} }
cmd.Start() cmd.Start()
defer cmd.Wait()
go func() { go func() {
@@ -1444,7 +1449,7 @@ func bufferWithFfmpeg(streamID int, playlistID string) {
for scanner.Scan() { for scanner.Scan() {
debug = fmt.Sprintf("%s:%s", bufferType, strings.TrimSpace(scanner.Text())) debug = fmt.Sprintf("%s log:%s", bufferType, strings.TrimSpace(scanner.Text()))
select { select {
case <-streamStatus: case <-streamStatus:
@@ -1475,7 +1480,7 @@ func bufferWithFfmpeg(streamID int, playlistID string) {
var timeout = 0 var timeout = 0
for { for {
time.Sleep(time.Duration(100) * time.Millisecond) time.Sleep(time.Duration(1000) * time.Millisecond)
timeout++ timeout++
select { select {
@@ -1545,9 +1550,11 @@ func bufferWithFfmpeg(streamID int, playlistID string) {
f.Close() f.Close()
tmpSegment++ tmpSegment++
if stream.Status == false {
stream.Status = true stream.Status = true
playlist.Streams[streamID] = stream playlist.Streams[streamID] = stream
BufferInformation.Store(playlistID, playlist) BufferInformation.Store(playlistID, playlist)
}
tmpFile = fmt.Sprintf("%s%d.ts", tmpFolder, tmpSegment) tmpFile = fmt.Sprintf("%s%d.ts", tmpFolder, tmpSegment)

View File

@@ -47,7 +47,7 @@ func Init() (err error) {
System.Compatibility = "1.4.4" System.Compatibility = "1.4.4"
// FFmpeg Default Einstellungen // FFmpeg Default Einstellungen
System.FFmpeg.DefaultOptions = "-hide_banner -loglevel panic -i [URL] -c copy -f mpegts pipe:1" System.FFmpeg.DefaultOptions = "-hide_banner -loglevel error -i [URL] -c copy -f mpegts pipe:1"
System.VLC.DefaultOptions = "-I dummy [URL] --sout #std{mux=ts,access=file,dst=-}" System.VLC.DefaultOptions = "-I dummy [URL] --sout #std{mux=ts,access=file,dst=-}"
// Default Logeinträge, wird später von denen aus der settings.json überschrieben. Muss gemacht werden, damit die ersten Einträge auch im Log (webUI aangezeigt werden) // Default Logeinträge, wird später von denen aus der settings.json überschrieben. Muss gemacht werden, damit die ersten Einträge auch im Log (webUI aangezeigt werden)

View File

@@ -503,8 +503,20 @@ func saveXEpgMapping(request RequestStruct) (err error) {
if System.ScanInProgress == 0 { if System.ScanInProgress == 0 {
System.ScanInProgress = 1
cleanupXEPG() cleanupXEPG()
buildXEPG(true) //buildXEPG(true)
go func() {
createXMLTVFile()
createM3UFile()
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
go cachingImages()
System.ScanInProgress = 0
}()
} else { } else {
@@ -525,8 +537,17 @@ func saveXEpgMapping(request RequestStruct) (err error) {
} }
System.ScanInProgress = 1
cleanupXEPG() cleanupXEPG()
buildXEPG(false) //buildXEPG(false)
createXMLTVFile()
createM3UFile()
showInfo("XEPG:" + fmt.Sprintf("Ready to use"))
go cachingImages()
System.ScanInProgress = 0
System.BackgroundProcess = false System.BackgroundProcess = false

View File

@@ -261,7 +261,6 @@ func getErrMsg(errCode int) (errMsg string) {
case 1050: case 1050:
errMsg = fmt.Sprintf("Invalid duration specification in the M3U8 playlist.") errMsg = fmt.Sprintf("Invalid duration specification in the M3U8 playlist.")
// M3U Parser
case 1060: case 1060:
errMsg = fmt.Sprintf("Invalid characters found in the tvg parameters, streams with invalid parameters were skipped.") errMsg = fmt.Sprintf("Invalid characters found in the tvg parameters, streams with invalid parameters were skipped.")
@@ -270,6 +269,8 @@ func getErrMsg(errCode int) (errMsg string) {
errMsg = fmt.Sprintf("Folder could not be created.") errMsg = fmt.Sprintf("Folder could not be created.")
case 1071: case 1071:
errMsg = fmt.Sprintf("File could not be created") errMsg = fmt.Sprintf("File could not be created")
case 1072:
errMsg = fmt.Sprintf("File not found")
// Backup // Backup
case 1090: case 1090:

View File

@@ -45,13 +45,25 @@ func checkFolder(path string) (err error) {
return nil return nil
} }
// Prüft ob die datei im Dateisystem existiert // Prüft ob die Datei im Dateisystem existiert
func checkFile(filename string) (err error) { func checkFile(filename string) (err error) {
var file = getPlatformFile(filename) var file = getPlatformFile(filename)
if _, err = os.Stat(file); os.IsNotExist(err) { if _, err = os.Stat(file); os.IsNotExist(err) {
return return err
}
fi, err := os.Stat(file)
if err != nil {
return err
}
switch mode := fi.Mode(); {
case mode.IsDir():
err = fmt.Errorf("%s: %s", file, getErrMsg(1072))
case mode.IsRegular():
break
} }
return return

View File

@@ -129,7 +129,12 @@ func Stream(w http.ResponseWriter, r *http.Request) {
return return
} }
/* switch Settings.Buffer {
case "-":
showInfo(fmt.Sprintf("Buffer:false", Settings.Buffer))
case "xteve":
if strings.Index(streamInfo.URL, "rtsp://") != -1 || strings.Index(streamInfo.URL, "rtp://") != -1 { if strings.Index(streamInfo.URL, "rtsp://") != -1 || strings.Index(streamInfo.URL, "rtp://") != -1 {
err = errors.New("RTSP and RTP streams are not supported") err = errors.New("RTSP and RTP streams are not supported")
ShowError(err, 2004) ShowError(err, 2004)
@@ -140,12 +145,9 @@ func Stream(w http.ResponseWriter, r *http.Request) {
showInfo("Streaming Info:URL was passed to the client") showInfo("Streaming Info:URL was passed to the client")
return return
} }
*/
switch Settings.Buffer { showInfo(fmt.Sprintf("Buffer:true [%s]", Settings.Buffer))
case "-":
showInfo(fmt.Sprintf("Buffer:false", Settings.Buffer))
default: default:
showInfo(fmt.Sprintf("Buffer:true [%s]", Settings.Buffer)) showInfo(fmt.Sprintf("Buffer:true [%s]", Settings.Buffer))

View File

@@ -39,7 +39,7 @@ var GitHub = GitHubStruct{Branch: "master", User: "xteve-project", Repo: "xTeVe-
const Name = "xTeVe" const Name = "xTeVe"
// Version : Version, die Build Nummer wird in der main func geparst. // Version : Version, die Build Nummer wird in der main func geparst.
const Version = "2.0.3.0042" const Version = "2.0.3.0048"
// DBVersion : Datanbank Version // DBVersion : Datanbank Version
const DBVersion = "2.1.0" const DBVersion = "2.1.0"