route original timestamps without converting to durations (#3839)

This improves timestamp precision.
This commit is contained in:
Alessandro Ros 2024-10-07 17:59:32 +02:00 committed by GitHub
parent 54c0737074
commit 23002d9f5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 475 additions and 400 deletions

View file

@ -14,6 +14,12 @@ import (
"github.com/bluenviron/mediamtx/internal/unit"
)
func multiplyAndDivide(v, m, d int64) int64 {
secs := v / d
dec := v % d
return (secs*m + dec*m/d)
}
func paramsFromConf(logLevel conf.LogLevel, cnf *conf.Path) params {
return params{
LogLevel: func() string {
@ -105,7 +111,7 @@ func (s *Source) Run(params defs.StaticSourceRunParams) error {
stream.WriteUnit(medi, medi.Formats[0], &unit.H264{
Base: unit.Base{
NTP: time.Now(),
PTS: dts,
PTS: multiplyAndDivide(int64(dts), 90000, int64(time.Second)),
},
AU: au,
})