Don't add metadata at random access indicators
A metadata tag injected into the generated FLV when a random access indicator was encountered in the adaptation field of a TS packet causes Firefox 38 on OSX to apply frame diffs against the wrong keyframe. This leads to ugly artifacts for a few seconds after seeking. Now metadata tags are only generated at the start of a segment and IDRs. Fixes #289.
Showing
2 changed files
with
2 additions
and
29 deletions
... | @@ -48,11 +48,9 @@ | ... | @@ -48,11 +48,9 @@ |
48 | 48 | ||
49 | this._state = 0; // :uint; | 49 | this._state = 0; // :uint; |
50 | 50 | ||
51 | this._nextFrameKeyFrame = false; | ||
52 | |||
53 | this.tags = []; | 51 | this.tags = []; |
54 | |||
55 | }; | 52 | }; |
53 | |||
56 | //(pts:uint):void | 54 | //(pts:uint):void |
57 | H264Stream.prototype.setTimeStampOffset = function(pts) { | 55 | H264Stream.prototype.setTimeStampOffset = function(pts) { |
58 | this._pts_offset = pts; | 56 | this._pts_offset = pts; |
... | @@ -97,11 +95,6 @@ | ... | @@ -97,11 +95,6 @@ |
97 | this._state = 0; | 95 | this._state = 0; |
98 | }; | 96 | }; |
99 | 97 | ||
100 | |||
101 | H264Stream.prototype.setNextFrameKeyFrame = function() { | ||
102 | this._nextFrameKeyFrame = true; | ||
103 | }; | ||
104 | |||
105 | // (data:ByteArray, o:int, l:int):void | 98 | // (data:ByteArray, o:int, l:int):void |
106 | H264Stream.prototype.writeBytes = function(data, offset, length) { | 99 | H264Stream.prototype.writeBytes = function(data, offset, length) { |
107 | var | 100 | var |
... | @@ -263,11 +256,6 @@ | ... | @@ -263,11 +256,6 @@ |
263 | this._h264Frame = new FlvTag(FlvTag.VIDEO_TAG); | 256 | this._h264Frame = new FlvTag(FlvTag.VIDEO_TAG); |
264 | this._h264Frame.pts = this._next_pts; | 257 | this._h264Frame.pts = this._next_pts; |
265 | this._h264Frame.dts = this._next_dts; | 258 | this._h264Frame.dts = this._next_dts; |
266 | |||
267 | if (this._nextFrameKeyFrame) { | ||
268 | this._h264Frame.keyFrame = true; | ||
269 | this._nextFrameKeyFrame = false; | ||
270 | } | ||
271 | } | 259 | } |
272 | 260 | ||
273 | this._h264Frame.startNalUnit(); | 261 | this._h264Frame.startNalUnit(); | ... | ... |
... | @@ -214,9 +214,6 @@ | ... | @@ -214,9 +214,6 @@ |
214 | // adaptation_field_control, whether this header is followed by an | 214 | // adaptation_field_control, whether this header is followed by an |
215 | // adaptation field, a payload, or both | 215 | // adaptation field, a payload, or both |
216 | afflag = (data[offset + 3] & 0x30 ) >>> 4, | 216 | afflag = (data[offset + 3] & 0x30 ) >>> 4, |
217 | adaptationFieldLength, | ||
218 | afftemp, | ||
219 | randomAccessIndicator, | ||
220 | 217 | ||
221 | patTableId, // :int | 218 | patTableId, // :int |
222 | patCurrentNextIndicator, // Boolean | 219 | patCurrentNextIndicator, // Boolean |
... | @@ -253,19 +250,7 @@ | ... | @@ -253,19 +250,7 @@ |
253 | // used to specify some forms of timing and control data that we | 250 | // used to specify some forms of timing and control data that we |
254 | // do not currently use. | 251 | // do not currently use. |
255 | if (afflag > 0x01) { | 252 | if (afflag > 0x01) { |
256 | adaptationFieldLength = data[offset]; | 253 | offset += data[offset] + 1; |
257 | |||
258 | if (adaptationFieldLength > 0) { | ||
259 | afftemp = data[offset + 1]; | ||
260 | |||
261 | randomAccessIndicator = (afftemp & 0x40) >>> 6; | ||
262 | |||
263 | if (randomAccessIndicator === 1) { | ||
264 | h264Stream.setNextFrameKeyFrame(); | ||
265 | } | ||
266 | } | ||
267 | |||
268 | offset += adaptationFieldLength + 1; | ||
269 | } | 254 | } |
270 | 255 | ||
271 | // Handle a Program Association Table (PAT). PATs map PIDs to | 256 | // Handle a Program Association Table (PAT). PATs map PIDs to | ... | ... |
-
Please register or sign in to post a comment