From: Zhao Zhili <quinkblack@foxmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Zhao Zhili <quinkblack@foxmail.com> Subject: [FFmpeg-devel] [PATCH] avformat/flvdec: fix mismatch on timestamp wrap point Date: Wed, 9 Mar 2022 19:15:06 +0800 Message-ID: <tencent_79D72D449AA640019A799F99AB7E4E3F7008@qq.com> (raw) 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".
reply other threads:[~2022-03-09 11:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=tencent_79D72D449AA640019A799F99AB7E4E3F7008@qq.com \ --to=quinkblack@foxmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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