tmpfs needed
This commit is contained in:
parent
935d5ade76
commit
3af8cf2090
2
TODO
2
TODO
@ -15,4 +15,4 @@
|
|||||||
1. 视频设备延迟过高
|
1. 视频设备延迟过高
|
||||||
|
|
||||||
# 2022-10-11
|
# 2022-10-11
|
||||||
1. 解决视频设备延迟
|
1. 解决视频设备延迟->丢帧机制?或者使用tmpfs
|
@ -5,7 +5,6 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/nfnt/resize"
|
"github.com/nfnt/resize"
|
||||||
"github.com/pion/mediadevices/pkg/frame"
|
"github.com/pion/mediadevices/pkg/frame"
|
||||||
@ -59,9 +58,6 @@ func (v *PPMStreamDriver) VideoRecord(p prop.Media) (video.Reader, error) {
|
|||||||
image.YCbCrSubsampleRatio420,
|
image.YCbCrSubsampleRatio420,
|
||||||
)
|
)
|
||||||
r := video.ReaderFunc(func() (img image.Image, release func(), err error) {
|
r := video.ReaderFunc(func() (img image.Image, release func(), err error) {
|
||||||
ticker := time.NewTicker(time.Second / time.Duration(p.FrameRate))
|
|
||||||
defer ticker.Stop()
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-v.closed:
|
case <-v.closed:
|
||||||
return nil, func() {}, io.EOF
|
return nil, func() {}, io.EOF
|
||||||
@ -74,7 +70,7 @@ func (v *PPMStreamDriver) VideoRecord(p prop.Media) (video.Reader, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// resize image and draw it to canvas
|
// resize image and draw it to canvas
|
||||||
resized := resize.Resize(uint(p.Width), uint(p.Height), img, resize.Lanczos3)
|
resized := resize.Resize(uint(p.Width), uint(p.Height), img, resize.Bilinear)
|
||||||
for y := 0; y < resized.Bounds().Dy(); y++ {
|
for y := 0; y < resized.Bounds().Dy(); y++ {
|
||||||
for x := 0; x < resized.Bounds().Dx(); x++ {
|
for x := 0; x < resized.Bounds().Dx(); x++ {
|
||||||
r, g, b, _ := resized.At(x, y).RGBA()
|
r, g, b, _ := resized.At(x, y).RGBA()
|
||||||
@ -85,7 +81,7 @@ func (v *PPMStreamDriver) VideoRecord(p prop.Media) (video.Reader, error) {
|
|||||||
canvas.Cr[canvas.COffset(x, y)] = Cr
|
canvas.Cr[canvas.COffset(x, y)] = Cr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case <-ticker.C:
|
default:
|
||||||
}
|
}
|
||||||
return canvas, func() {}, nil
|
return canvas, func() {}, nil
|
||||||
})
|
})
|
||||||
|
@ -39,7 +39,7 @@ func NewServer(o *Options) (*Server, error) {
|
|||||||
options: o,
|
options: o,
|
||||||
audioHeader: make(chan *audio.WavHeader, 1),
|
audioHeader: make(chan *audio.WavHeader, 1),
|
||||||
pcm: make(chan []byte),
|
pcm: make(chan []byte),
|
||||||
ppm: make(chan io.ReadCloser), // to be configured
|
ppm: make(chan io.ReadCloser, 1), // to be configured
|
||||||
}
|
}
|
||||||
|
|
||||||
u, err := url.Parse(o.QmpAddress)
|
u, err := url.Parse(o.QmpAddress)
|
||||||
|
Loading…
Reference in New Issue
Block a user