[FFmpeg-devel] [PATCH] flvenc: Fix sequence header update timestamps
Alex Converse
alex.converse at gmail.com
Thu May 3 19:50:21 EEST 2018
From: Alex Converse <alexconv at twitch.tv>
---
libavformat/flvenc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index e8af48cb64..827d798a61 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -480,7 +480,7 @@ static int unsupported_codec(AVFormatContext *s,
return AVERROR(ENOSYS);
}
-static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par) {
+static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, unsigned int ts) {
int64_t data_size;
AVIOContext *pb = s->pb;
FLVContext *flv = s->priv_data;
@@ -492,8 +492,8 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par) {
par->codec_type == AVMEDIA_TYPE_VIDEO ?
FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
avio_wb24(pb, 0); // size patched later
- avio_wb24(pb, 0); // ts
- avio_w8(pb, 0); // ts ext
+ avio_wb24(pb, ts & 0xFFFFFF);
+ avio_w8(pb, (ts >> 24) & 0x7F);
avio_wb24(pb, 0); // streamid
pos = avio_tell(pb);
if (par->codec_id == AV_CODEC_ID_AAC) {
@@ -756,7 +756,7 @@ static int flv_write_header(AVFormatContext *s)
}
for (i = 0; i < s->nb_streams; i++) {
- flv_write_codec_header(s, s->streams[i]->codecpar);
+ flv_write_codec_header(s, s->streams[i]->codecpar, 0);
}
flv->datastart_offset = avio_tell(pb);
@@ -900,7 +900,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
}
memcpy(par->extradata, side, side_size);
par->extradata_size = side_size;
- flv_write_codec_header(s, par);
+ flv_write_codec_header(s, par, pkt->dts);
}
}
--
2.17.0
More information about the ffmpeg-devel
mailing list