mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 20:52:20 +00:00
I commit this only to revert easily to something that worked with VP8
This commit is contained in:
parent
9f8c3a907a
commit
4888a4d5fc
@ -5,7 +5,7 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/pion/webrtc/v3/pkg/media/h264reader"
|
||||
"github.com/pion/webrtc/v3/pkg/media/ivfreader"
|
||||
"io"
|
||||
"log"
|
||||
"math/rand"
|
||||
@ -34,8 +34,8 @@ func ingest(name string, q *messaging.Quality) {
|
||||
return
|
||||
}
|
||||
|
||||
f, _ := os.Open("CoffeeRun.h264")
|
||||
h264, err := h264reader.NewReader(f)
|
||||
f, _ := os.Open("output.ivf")
|
||||
h264, _, err := ivfreader.NewWith(f)
|
||||
|
||||
// Start ffmpag to convert videoInput to audio UDP
|
||||
ffmpeg, err := startFFmpeg(videoInput, firstPort)
|
||||
@ -47,7 +47,7 @@ func ingest(name string, q *messaging.Quality) {
|
||||
// Receive video
|
||||
go func() {
|
||||
for {
|
||||
nal, h264Err := h264.NextNAL()
|
||||
nal, _, h264Err := h264.ParseNextFrame()
|
||||
if h264Err == io.EOF {
|
||||
fmt.Printf("All video frames parsed and sent")
|
||||
return
|
||||
@ -58,25 +58,13 @@ func ingest(name string, q *messaging.Quality) {
|
||||
}
|
||||
|
||||
time.Sleep(time.Millisecond * 33)
|
||||
nal.Data = append([]byte{0x00, 0x00, 0x00, 0x01}, nal.Data...)
|
||||
|
||||
if videoTracks[name] == nil {
|
||||
videoTracks[name] = make([]*webrtc.Track, 0)
|
||||
}
|
||||
|
||||
var spsAndPpsCache []byte
|
||||
if nal.UnitType == h264reader.NalUnitTypeSPS || nal.UnitType == h264reader.NalUnitTypePPS {
|
||||
spsAndPpsCache = append(spsAndPpsCache, nal.Data...)
|
||||
continue
|
||||
} else if nal.UnitType == h264reader.NalUnitTypeCodedSliceIdr {
|
||||
nal.Data = append(spsAndPpsCache, nal.Data...)
|
||||
spsAndPpsCache = []byte{}
|
||||
}
|
||||
log.Println(nal.PictureOrderCount)
|
||||
|
||||
for _, videoTrack := range videoTracks[name] {
|
||||
if h264Err = videoTrack.WriteSample(media.Sample{Data: nal.Data, Samples: 90000}); h264Err != nil {
|
||||
panic(h264Err)
|
||||
if ivfErr := videoTrack.WriteSample(media.Sample{Data: nal, Samples: 90000}); ivfErr != nil {
|
||||
panic(ivfErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user