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"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pion/webrtc/v3/pkg/media"
|
"github.com/pion/webrtc/v3/pkg/media"
|
||||||
"github.com/pion/webrtc/v3/pkg/media/h264reader"
|
"github.com/pion/webrtc/v3/pkg/media/ivfreader"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
@ -34,8 +34,8 @@ func ingest(name string, q *messaging.Quality) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
f, _ := os.Open("CoffeeRun.h264")
|
f, _ := os.Open("output.ivf")
|
||||||
h264, err := h264reader.NewReader(f)
|
h264, _, err := ivfreader.NewWith(f)
|
||||||
|
|
||||||
// Start ffmpag to convert videoInput to audio UDP
|
// Start ffmpag to convert videoInput to audio UDP
|
||||||
ffmpeg, err := startFFmpeg(videoInput, firstPort)
|
ffmpeg, err := startFFmpeg(videoInput, firstPort)
|
||||||
|
@ -47,7 +47,7 @@ func ingest(name string, q *messaging.Quality) {
|
||||||
// Receive video
|
// Receive video
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
nal, h264Err := h264.NextNAL()
|
nal, _, h264Err := h264.ParseNextFrame()
|
||||||
if h264Err == io.EOF {
|
if h264Err == io.EOF {
|
||||||
fmt.Printf("All video frames parsed and sent")
|
fmt.Printf("All video frames parsed and sent")
|
||||||
return
|
return
|
||||||
|
@ -58,25 +58,13 @@ func ingest(name string, q *messaging.Quality) {
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(time.Millisecond * 33)
|
time.Sleep(time.Millisecond * 33)
|
||||||
nal.Data = append([]byte{0x00, 0x00, 0x00, 0x01}, nal.Data...)
|
|
||||||
|
|
||||||
if videoTracks[name] == nil {
|
if videoTracks[name] == nil {
|
||||||
videoTracks[name] = make([]*webrtc.Track, 0)
|
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] {
|
for _, videoTrack := range videoTracks[name] {
|
||||||
if h264Err = videoTrack.WriteSample(media.Sample{Data: nal.Data, Samples: 90000}); h264Err != nil {
|
if ivfErr := videoTrack.WriteSample(media.Sample{Data: nal, Samples: 90000}); ivfErr != nil {
|
||||||
panic(h264Err)
|
panic(ivfErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue