diff --git a/h264/h264Parser.go b/h264/h264Parser.go index 74a4386d..d79f3b21 100644 --- a/h264/h264Parser.go +++ b/h264/h264Parser.go @@ -60,7 +60,6 @@ func (p* H264Parser)Parse() { p.isParsing = true outputBuffer := make([]byte, 0, 10000) searchingForEnd := false - p.InputByteChan = make(chan byte, 10000) for p.isParsing { aByte := <-p.InputByteChan outputBuffer = append(outputBuffer, aByte) @@ -77,8 +76,6 @@ func (p* H264Parser)Parse() { aByte = <-p.InputByteChan outputBuffer = append(outputBuffer, aByte) if nalType := aByte & 0x1F; nalType == 1 || nalType == 5 { - if firstRunThrough { - spsPpsSei = append(spsPpsSei, searchingForEnd = true } } diff --git a/mpegts/MpegTs.go b/mpegts/MpegTs.go index 7339995d..50fd8362 100644 --- a/mpegts/MpegTs.go +++ b/mpegts/MpegTs.go @@ -31,7 +31,6 @@ package mpegts import ( "bitbucket.org/ausocean/av/tools" "errors" - _"fmt" ) const ( @@ -135,9 +134,13 @@ func (p *MpegTsPacket) FillPayload(channel chan byte){ p.Payload = make([]byte,0,mpegtsPayloadSize) currentPktLength := 6 + int(tools.BoolToByte(p.PCRF))*6+int(tools.BoolToByte(p.OPCRF))*6+ int(tools.BoolToByte(p.SPF))*1+int(tools.BoolToByte(p.TPDF))*1+len(p.TPD) - for len(channel) > 0 && (currentPktLength+len(p.Payload)) < 188 { - nextByte := <-channel - p.Payload = append(p.Payload,nextByte) + for (currentPktLength+len(p.Payload)) < 188 { + select { + case nextByte := <-channel: + p.Payload = append(p.Payload,nextByte) + default: + return + } } } diff --git a/revid/RevidInstance.go b/revid/RevidInstance.go index 68c6c2f9..22f0eddb 100644 --- a/revid/RevidInstance.go +++ b/revid/RevidInstance.go @@ -143,6 +143,7 @@ func NewRevidInstance(config Config) (r *revidInst, err error) { } r.generator = tsgenerator.NewTsGenerator(framesPerSec) r.h264Parser = h264.H264Parser{OutputChan: r.generator.GetNalInputChan()} + r.h264Parser.InputByteChan = make(chan byte, 10000) // TODO: Need to create constructor for parser otherwise I'm going to break // something eventuallyl go r.h264Parser.Parse() @@ -162,7 +163,7 @@ func (r *revidInst) Start() { switch r.config.Input { case Raspivid: cmd = exec.Command("raspivid", "-o", "-", "-n", "-t", "0", "-b", - r.config.Bitrate, "-w", r.config.Width, "-h", r.config.Height, "-fps", r.config.FrameRate) + r.config.Bitrate, "-w", r.config.Width, "-h", r.config.Height, "-fps", r.config.FrameRate, "-ih", "-g", "100") stdout, _ := cmd.StdoutPipe() err := cmd.Start() inputReader = bufio.NewReader(stdout) diff --git a/tsgenerator/TsGenerator.go b/tsgenerator/TsGenerator.go index fd88b896..25013290 100644 --- a/tsgenerator/TsGenerator.go +++ b/tsgenerator/TsGenerator.go @@ -29,7 +29,7 @@ LICENSE package tsgenerator import ( - _ "fmt" + "fmt" _"os" "bitbucket.org/ausocean/av/mpegts" "bitbucket.org/ausocean/av/pes" @@ -270,6 +270,7 @@ func (g *tsGenerator) Generate() { } } } + fmt.Println("\n\n\nGetting out of generate!\n\n\n") } func (g *tsGenerator) getCC(pid int) int {