Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9bd93ad9
authored
Jan 31, 2022
by
Dustin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add work-around for muxer bug where idx1 offset is from 0, not "movi"
location
parent
0ff238df
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviSeekMap.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviSeekMapTest.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java
View file @
9bd93ad9
...
@@ -399,6 +399,14 @@ public class AviExtractor implements Extractor {
...
@@ -399,6 +399,14 @@ public class AviExtractor implements Extractor {
w
(
"No video track found"
);
w
(
"No video track found"
);
return
;
return
;
}
}
if
(
remaining
<
16
)
{
output
.
seekMap
(
new
SeekMap
.
Unseekable
(
getDuration
()));
w
(
"Index too short"
);
return
;
}
final
ByteBuffer
firstEntry
=
AviExtractor
.
allocate
(
16
);
input
.
peekFully
(
firstEntry
.
array
(),
0
,
16
);
final
int
videoId
=
videoTrack
.
id
;
final
int
videoId
=
videoTrack
.
id
;
final
ByteBuffer
indexByteBuffer
=
allocate
(
Math
.
min
(
remaining
,
64
*
1024
));
final
ByteBuffer
indexByteBuffer
=
allocate
(
Math
.
min
(
remaining
,
64
*
1024
));
final
byte
[]
bytes
=
indexByteBuffer
.
array
();
final
byte
[]
bytes
=
indexByteBuffer
.
array
();
...
@@ -466,8 +474,10 @@ public class AviExtractor implements Extractor {
...
@@ -466,8 +474,10 @@ public class AviExtractor implements Extractor {
videoTrack
.
setKeyFrames
(
seekIndexes
[
videoId
].
getArray
());
videoTrack
.
setKeyFrames
(
seekIndexes
[
videoId
].
getArray
());
}
}
//Work-around a bug where the offset is from the start of the file, not "movi"
final
long
seekOffset
=
firstEntry
.
getInt
(
8
)
>
moviOffset
?
0L
:
moviOffset
;
final
AviSeekMap
seekMap
=
new
AviSeekMap
(
videoId
,
videoTrack
.
clock
.
durationUs
,
videoTrack
.
chunks
,
final
AviSeekMap
seekMap
=
new
AviSeekMap
(
videoId
,
videoTrack
.
clock
.
durationUs
,
videoTrack
.
chunks
,
keyFrameOffsetsDiv2
.
getArray
(),
seekIndexes
,
movi
Offset
);
keyFrameOffsetsDiv2
.
getArray
(),
seekIndexes
,
seek
Offset
);
i
(
"Video chunks="
+
videoTrack
.
chunks
+
" us="
+
seekMap
.
getDurationUs
());
i
(
"Video chunks="
+
videoTrack
.
chunks
+
" us="
+
seekMap
.
getDurationUs
());
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviSeekMap.java
View file @
9bd93ad9
...
@@ -14,10 +14,13 @@ public class AviSeekMap implements SeekMap {
...
@@ -14,10 +14,13 @@ public class AviSeekMap implements SeekMap {
final
int
[]
keyFrameOffsetsDiv2
;
final
int
[]
keyFrameOffsetsDiv2
;
//Seek chunk indexes by streamId
//Seek chunk indexes by streamId
final
int
[][]
seekIndexes
;
final
int
[][]
seekIndexes
;
final
long
moviOffset
;
/**
* Usually the same as moviOffset, but sometimes 0 (muxer bug)
*/
final
long
seekOffset
;
public
AviSeekMap
(
int
videoId
,
long
usDuration
,
int
videoChunks
,
int
[]
keyFrameOffsetsDiv2
,
public
AviSeekMap
(
int
videoId
,
long
usDuration
,
int
videoChunks
,
int
[]
keyFrameOffsetsDiv2
,
UnboundedIntArray
[]
seekIndexes
,
long
movi
Offset
)
{
UnboundedIntArray
[]
seekIndexes
,
long
seek
Offset
)
{
this
.
videoId
=
videoId
;
this
.
videoId
=
videoId
;
this
.
videoUsPerChunk
=
usDuration
/
videoChunks
;
this
.
videoUsPerChunk
=
usDuration
/
videoChunks
;
this
.
duration
=
usDuration
;
this
.
duration
=
usDuration
;
...
@@ -26,7 +29,7 @@ public class AviSeekMap implements SeekMap {
...
@@ -26,7 +29,7 @@ public class AviSeekMap implements SeekMap {
for
(
int
i
=
0
;
i
<
seekIndexes
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
seekIndexes
.
length
;
i
++)
{
this
.
seekIndexes
[
i
]
=
seekIndexes
[
i
].
getArray
();
this
.
seekIndexes
[
i
]
=
seekIndexes
[
i
].
getArray
();
}
}
this
.
moviOffset
=
movi
Offset
;
this
.
seekOffset
=
seek
Offset
;
}
}
@Override
@Override
...
@@ -56,7 +59,7 @@ public class AviSeekMap implements SeekMap {
...
@@ -56,7 +59,7 @@ public class AviSeekMap implements SeekMap {
private
SeekPoint
getSeekPoint
(
int
index
)
{
private
SeekPoint
getSeekPoint
(
int
index
)
{
long
offset
=
keyFrameOffsetsDiv2
[
index
]
*
2L
;
long
offset
=
keyFrameOffsetsDiv2
[
index
]
*
2L
;
final
long
outUs
=
seekIndexes
[
videoId
][
index
]
*
videoUsPerChunk
;
final
long
outUs
=
seekIndexes
[
videoId
][
index
]
*
videoUsPerChunk
;
final
long
position
=
offset
+
movi
Offset
;
final
long
position
=
offset
+
seek
Offset
;
return
new
SeekPoint
(
outUs
,
position
);
return
new
SeekPoint
(
outUs
,
position
);
}
}
...
@@ -78,7 +81,7 @@ public class AviSeekMap implements SeekMap {
...
@@ -78,7 +81,7 @@ public class AviSeekMap implements SeekMap {
}
}
public
void
setFrames
(
final
long
position
,
final
long
timeUs
,
final
AviTrack
[]
aviTracks
)
{
public
void
setFrames
(
final
long
position
,
final
long
timeUs
,
final
AviTrack
[]
aviTracks
)
{
final
int
index
=
Arrays
.
binarySearch
(
keyFrameOffsetsDiv2
,
(
int
)((
position
-
movi
Offset
)
/
2
));
final
int
index
=
Arrays
.
binarySearch
(
keyFrameOffsetsDiv2
,
(
int
)((
position
-
seek
Offset
)
/
2
));
if
(
index
<
0
)
{
if
(
index
<
0
)
{
throw
new
IllegalArgumentException
(
"Position: "
+
position
);
throw
new
IllegalArgumentException
(
"Position: "
+
position
);
...
...
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviSeekMapTest.java
View file @
9bd93ad9
...
@@ -9,7 +9,7 @@ public class AviSeekMapTest {
...
@@ -9,7 +9,7 @@ public class AviSeekMapTest {
@Test
@Test
public
void
setFrames_givenExactSeekPointMatch
()
{
public
void
setFrames_givenExactSeekPointMatch
()
{
final
AviSeekMap
aviSeekMap
=
DataHelper
.
getAviSeekMap
();
final
AviSeekMap
aviSeekMap
=
DataHelper
.
getAviSeekMap
();
final
long
position
=
aviSeekMap
.
keyFrameOffsetsDiv2
[
1
]
*
2L
+
aviSeekMap
.
movi
Offset
;
final
long
position
=
aviSeekMap
.
keyFrameOffsetsDiv2
[
1
]
*
2L
+
aviSeekMap
.
seek
Offset
;
final
int
secs
=
4
;
final
int
secs
=
4
;
final
AviTrack
[]
aviTracks
=
new
AviTrack
[]{
DataHelper
.
getVideoAviTrack
(
secs
),
final
AviTrack
[]
aviTracks
=
new
AviTrack
[]{
DataHelper
.
getVideoAviTrack
(
secs
),
DataHelper
.
getAudioAviTrack
(
secs
)};
DataHelper
.
getAudioAviTrack
(
secs
)};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment