Skip to content

Commit fb8b8d9

Browse files
committed
Add FirstPTS/LastPTS/LastEndPTS to FFMS_VideoProperties
1 parent 6601f8c commit fb8b8d9

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

doc/ffms2-api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,9 @@ typedef struct {
10521052
unsigned int ContentLightLevelMax;
10531053
unsigned int ContentLightLevelAverage;
10541054
int Flip;
1055+
int64_t FirstPTS;
1056+
int64_t LastPTS;
1057+
int64_t LastEndPTS;
10551058
} FFMS_VideoProperties;
10561059
```
10571060
A struct containing metadata about a video track.
@@ -1094,6 +1097,8 @@ The fields are:
10941097
- `unsigned int ContentLightLevelMax;` - Maximum content luminance (cd/m^2).
10951098
- `unsigned int ContentLightLevelAverage;` - Average content luminance (cd/m^2).
10961099
- `int Flip;` - Flip direction to be applied *before* rotation: 0 for no operation, >0 for horizontal flip, <0 for vertical flip.
1100+
- `int64_t FirstPTS; int64_t LastPTS;` - The first and last PTS of the stream respectively.
1101+
- `int64_t LastEndPTS;` - The end PTS of the last packet of the stream.
10971102

10981103
### FFMS_AudioProperties
10991104

doc/ffms2-changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- 5.1
33
- FFmpeg 7.1 is now the minimum requirement.
44
- Added layered decoding support, for e.g. spatial MV-HEVC.
5+
- Added FirstPTS, LastPTS and LastEndPTS to FFMS_VideoProperties. Those fields are the equivalent of FirstTime, LastTime and LastEndTime, but they are expressed in the video timebase.
56

67
- 5.0
78
- Fixed all issues with FFmpeg 6.1 which is now the minimum requirement

include/ffms.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ typedef struct FFMS_VideoProperties {
406406
unsigned int ContentLightLevelAverage;
407407
/* Introduced in FFMS_VERSION ((2 << 24) | (31 << 16) | (0 << 8) | 0) */
408408
int Flip; /* -1 = Vertical flip, 1 = Horizontal flip */
409+
/* Introduced in FFMS_VERSION ((5 << 24) | (1 << 16) | (0 << 8) | 0) */
410+
int64_t FirstPTS;
411+
int64_t LastPTS;
412+
int64_t LastEndPTS;
409413
} FFMS_VideoProperties;
410414

411415
typedef struct FFMS_AudioProperties {

src/core/videosource.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,12 @@ void FFMS_VideoSource::SetVideoProperties() {
685685
VP.ColorRange = AVCOL_RANGE_JPEG;
686686

687687

688-
VP.FirstTime = ((Frames[Frames.RealFrameNumber(0)].PTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000;
689-
VP.LastTime = ((Frames[Frames.RealFrameNumber(Frames.VisibleFrameCount()-1)].PTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000;
690-
VP.LastEndTime = (((Frames[Frames.RealFrameNumber(Frames.VisibleFrameCount()-1)].PTS + Frames.LastDuration) * Frames.TB.Num) / (double)Frames.TB.Den) / 1000;
688+
VP.FirstPTS = Frames[Frames.RealFrameNumber(0)].PTS;
689+
VP.LastPTS = Frames[Frames.RealFrameNumber(Frames.VisibleFrameCount()-1)].PTS;
690+
VP.LastEndPTS = VP.LastPTS + Frames.LastDuration;
691+
VP.FirstTime = ((VP.FirstPTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000;
692+
VP.LastTime = ((VP.LastPTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000;
693+
VP.LastEndTime = ((VP.LastEndPTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000;
691694

692695
if (CodecContext->width <= 0 || CodecContext->height <= 0)
693696
throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,

0 commit comments

Comments
 (0)