File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -106,16 +106,18 @@ var (
106
106
err error
107
107
)
108
108
109
- const h264FrameDuration = time .Millisecond * 20
110
-
111
109
func writeH264ToTrack (track * webrtc.TrackLocalStaticSample ) {
112
110
astiav .RegisterAllDevices ()
113
111
114
112
initTestSrc ()
115
113
defer freeVideoCoding ()
116
114
115
+ h264FrameDuration := time .Duration (float64 (time .Second ) / videoStream .AvgFrameRate ().Float64 ())
116
+
117
117
ticker := time .NewTicker (h264FrameDuration )
118
118
for ; true ; <- ticker .C {
119
+ decodePacket .Unref ()
120
+
119
121
// Read frame from lavfi
120
122
if err = inputFormatContext .ReadFrame (decodePacket ); err != nil {
121
123
if errors .Is (err , astiav .ErrEof ) {
@@ -236,7 +238,12 @@ func initVideoEncoding() {
236
238
encodeCodecContext .SetWidth (decodeCodecContext .Width ())
237
239
encodeCodecContext .SetHeight (decodeCodecContext .Height ())
238
240
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 {
240
247
panic (err )
241
248
}
242
249
You can’t perform that action at this time.
0 commit comments