mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08: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
This commit is contained in:
parent
0038dda3c3
commit
e677c8dccd
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.extractor.avi;
|
package androidx.media3.extractor.avi;
|
||||||
|
|
||||||
|
import static java.lang.Math.max;
|
||||||
import static java.lang.annotation.ElementType.TYPE_USE;
|
import static java.lang.annotation.ElementType.TYPE_USE;
|
||||||
|
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
@ -521,7 +522,7 @@ public final class AviExtractor implements Extractor {
|
|||||||
ChunkReader chunkReader =
|
ChunkReader chunkReader =
|
||||||
new ChunkReader(
|
new ChunkReader(
|
||||||
streamId, trackType, durationUs, aviStreamHeaderChunk.length, trackOutput);
|
streamId, trackType, durationUs, aviStreamHeaderChunk.length, trackOutput);
|
||||||
this.durationUs = durationUs;
|
this.durationUs = max(this.durationUs, durationUs);
|
||||||
return chunkReader;
|
return chunkReader;
|
||||||
} else {
|
} else {
|
||||||
// We don't currently support tracks other than video and audio.
|
// We don't currently support tracks other than video and audio.
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
seekMap:
|
seekMap:
|
||||||
isSeekable = true
|
isSeekable = true
|
||||||
duration = 4080000
|
duration = 4087416
|
||||||
getPosition(0) = [[timeUs=0, position=9996]]
|
getPosition(0) = [[timeUs=0, position=9996]]
|
||||||
getPosition(1) = [[timeUs=0, position=9996]]
|
getPosition(1) = [[timeUs=0, position=9996]]
|
||||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||||
numberOfTracks = 2
|
numberOfTracks = 2
|
||||||
track 0:
|
track 0:
|
||||||
total output bytes = 252777
|
total output bytes = 252777
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
seekMap:
|
seekMap:
|
||||||
isSeekable = true
|
isSeekable = true
|
||||||
duration = 4080000
|
duration = 4087416
|
||||||
getPosition(0) = [[timeUs=0, position=9996]]
|
getPosition(0) = [[timeUs=0, position=9996]]
|
||||||
getPosition(1) = [[timeUs=0, position=9996]]
|
getPosition(1) = [[timeUs=0, position=9996]]
|
||||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||||
numberOfTracks = 2
|
numberOfTracks = 2
|
||||||
track 0:
|
track 0:
|
||||||
total output bytes = 165531
|
total output bytes = 165531
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
seekMap:
|
seekMap:
|
||||||
isSeekable = true
|
isSeekable = true
|
||||||
duration = 4080000
|
duration = 4087416
|
||||||
getPosition(0) = [[timeUs=0, position=9996]]
|
getPosition(0) = [[timeUs=0, position=9996]]
|
||||||
getPosition(1) = [[timeUs=0, position=9996]]
|
getPosition(1) = [[timeUs=0, position=9996]]
|
||||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||||
numberOfTracks = 2
|
numberOfTracks = 2
|
||||||
track 0:
|
track 0:
|
||||||
total output bytes = 102418
|
total output bytes = 102418
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
seekMap:
|
seekMap:
|
||||||
isSeekable = true
|
isSeekable = true
|
||||||
duration = 4080000
|
duration = 4087416
|
||||||
getPosition(0) = [[timeUs=0, position=9996]]
|
getPosition(0) = [[timeUs=0, position=9996]]
|
||||||
getPosition(1) = [[timeUs=0, position=9996]]
|
getPosition(1) = [[timeUs=0, position=9996]]
|
||||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||||
numberOfTracks = 2
|
numberOfTracks = 2
|
||||||
track 0:
|
track 0:
|
||||||
total output bytes = 17833
|
total output bytes = 17833
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
seekMap:
|
seekMap:
|
||||||
isSeekable = true
|
isSeekable = true
|
||||||
duration = 4080000
|
duration = 4087416
|
||||||
getPosition(0) = [[timeUs=0, position=9996]]
|
getPosition(0) = [[timeUs=0, position=9996]]
|
||||||
getPosition(1) = [[timeUs=0, position=9996]]
|
getPosition(1) = [[timeUs=0, position=9996]]
|
||||||
getPosition(2040000) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
getPosition(2043708) = [[timeUs=1835152, position=160708], [timeUs=2335648, position=198850]]
|
||||||
getPosition(4080000) = [[timeUs=3837136, position=308434]]
|
getPosition(4087416) = [[timeUs=3837136, position=308434]]
|
||||||
numberOfTracks = 2
|
numberOfTracks = 2
|
||||||
track 0:
|
track 0:
|
||||||
total output bytes = 252777
|
total output bytes = 252777
|
||||||
|
Loading…
x
Reference in New Issue
Block a user