mirror of
https://github.com/samsonjs/media.git
synced 2026-04-19 13:35:47 +00:00
Fix duration calculation for AVI files
The duration is now correctly calculated as the maximum of all track durations, instead of being overwritten by the last track's value. This aligns with how other Extractor implementations handle durations for multiple tracks.
PiperOrigin-RevId: 688896743
(cherry picked from commit e677c8dccd)
This commit is contained in:
parent
57f0c0d368
commit
a03bd8248c
6 changed files with 17 additions and 16 deletions
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package androidx.media3.extractor.avi;
|
||||
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.annotation.ElementType.TYPE_USE;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
|
@ -521,7 +522,7 @@ public final class AviExtractor implements Extractor {
|
|||
ChunkReader chunkReader =
|
||||
new ChunkReader(
|
||||
streamId, trackType, durationUs, aviStreamHeaderChunk.length, trackOutput);
|
||||
this.durationUs = durationUs;
|
||||
this.durationUs = max(this.durationUs, durationUs);
|
||||
return chunkReader;
|
||||
} else {
|
||||
// We don't currently support tracks other than video and audio.
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
seekMap:
|
||||
isSeekable = true
|
||||
duration = 4080000
|
||||
duration = 4087416
|
||||
getPosition(0) = [[timeUs=0, position=9996]]
|
||||
getPosition(1) = [[timeUs=0, position=9996]]
|
||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
||||
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||
numberOfTracks = 2
|
||||
track 0:
|
||||
total output bytes = 252777
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
seekMap:
|
||||
isSeekable = true
|
||||
duration = 4080000
|
||||
duration = 4087416
|
||||
getPosition(0) = [[timeUs=0, position=9996]]
|
||||
getPosition(1) = [[timeUs=0, position=9996]]
|
||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
||||
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||
numberOfTracks = 2
|
||||
track 0:
|
||||
total output bytes = 165531
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
seekMap:
|
||||
isSeekable = true
|
||||
duration = 4080000
|
||||
duration = 4087416
|
||||
getPosition(0) = [[timeUs=0, position=9996]]
|
||||
getPosition(1) = [[timeUs=0, position=9996]]
|
||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
||||
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||
numberOfTracks = 2
|
||||
track 0:
|
||||
total output bytes = 102418
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
seekMap:
|
||||
isSeekable = true
|
||||
duration = 4080000
|
||||
duration = 4087416
|
||||
getPosition(0) = [[timeUs=0, position=9996]]
|
||||
getPosition(1) = [[timeUs=0, position=9996]]
|
||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
||||
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||
numberOfTracks = 2
|
||||
track 0:
|
||||
total output bytes = 17833
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
seekMap:
|
||||
isSeekable = true
|
||||
duration = 4080000
|
||||
duration = 4087416
|
||||
getPosition(0) = [[timeUs=0, position=9996]]
|
||||
getPosition(1) = [[timeUs=0, position=9996]]
|
||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
||||
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||
numberOfTracks = 2
|
||||
track 0:
|
||||
total output bytes = 252777
|
||||
|
|
|
|||
Loading…
Reference in a new issue