Avoid duplicated samples with at H265 ts end

This commit is contained in:
Daniele Sparano 2025-02-11 11:45:51 +00:00 committed by tonihei
parent 4015db57a5
commit 8253530688

View File

@ -394,8 +394,10 @@ public final class H265Reader implements ElementaryStreamReader {
public void end(long position) {
sampleIsKeyframe = nalUnitHasKeyframeData;
// Output a sample with the NAL units since the current nalUnitPosition
outputSample(/* offset= */ (int) (position - nalUnitPosition));
if (nalUnitTimeUs != sampleTimeUs) {
// Output a sample with the NAL units since the current nalUnitPosition
outputSample(/* offset= */ (int) (position - nalUnitPosition));
}
// Output a final sample with the remaining NAL units up to the passed position
samplePosition = nalUnitPosition;
nalUnitPosition = position;