File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -106,16 +106,18 @@ var (
106106 err error
107107)
108108
109- const h264FrameDuration = time .Millisecond * 20
110-
111109func writeH264ToTrack (track * webrtc.TrackLocalStaticSample ) {
112110 astiav .RegisterAllDevices ()
113111
114112 initTestSrc ()
115113 defer freeVideoCoding ()
116114
115+ h264FrameDuration := time .Duration (float64 (time .Second ) * videoStream .TimeBase ().Float64 ())
116+
117117 ticker := time .NewTicker (h264FrameDuration )
118118 for ; true ; <- ticker .C {
119+ decodePacket .Unref ()
120+
119121 // Read frame from lavfi
120122 if err = inputFormatContext .ReadFrame (decodePacket ); err != nil {
121123 if errors .Is (err , astiav .ErrEof ) {
@@ -236,7 +238,12 @@ func initVideoEncoding() {
236238 encodeCodecContext .SetWidth (decodeCodecContext .Width ())
237239 encodeCodecContext .SetHeight (decodeCodecContext .Height ())
238240
239- if err = encodeCodecContext .Open (h264Encoder , nil ); err != nil {
241+ encodeCodecContextDictionary := astiav .NewDictionary ()
242+ if err = encodeCodecContextDictionary .Set ("bf" , "0" , astiav .NewDictionaryFlags ()); err != nil {
243+ panic (err )
244+ }
245+
246+ if err = encodeCodecContext .Open (h264Encoder , encodeCodecContextDictionary ); err != nil {
240247 panic (err )
241248 }
242249
You can’t perform that action at this time.
0 commit comments