History

avformat/flvenc: fix EOS tag

FLV spec only has AVC end of sequence tag, and the EOS tag has a CodecID as other video data packet. MPEG4 doesn't conformance to the spec, but it's there for a decade. So only 'fix' the EOS tag rather than remove it completely.

Zhao Zhili committed 3 years ago

Commit 59a97271 parent 9f7e51e1 file · +6 −3Browse files

Unified · Split

libavformat/flvenc.c+6−3
@@ -235,13 +235,16 @@ static void put_timestamp(AVIOContext *pb, int64_t ts) { · 234 unmodified lines
235 avio_w8(pb, (ts >> 24) & 0x7F);235 avio_w8(pb, (ts >> 24) & 0x7F);
236}236}
237 237
238static void put_avc_eos_tag(AVIOContext *pb, unsigned ts)238static void put_eos_tag(AVIOContext *pb, unsigned ts, enum AVCodecID codec_id)
239{239{
240 uint32_t tag = ff_codec_get_tag(flv_video_codec_ids, codec_id);
241 /* ub[4] FrameType = 1, ub[4] CodecId */
242 tag |= 1 << 4;
240 avio_w8(pb, FLV_TAG_TYPE_VIDEO);243 avio_w8(pb, FLV_TAG_TYPE_VIDEO);
241 avio_wb24(pb, 5); /* Tag Data Size */244 avio_wb24(pb, 5); /* Tag Data Size */
242 put_timestamp(pb, ts);245 put_timestamp(pb, ts);
243 avio_wb24(pb, 0); /* StreamId = 0 */246 avio_wb24(pb, 0); /* StreamId = 0 */
244 avio_w8(pb, 23); /* ub[4] FrameType = 1, ub[4] CodecId = 7 */247 avio_w8(pb, tag);
245 avio_w8(pb, 2); /* AVC end of sequence */248 avio_w8(pb, 2); /* AVC end of sequence */
246 avio_wb24(pb, 0); /* Always 0 for AVC EOS. */249 avio_wb24(pb, 0); /* Always 0 for AVC EOS. */
247 avio_wb32(pb, 16); /* Size of FLV tag */250 avio_wb32(pb, 16); /* Size of FLV tag */
@@ -783,7 +786,7 @@ end: · 535 unmodified lines
783 FLVStreamContext *sc = s->streams[i]->priv_data;786 FLVStreamContext *sc = s->streams[i]->priv_data;
784 if (par->codec_type == AVMEDIA_TYPE_VIDEO &&787 if (par->codec_type == AVMEDIA_TYPE_VIDEO &&
785 (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4))788 (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4))
786 put_avc_eos_tag(pb, sc->last_ts);789 put_eos_tag(pb, sc->last_ts, par->codec_id);
787 }790 }
788 }791 }
789 792

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t