MediaArea / MediaInfoLib

Convenient unified display of the most relevant technical and tag data for video and audio files.
https://mediaarea.net/MediaInfo
BSD 2-Clause "Simplified" License
621 stars 170 forks source link

Mismatch in container and video duration for MPEG-TS #2087

Open plondino opened 2 years ago

plondino commented 2 years ago

I have an MPEG TS file that has a mismatch in the container and video duration:

General
Commercial name                          : MPEG-TS
Frame count                              : 961
Duration                                 : 32032.000000
Duration                                 : 32 s 32 ms
Duration                                 : 32 s 32 ms
Duration                                 : 32 s 32 ms
Duration                                 : 00:00:32.032
Duration                                 : 00:00:32;01
Duration                                 : 00:00:32.032 (00:00:32;01)

The video reports:

Video
Commercial name                          : MPEG-2 Video
Frame count                              : 961
Duration                                 : 32065
Duration                                 : 32 s 65 ms
Duration                                 : 32 s 65 ms
Duration                                 : 32 s 65 ms
Duration                                 : 00:00:32.065
Duration                                 : 00:00:32;01
Duration                                 : 00:00:32.065 (00:00:32;01)

A duration of 961 frames at 30000/1001 should be ~32.65s so not clear why the general section reports the duration as 32.32s.

I can provide a sample file if necessary.

JeromeMartinez commented 10 months ago

not clear why the general section reports the duration as 32.32s.

The General section uses the PCR values, but without adding the duration of the last frame associated with stream transporting the PCR, I guess that we need to add it there for having something which is greater than the duration of the longer stream in the file.

JeromeMartinez commented 1 month ago

@plondino I implemented in https://github.com/MediaArea/MediaInfoLib/pull/2073 what was buggy from my point of view but I am not sure that it is what you expect.

General duration is now coherent with file size and overall bit rate (duration = file size * 8 / overall bit rate), it is the duration of the content transmission as indicated by the TS stream. It is not based on the duration of any A/V stream. Sometimes general duration is smaller than other duration due to a burst in the content transmission, sometimes it is larger due to I-frame not at the beginning of the transmission, sometimes same if all is well synchronized.

When you say:

A duration of 961 frames at 30000/1001 should be ~32.65s so not clear why the general section reports the duration as 32.32s.

I don't consider as an issue directly, because the transmission duration could be 32.32s due to some small p/b frames at the end, no need of 32.65s for transmitting 32.65s of content.

What is your idea behind this ticket? What do you expect from General duration not in other parts of MediaInfo?

With an example, could you say what value you expect? A caricatural but possible example: 2 TS programs Program 1 has V1 and A1, PCR1 on V1 Program 2 has V2 and A2, PCR2 on V2 PCR1 has start 0.50s and end 1.5s V1 has start 1.00s and end 2.10s A1 has start 0.98s and end 1.99s PCR2 has start 0.45s and end 1.45s V2 has start 0.70s and end 1.60s A2 has start 0.60s and end 1.80s

Currently MI has: General duration 1.00s (based on end PCRx - start PCRx, both PCR should be same in a coherent TS) V1 duration 1.10s (end V1 - start V1) V2 duration 0.90s (end V2 - start V2) A1 duration 1.01s (end A1 - start A1) A2 duration 1.20s (end A2 - start A2)

General duration is less than any stream in this example because the transmission was faster than any content. If something else is expected, is it max (A/V ends) - min (A/V starts) = 1.50s, max (max(A/V end per program) - min(A/V start per program)) = 1.20s, something else?


You can test the latest dev snapshots knowing that this is maybe not as you expect due to a different idea we have of general duration field.