* [FFmpeg-devel] [PATCH] avformat/mpegts: correct timestamp overflow on multiple pcr loopback @ 2022-06-23 15:45 Sébastien Rossi 2022-06-23 23:31 ` Michael Niedermayer 0 siblings, 1 reply; 5+ messages in thread From: Sébastien Rossi @ 2022-06-23 15:45 UTC (permalink / raw) To: ffmpeg-devel [-- Attachment #1: Type: text/plain, Size: 140 bytes --] - Detect and count PCR loopback - Correct DTS and PTS with PCR loopback count to avoid timestamp overflow and preserve timestamp continuity [-- Attachment #2: 0001-avformat-mpegts-correct-timestamp-overflow-on-multip.patch --] [-- Type: application/octet-stream, Size: 245939 bytes --] [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mpegts: correct timestamp overflow on multiple pcr loopback 2022-06-23 15:45 [FFmpeg-devel] [PATCH] avformat/mpegts: correct timestamp overflow on multiple pcr loopback Sébastien Rossi @ 2022-06-23 23:31 ` Michael Niedermayer 2022-06-24 12:30 ` Sébastien Rossi 0 siblings, 1 reply; 5+ messages in thread From: Michael Niedermayer @ 2022-06-23 23:31 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1.1: Type: text/plain, Size: 1950 bytes --] On Thu, Jun 23, 2022 at 05:45:52PM +0200, Sébastien Rossi wrote: > - Detect and count PCR loopback > - Correct DTS and PTS with PCR loopback count to avoid timestamp overflow > and preserve timestamp continuity > libavformat/mpegts.c | 45 + > tests/ref/fate/ts-opus-demux | 1028 +++++++++++++++++++++---------------------- > 2 files changed, 556 insertions(+), 517 deletions(-) > 43462e655164b7eda6d3a5e8a85bc42556891742 0001-avformat-mpegts-correct-timestamp-overflow-on-multip.patch > From 19305e9c1beffb34b73c71f721a6dea2b9fc483f Mon Sep 17 00:00:00 2001 > From: sebastien_rossi <sebastien.rossi@bbright.com> > Date: Thu, 23 Jun 2022 17:20:06 +0200 > Subject: [PATCH] avformat/mpegts: correct timestamp overflow on multiple pcr > loopback not entirely sure what you are trying to do, did you look at the timestamp handling in the generic code? also this sort of timestamp modification can have issues with seeking also this segfaults ==13685== Invalid read of size 8 ==13685== at 0x690357: new_pes_packet (in ffmpeg/ffmpeg_g) ==13685== by 0x6937AB: mpegts_push_data (in ffmpeg/ffmpeg_g) ==13685== by 0x690CE7: handle_packet (in ffmpeg/ffmpeg_g) ==13685== by 0x6911A4: handle_packets (in ffmpeg/ffmpeg_g) ==13685== by 0x6912E1: mpegts_read_packet (in ffmpeg/ffmpeg_g) ==13685== by 0x5F42D4: ff_read_packet (in ffmpeg/ffmpeg_g) ==13685== by 0x5F50C4: read_frame_internal (in ffmpeg/ffmpeg_g) ==13685== by 0x5F6EA0: avformat_find_stream_info (in ffmpeg/ffmpeg_g) ==13685== by 0x2F1644: open_input_file (in ffmpeg/ffmpeg_g) ==13685== by 0x2F7C5B: ffmpeg_parse_options (in ffmpeg/ffmpeg_g) ==13685== by 0x2E60F4: main (in ffmpeg/ffmpeg_g) ==13685== Address 0x10 is not stack'd, malloc'd or (recently) free'd [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mpegts: correct timestamp overflow on multiple pcr loopback 2022-06-23 23:31 ` Michael Niedermayer @ 2022-06-24 12:30 ` Sébastien Rossi 2022-06-24 20:34 ` Michael Niedermayer 0 siblings, 1 reply; 5+ messages in thread From: Sébastien Rossi @ 2022-06-24 12:30 UTC (permalink / raw) To: FFmpeg development discussions and patches The issue I tried to patch is that on ts stream that last more than 26,5h (time between pcr loopback) we had pts and dts discontinuities. In wrap_timestamp function in demux.c, I've seen there's some code to correct timestamp overflow, but when the stream last more than 26,5h, timestamps are upper than pts_wrap_reference two times. So the second time we outrun the pts_wrap_reference we lose the timestamp correction and have some errors like pts < dts. What I tried to do is to restamp pts and dts using mpegts pcr information. The preserve_continuity function checks relative position between timestamp (dts or pts) and pcr, and handle cases when pcr have already loopback and timestamp not or vice versa. Then it applicates correction to the timestamp depending on pcr loopback count. I can provide a stream with a duration of 30h, if you want to. Could you tell me how to reproduce the segfault you've seen ? Sébastien Rossi Le ven. 24 juin 2022 à 01:31, Michael Niedermayer <michael@niedermayer.cc> a écrit : > On Thu, Jun 23, 2022 at 05:45:52PM +0200, Sébastien Rossi wrote: > > - Detect and count PCR loopback > > - Correct DTS and PTS with PCR loopback count to avoid timestamp overflow > > and preserve timestamp continuity > > > libavformat/mpegts.c | 45 + > > tests/ref/fate/ts-opus-demux | 1028 > +++++++++++++++++++++---------------------- > > 2 files changed, 556 insertions(+), 517 deletions(-) > > 43462e655164b7eda6d3a5e8a85bc42556891742 > 0001-avformat-mpegts-correct-timestamp-overflow-on-multip.patch > > From 19305e9c1beffb34b73c71f721a6dea2b9fc483f Mon Sep 17 00:00:00 2001 > > From: sebastien_rossi <sebastien.rossi@bbright.com> > > Date: Thu, 23 Jun 2022 17:20:06 +0200 > > Subject: [PATCH] avformat/mpegts: correct timestamp overflow on multiple > pcr > > loopback > > not entirely sure what you are trying to do, did you look at the timestamp > handling in the generic code? > also this sort of timestamp modification can have issues with seeking > > also this segfaults > > ==13685== Invalid read of size 8 > ==13685== at 0x690357: new_pes_packet (in ffmpeg/ffmpeg_g) > ==13685== by 0x6937AB: mpegts_push_data (in ffmpeg/ffmpeg_g) > ==13685== by 0x690CE7: handle_packet (in ffmpeg/ffmpeg_g) > ==13685== by 0x6911A4: handle_packets (in ffmpeg/ffmpeg_g) > ==13685== by 0x6912E1: mpegts_read_packet (in ffmpeg/ffmpeg_g) > ==13685== by 0x5F42D4: ff_read_packet (in ffmpeg/ffmpeg_g) > ==13685== by 0x5F50C4: read_frame_internal (in ffmpeg/ffmpeg_g) > ==13685== by 0x5F6EA0: avformat_find_stream_info (in ffmpeg/ffmpeg_g) > ==13685== by 0x2F1644: open_input_file (in ffmpeg/ffmpeg_g) > ==13685== by 0x2F7C5B: ffmpeg_parse_options (in ffmpeg/ffmpeg_g) > ==13685== by 0x2E60F4: main (in ffmpeg/ffmpeg_g) > ==13685== Address 0x10 is not stack'd, malloc'd or (recently) free'd > > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Avoid a single point of failure, be that a person or equipment. > _______________________________________________ > 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". > _______________________________________________ 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] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mpegts: correct timestamp overflow on multiple pcr loopback 2022-06-24 12:30 ` Sébastien Rossi @ 2022-06-24 20:34 ` Michael Niedermayer 2022-06-27 12:25 ` Sébastien Rossi 0 siblings, 1 reply; 5+ messages in thread From: Michael Niedermayer @ 2022-06-24 20:34 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1.1: Type: text/plain, Size: 2014 bytes --] Hi On Fri, Jun 24, 2022 at 02:30:19PM +0200, Sébastien Rossi wrote: > The issue I tried to patch is that on ts stream that last more than 26,5h > (time between pcr loopback) we had pts and dts discontinuities. In > wrap_timestamp function in demux.c, I've seen there's some code to correct > timestamp overflow, but when the stream last more than 26,5h, timestamps > are upper than pts_wrap_reference two times. So the second time we outrun > the pts_wrap_reference we lose the timestamp correction and have some > errors like pts < dts. > What I tried to do is to restamp pts and dts using mpegts pcr information. > The preserve_continuity function checks relative position between timestamp > (dts or pts) and pcr, and handle cases when pcr have already loopback and > timestamp not or vice versa. Then it applicates correction to the timestamp > depending on pcr loopback count. there can be more timestamp discontinuities than one per 26.5h if the goal is to remove all that requires more code. Either some scaning of the whole file or some quite smart stuff and either way a buffer to store where the discontinuities are so they are consistantly handled during seeking. if the goal is to eliminate 1 wraparound only, there should be some existing code i think that does this. IIRC see pts_wrap_behavior the wraping behavior is applies to multiple demuxers so code handling it really does not belong in a single demuxer > > I can provide a stream with a duration of 30h, if you want to. not needed > > Could you tell me how to reproduce the segfault you've seen ? it segfaults because filter is NULL. i can send you the file but as the code and why its segfaults is specific to one demxuer and this shouldnt be in one single demuxer i dont think it would help you thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mpegts: correct timestamp overflow on multiple pcr loopback 2022-06-24 20:34 ` Michael Niedermayer @ 2022-06-27 12:25 ` Sébastien Rossi 0 siblings, 0 replies; 5+ messages in thread From: Sébastien Rossi @ 2022-06-27 12:25 UTC (permalink / raw) To: FFmpeg development discussions and patches Hi, Ok, my goal was to eliminate all wraparound for live transport stream mainly. But as it seems hard to handle this particular case (long live stream) and cover all the other use cases (scaning, smart stuff etc), I will keep this patch on my side as an option for my personal usage. Thanks for your help, have a good day. Sébastien Le ven. 24 juin 2022 à 22:35, Michael Niedermayer <michael@niedermayer.cc> a écrit : > Hi > > On Fri, Jun 24, 2022 at 02:30:19PM +0200, Sébastien Rossi wrote: > > The issue I tried to patch is that on ts stream that last more than 26,5h > > (time between pcr loopback) we had pts and dts discontinuities. In > > wrap_timestamp function in demux.c, I've seen there's some code to > correct > > timestamp overflow, but when the stream last more than 26,5h, timestamps > > are upper than pts_wrap_reference two times. So the second time we outrun > > the pts_wrap_reference we lose the timestamp correction and have some > > errors like pts < dts. > > What I tried to do is to restamp pts and dts using mpegts pcr > information. > > The preserve_continuity function checks relative position between > timestamp > > (dts or pts) and pcr, and handle cases when pcr have already loopback and > > timestamp not or vice versa. Then it applicates correction to the > timestamp > > depending on pcr loopback count. > > there can be more timestamp discontinuities than one per 26.5h > if the goal is to remove all that requires more code. Either > some scaning of the whole file or some quite smart stuff and either > way a buffer to store where the discontinuities are so they are > consistantly > handled during seeking. > > if the goal is to eliminate 1 wraparound only, there should be some > existing code i think that does this. IIRC see pts_wrap_behavior > > the wraping behavior is applies to multiple demuxers so code > handling it really does not belong in a single demuxer > > > > > > I can provide a stream with a duration of 30h, if you want to. > > not needed > > > > > > Could you tell me how to reproduce the segfault you've seen ? > > it segfaults because filter is NULL. > i can send you the file but as the code and why its segfaults is > specific to one demxuer and this shouldnt be in one single demuxer > i dont think it would help you > > thx > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > I am the wisest man alive, for I know one thing, and that is that I know > nothing. -- Socrates > _______________________________________________ > 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". > _______________________________________________ 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] 5+ messages in thread
end of thread, other threads:[~2022-06-27 12:26 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-06-23 15:45 [FFmpeg-devel] [PATCH] avformat/mpegts: correct timestamp overflow on multiple pcr loopback Sébastien Rossi 2022-06-23 23:31 ` Michael Niedermayer 2022-06-24 12:30 ` Sébastien Rossi 2022-06-24 20:34 ` Michael Niedermayer 2022-06-27 12:25 ` Sébastien Rossi
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