Change the wrap point to 2^31 to match flvenc muxer. For other flv muxers which treat timestamp as uint32_t, it should be handled by wrap_timestamp(). For muxers which treat timestamp as int32_t and create negative timestamp, they are broken before the patch. --- libavformat/flvdec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index b9e36b3ff1..ff5e6eabb4 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -184,7 +184,7 @@ static AVStream *create_stream(AVFormatContext *s, int codec_type) } - avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ + avpriv_set_pts_info(st, 31, 1, 1000); /* 31 bit pts in ms */ flv->last_keyframe_stream_index = s->nb_streams - 1; add_keyframes_index(s); return st; @@ -1033,7 +1033,11 @@ retry: size = avio_rb24(s->pb); flv->sum_flv_tag_size += size + 11; dts = avio_rb24(s->pb); - dts |= (unsigned)avio_r8(s->pb) << 24; + /* FLV timestamps are 32 bits signed, flvenc.c doesn't use the 32 msb, but + * other muxer may treat timestamp as uint32_t. We ignore the 32 bit and + * handle the wrap by avpriv_set_pts_info(). + */ + dts |= ((unsigned)avio_r8(s->pb) & 0x7F) << 24; av_log(s, AV_LOG_TRACE, "type:%d, size:%d, last:%d, dts:%"PRId64" pos:%"PRId64"\n", type, size, last, dts, avio_tell(s->pb)); if (avio_feof(s->pb)) return AVERROR_EOF; -- 2.31.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".