diff --git a/src/main/java/com/netflix/imflibrary/writerTools/IMPAssembler.java b/src/main/java/com/netflix/imflibrary/writerTools/IMPAssembler.java index 88ffdd03..3b97b0b8 100644 --- a/src/main/java/com/netflix/imflibrary/writerTools/IMPAssembler.java +++ b/src/main/java/com/netflix/imflibrary/writerTools/IMPAssembler.java @@ -61,7 +61,7 @@ public AssembledIMPResult assembleIMFFromFiles(SimpleTimeline simpleTimeline, Fi Map> sampleRateMap = new HashMap<>(); Map sampleCountMap = new HashMap<>(); Map hashMap = new HashMap<>(); - long videoIntrinsicDuration = 0; + long videoTotalSourceDuration = 0; for (Track track : simpleTimeline.getEssenceTracks()) { @@ -159,7 +159,7 @@ public AssembledIMPResult assembleIMFFromFiles(SimpleTimeline simpleTimeline, Fi logger.info("Adding file to resources: {}..", essenceTrackEntry.getFile().getName()); if (track.getSequenceTypeEnum().equals(Composition.SequenceTypeEnum.MainImageSequence)) { - videoIntrinsicDuration += sampleCount.longValue(); + videoTotalSourceDuration += (essenceTrackEntry.getDuration() == null ? sampleCount : essenceTrackEntry.getDuration()).longValue(); } trackFileResources.add( @@ -209,9 +209,9 @@ public AssembledIMPResult assembleIMFFromFiles(SimpleTimeline simpleTimeline, Fi markerResources.add(new IMFMarkerResourceType( UUIDHelper.fromUUID(IMFUUIDGenerator.getInstance().generateUUID()), editRate, - BigInteger.valueOf(videoIntrinsicDuration), + BigInteger.valueOf(videoTotalSourceDuration), BigInteger.ZERO, - BigInteger.valueOf(videoIntrinsicDuration), // source duration may not be necessary + BigInteger.valueOf(videoTotalSourceDuration), // source duration may not be necessary BigInteger.ONE, markerList));