[Question] Difference between *TrackLocalStaticRTP and *TrackLocalStaticSample ??? #1887
Replies: 2 comments 1 reply
-
I have the same question. I am trying to build webrtc streaming service that uses directly nvenc encoder thats write into pion. I have a working solution that display a stream. However it produces big lags. @ashellunts can you help? I used your example: // reader reads from nvenc pipe
for {
nal, err := reader.NextNAL()
if err == io.EOF {
log.Println("All video frames parsed and sent")
}
if err != nil {
log.Fatal(err)
}
nal.Data = append([]byte{0x00, 0x00, 0x00, 0x01}, nal.Data...)
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{}
}
if err = videoTrack.WriteSample(media.Sample{Data: nal.Data, Timestamp: time.Now()}); err != nil {
log.Fatal(err)
}
} It renders correct picture through webrtc only if I used 1. Is it possible to use PROGRESSIVE profile with this h264reader? Even if I have correct picture I see a strong lags in streaming. The picture is often outdated or can freeze for some time. Why it can happen? I am sure that nvenc is working correctly, it encodes 60 frames per second. I immediately read them and pass to Also it's not clear what I should pass to Timestamp, Duration fields? 2. So why I experience strong lags with this code? |
Beta Was this translation helpful? Give feedback.
-
Hello comrade. I've found the answer for my second question. By the way, I also try to use nvenc but currently using ffmpeg with linux pipe for I'm not familiar with libav. Tank you |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello comrades
I am writing an application that does:
cam -> ffmpeg h264 -> pion webrtc server -> browser
thing.
I am learning with these two examples:
https://github.com/pion/webrtc/tree/master/examples/play-from-disk
https://github.com/pion/webrtc/tree/master/examples/broadcast
I have two questions.
First example(play-from-disk) uses
webrtc/track_local_static.go
Line 248 in ee255e8
Second example(broadcase) uses
webrtc/track_local_static.go
Line 151 in ee255e8
for writing video data to the peer.
What is the difference between these two functions?
I have a h264 stream which is coming from ffmpeg pipe (ffmpeg ... -f h264 pipe:1)
and media.H264Reader is parsing it as NAL packets with NextNAL() function.
webrtc/pkg/media/h264reader/h264reader.go
Lines 110 to 113 in ee255e8
Can I just provide NAL.Data (which is []byte) to (*TrackLocalStaticRTP).Write() ?
Should I provide []byte(NAL) as a whole to .Write() function?
or should I do further processing to wrap NAL into something digestible for browser?
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions