Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/flvdec: fix mismatch on timestamp wrap point
@ 2022-03-09 11:15 Zhao Zhili
  0 siblings, 0 replies; only message in thread
From: Zhao Zhili @ 2022-03-09 11:15 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Zhao Zhili

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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-09 11:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09 11:15 [FFmpeg-devel] [PATCH] avformat/flvdec: fix mismatch on timestamp wrap point Zhao Zhili

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git