summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2022-07-29 12:43:08 +0800
committerZhao Zhili <zhilizhao@tencent.com>2022-08-03 17:52:45 +0800
commit693c5be320c23e892c49907eba394215bddbe94a (patch)
tree1d1437c4eb7db052393353ddd14a2fade46c8ec0 /libavformat
parent30aa0c3f4873a92c5e3da8ba8cf030de56bf4cf7 (diff)
avformat/flvenc: fix timestamp of key frame index
Firstly, the timestamps generated from framerate are inaccurate for variable framerate mode. Secondly, the timestamps always start from zero, while pts/dts can start from nonzero. FLV demuxer rejects such index with message: "Found invalid index entries, clearing the index".
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/flvenc.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 770ca319ed..1c4ffb985a 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -104,7 +104,6 @@ typedef struct FLVContext {
int64_t lastkeyframelocation_offset;
int64_t lastkeyframelocation;
- int acurframeindex;
int64_t keyframes_info_offset;
int64_t filepositions_count;
@@ -391,7 +390,6 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
}
if (flv->flags & FLV_ADD_KEYFRAME_INDEX) {
- flv->acurframeindex = 0;
flv->keyframe_index_size = 0;
put_amf_string(pb, "hasVideo");
@@ -993,8 +991,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
flv->videosize += (avio_tell(pb) - cur_offset);
- flv->lasttimestamp = flv->acurframeindex / flv->framerate;
- flv->acurframeindex++;
+ flv->lasttimestamp = pkt->dts / 1000.0;
if (pkt->flags & AV_PKT_FLAG_KEY) {
double ts = flv->lasttimestamp;
int64_t pos = cur_offset;