Converting DTS (timestamps) in mpegts to HH:MM:SS:FF

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting DTS (timestamps) in mpegts to HH:MM:SS:FF

Kieran O Leary
Hi,

I'm working with HDV tape transfers in the moment and dealing with m2t
transport streams. I've found that using ffmpeg -report -loglevel debug -i
input -f null - has been great at catching corrupt frames that I can
investigate in playback software.
I just realised that this can be done even quicker and it looks like the
same corruption is detected when using -c copy. However, the report I get
in the terminal just uses dts values - is there a way to convert these dts
values to a frame number or preferably a HH:MM:SS:FF value? is it related
to the tbn/tbc value? Either in ffmpeg or even some scriptable way.

For example, one of the errors displays like this:
[mpegts @ 00000165bdcd34c0] Packet corrupt (stream = 1, dts = 332636400)
and I can tell from using -f null - that this corresponds to
approx 01:01:33.55 , but I can't find a way to get the dts value to relate
to that timestamp.


ffmpeg -i 2.m2t -c copy -f null -
ffmpeg version N-96643-g2942b00285-g2383021a7a+1 Copyright (c) 2000-2020
the FFmpeg developers
  built with gcc 9.2.0 (Rev2, Built by MSYS2 project)
  configuration:  --disable-autodetect --enable-amf --enable-bzlib
--enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-iconv
--enable-lzma --enable-nvenc --enable-zlib --enable-sdl2 --enable-ffnvcodec
--enable-nvdec --enable-cuda-llvm --enable-libmp3lame --enable-libopus
--enable-libvorbis --enable-libx264 --enable-libdav1d --disable-debug
--enable-fontconfig --enable-libass --enable-libbluray --enable-libfreetype
--enable-libmfx --enable-libmysofa --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack
--enable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine
--enable-gpl --enable-avisynth --enable-libxvid --enable-libaom
--enable-libopenmpt --enable-version3 --enable-openssl
--extra-cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++
--extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv --enable-nonfree
  libavutil      56. 39.100 / 56. 39.100
  libavcodec     58. 67.101 / 58. 67.101
  libavformat    58. 37.100 / 58. 37.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 74.100 /  7. 74.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[mpegts @ 00000180e65c24c0] PES packet size mismatch
[mpegts @ 00000180e65c24c0] Packet corrupt (stream = 1, dts = 437428800).
[mpegts @ 00000180e65c24c0] Could not find codec parameters for stream 2
(Unknown: none ([160][0][0][0] / 0x00A0)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize'
options
[mpegts @ 00000180e65c24c0] Could not find codec parameters for stream 3
(Unknown: none ([161][0][0][0] / 0x00A1)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize'
options
Input #0, mpegts, from '82.m2t':
  Duration: 01:20:57.08, start: 3.440000, bitrate: 26122 kb/s
  Program 100
    Stream #0:0[0x810]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
yuv420p(tv, bt709, top first), 1440x1080 [SAR 4:3 DAR 16:9], 25000 kb/s, 25
fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x814]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz,
stereo, fltp, 384 kb/s
    Stream #0:2[0x815]: Unknown: none ([160][0][0][0] / 0x00A0)
    Stream #0:3[0x811]: Unknown: none ([161][0][0][0] / 0x00A1)
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf58.37.100
    Stream #0:0: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
yuv420p(tv, bt709, top first), 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 25000
kb/s, 25 fps, 25 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo,
fltp, 384 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpegts @ 00000180e65c24c0] Packet corrupt (stream = 0, dts = 5317200).
[mpegts @ 00000180e65c24c0] Packet corrupt (stream = 0, dts = 10821600).
[mpegts @ 00000180e65c24c0] Packet corrupt (stream = 0, dts =
116416800).322x
[mpegts @ 00000180e65c24c0] PES packet size mismatch
[mpegts @ 00000180e65c24c0] Packet corrupt (stream = 1, dts = 116398800).
[mpegts @ 00000180e65c24c0] Packet corrupt (stream = 0, dts =
332654400).341x
[mpegts @ 00000180e65c24c0] PES packet size mismatch
[mpegts @ 00000180e65c24c0] Packet corrupt (stream = 1, dts = 332636400).
[mpegts @ 00000180e65c24c0] PES packet size mismatch04 bitrate=N/A speed=
345x
[mpegts @ 00000180e65c24c0] Packet corrupt (stream = 1, dts = 437428800).
frame=121338 fps=8612 q=-1.0 Lsize=N/A time=01:20:57.04 bitrate=N/A speed=
345x
video:14811578kB audio:227500kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: unknown

Best,

Kieran O'Leary
Irish Film Institute
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Converting DTS (timestamps) in mpegts to HH:MM:SS:FF

Kieran O Leary
OK, so I figured out that the dts needs to be divided by pkt_duration_time,
which in this instance was 3600. Not sure how to get that aside from using
ffprobe as I don't see it listed in the ffmpeg output.
And I also realised via this  https://github.com/bavc/qctools/issues/291
that just pulling frame level data via ffprobe is a better way to get this
data:
ffprobe  2.m2t -show_log 16 -show_frames -of xml  > bla.xml

gives me lovely stuff like this:
     <frame media_type="video" stream_index="0" key_frame="0"
pkt_pts="5317200" pkt_pts_time="59.080000" pkt_dts="5317200"
pkt_dts_time="59.080000" best_effort_timestamp="5317200"
best_effort_timestamp_time="59.080000" pkt_duration="3600"
pkt_duration_time="0.040000" pkt_pos="180487708" pkt_size="183288"
width="1440" height="1080" pix_fmt="yuv420p" sample_aspect_ratio="4:3"
pict_type="P" coded_picture_number="1378" display_picture_number="0"
interlaced_frame="1" top_field_first="1" repeat_pict="0" color_range="tv"
color_space="bt709" color_primaries="bt709" color_transfer="bt709"
chroma_location="left">
            <logs>
                <log context="mpeg2video" level="16" category="6"
message="[mpeg2video @ 000001df0605e000] ac-tex damaged at 84 42"/>
                <log context="mpeg2video" level="16" category="6"
message="[mpeg2video @ 000001df0605e000] Warning MVs not available"/>
            </logs>
            <side_data_list>
                <side_data side_data_type="AVPanScan"/>
                <side_data side_data_type="QP table data"/>
                <side_data side_data_type="QP table properties"/>
            </side_data_list>
        </frame>

Best,

Kieran
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Converting DTS (timestamps) in mpegts to HH:MM:SS:FF

Kieran O Leary
On Tue, Jun 16, 2020 at 9:40 AM Kieran O Leary <[hidden email]>
wrote:

> OK, so I figured out that the dts needs to be divided by
> pkt_duration_time, which in this instance was 3600. Not sure how to get
> that aside from using ffprobe as I don't see it listed in the ffmpeg output.
>

Sorry, the dts value needs to be divided by pkt_duration, which gives the
frame number. Also ffmpeg is amazing.

Best,

Kieran.

>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Converting DTS (timestamps) in mpegts to HH:MM:SS:FF

Gyan Doshi-2


On 16-06-2020 02:15 pm, Kieran O Leary wrote:
> On Tue, Jun 16, 2020 at 9:40 AM Kieran O Leary <[hidden email]>
> wrote:
>
>> OK, so I figured out that the dts needs to be divided by
>> pkt_duration_time, which in this instance was 3600. Not sure how to get
>> that aside from using ffprobe as I don't see it listed in the ffmpeg output.
>>
> Sorry, the dts value needs to be divided by pkt_duration, which gives the
> frame number. Also ffmpeg is amazing.

Actually, the dts is denominated in terms of the stream time_base. For
MPEG-TS, that's 90000 for all streams.
This applies to the dts shown in the corrupt packet msg. After decoding,
lavc will change audio stream time base to stream sampling rate.

Gyan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Converting DTS (timestamps) in mpegts to HH:MM:SS:FF

Moritz Barsnick
In reply to this post by Kieran O Leary
On Tue, Jun 16, 2020 at 09:45:02 +0100, Kieran O Leary wrote:
> On Tue, Jun 16, 2020 at 9:40 AM Kieran O Leary <[hidden email]>
> > OK, so I figured out that the dts needs to be divided by
> > pkt_duration_time, which in this instance was 3600. Not sure how to get
> > that aside from using ffprobe as I don't see it listed in the ffmpeg output.
>
> Sorry, the dts value needs to be divided by pkt_duration, which gives the
> frame number. Also ffmpeg is amazing.

Note that ffprobe also has those *_time fields, where the calculation
is already done for you. E.g. best_effort_timestamp_time, pkt_pts_time,
pkt_dts_time, pkt_duration_time.

(Does ffprobe report which frames are corrupt? I didn't check.)

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Converting DTS (timestamps) in mpegts to HH:MM:SS:FF

Kieran O Leary
Hi Moritz,

On Tue, Jun 16, 2020 at 9:55 AM Moritz Barsnick <[hidden email]> wrote:

> On Tue, Jun 16, 2020 at 09:45:02 +0100, Kieran O Leary wrote:
> > On Tue, Jun 16, 2020 at 9:40 AM Kieran O Leary <[hidden email]
> >
> > > OK, so I figured out that the dts needs to be divided by
> > > pkt_duration_time, which in this instance was 3600. Not sure how to get
> > > that aside from using ffprobe as I don't see it listed in the ffmpeg
> output.
> >
> > Sorry, the dts value needs to be divided by pkt_duration, which gives the
> > frame number. Also ffmpeg is amazing.
>
> Note that ffprobe also has those *_time fields, where the calculation
> is already done for you. E.g. best_effort_timestamp_time, pkt_pts_time,
> pkt_dts_time, pkt_duration_time.
>
> (Does ffprobe report which frames are corrupt? I didn't check.)
>

it does indeed - not the exact same message I received earlier, but it's
enough for me to write a script to catch these:
Here's a snip from the ffprobe output I posted that shows the corruption

 <logs>
                <log context="mpeg2video" level="16" category="6"
message="[mpeg2video @ 000001df0605e000] ac-tex damaged at 84 42"/>
                <log context="mpeg2video" level="16" category="6"
message="[mpeg2video @ 000001df0605e000] Warning MVs not available"/>

</logs>

Best,

Kieran
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Converting DTS (timestamps) in mpegts to HH:MM:SS:FF

Kieran O Leary
In reply to this post by Gyan Doshi-2
Hi

On Tue, Jun 16, 2020 at 9:51 AM Gyan Doshi <[hidden email]> wrote:

>
>
> On 16-06-2020 02:15 pm, Kieran O Leary wrote:
> > On Tue, Jun 16, 2020 at 9:40 AM Kieran O Leary <[hidden email]
> >
> > wrote:
> >
> >> OK, so I figured out that the dts needs to be divided by
> >> pkt_duration_time, which in this instance was 3600. Not sure how to get
> >> that aside from using ffprobe as I don't see it listed in the ffmpeg
> output.
> >>
> > Sorry, the dts value needs to be divided by pkt_duration, which gives the
> > frame number. Also ffmpeg is amazing.
>
> Actually, the dts is denominated in terms of the stream time_base. For
> MPEG-TS, that's 90000 for all streams.
> This applies to the dts shown in the corrupt packet msg. After decoding,
> lavc will change audio stream time base to stream sampling rate.
>

Argh, you're absolutely right,that produces the seconds value. Thanks Gyan!

K
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".