Skip to content

Commit 65afb86

Browse files
committed
Add LastEndPTS to FFMS_VideoProperties
1 parent 65f6ce9 commit 65afb86

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

doc/ffms2-api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ typedef struct {
10521052
unsigned int ContentLightLevelMax;
10531053
unsigned int ContentLightLevelAverage;
10541054
int Flip;
1055+
int64_t LastEndPTS;
10551056
} FFMS_VideoProperties;
10561057
```
10571058
A struct containing metadata about a video track.
@@ -1094,6 +1095,7 @@ The fields are:
10941095
- `unsigned int ContentLightLevelMax;` - Maximum content luminance (cd/m^2).
10951096
- `unsigned int ContentLightLevelAverage;` - Average content luminance (cd/m^2).
10961097
- `int Flip;` - Flip direction to be applied *before* rotation: 0 for no operation, >0 for horizontal flip, <0 for vertical flip.
1098+
- `int64_t LastEndPTS;` - The end PTS of the last packet of the stream.
10971099

10981100
### FFMS_AudioProperties
10991101

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 LastEndPTS to FFMS_VideoProperties. This field is the equivalent of LastEndTime, but it is 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ 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) | (1 << 8) | 0) */
410+
int64_t LastEndPTS;
409411
} FFMS_VideoProperties;
410412

411413
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+
auto FirstPTS = Frames[Frames.RealFrameNumber(0)].PTS;
689+
auto LastPTS = Frames[Frames.RealFrameNumber(Frames.VisibleFrameCount()-1)].PTS;
690+
VP.LastEndPTS = LastPTS + Frames.LastDuration;
691+
VP.FirstTime = ((FirstPTS * Frames.TB.Num) / (double)Frames.TB.Den) / 1000;
692+
VP.LastTime = ((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)