BIG rewrite stream info

This commit is contained in:
Alex X
2024-06-15 16:46:03 +03:00
parent ecfe802065
commit 96504e2fb0
88 changed files with 1043 additions and 854 deletions
+29
View File
@@ -1,6 +1,7 @@
package y4m
import (
"bytes"
"image"
"github.com/AlexxIT/go2rtc/pkg/core"
@@ -10,6 +11,34 @@ const FourCC = "YUV4"
const frameHdr = "FRAME\n"
func ParseHeader(b []byte) (fmtp string) {
for b != nil {
// YUV4MPEG2 W1280 H720 F24:1 Ip A1:1 C420mpeg2 XYSCSS=420MPEG2
// https://manned.org/yuv4mpeg.5
// https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/yuv4mpegenc.c
key := b[0]
var value string
if i := bytes.IndexByte(b, ' '); i > 0 {
value = string(b[1:i])
b = b[i+1:]
} else {
value = string(b[1:])
b = nil
}
switch key {
case 'W':
fmtp = "width=" + value
case 'H':
fmtp += ";height=" + value
case 'C':
fmtp += ";colorspace=" + value
}
}
return
}
func GetSize(fmtp string) int {
w := core.Atoi(core.Between(fmtp, "width=", ";"))
h := core.Atoi(core.Between(fmtp, "height=", ";"))