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
77a18739
authored
Jan 23, 2022
by
Dustin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix bugs around seek
parent
98b487eb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
20 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/AviTrack.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviExtractor.java
View file @
77a18739
...
@@ -94,7 +94,7 @@ public class AviExtractor implements Extractor {
...
@@ -94,7 +94,7 @@ public class AviExtractor implements Extractor {
@Override
@Override
public
boolean
sniff
(
ExtractorInput
input
)
throws
IOException
{
public
boolean
sniff
(
ExtractorInput
input
)
throws
IOException
{
return
pe
a
kHeaderList
(
input
);
return
pe
e
kHeaderList
(
input
);
}
}
static
ByteBuffer
allocate
(
int
bytes
)
{
static
ByteBuffer
allocate
(
int
bytes
)
{
...
@@ -109,7 +109,7 @@ public class AviExtractor implements Extractor {
...
@@ -109,7 +109,7 @@ public class AviExtractor implements Extractor {
output
.
seekMap
(
aviSeekMap
);
output
.
seekMap
(
aviSeekMap
);
}
}
boolean
pea
kHeaderList
(
ExtractorInput
input
)
throws
IOException
{
static
boolean
pee
kHeaderList
(
ExtractorInput
input
)
throws
IOException
{
final
ByteBuffer
byteBuffer
=
allocate
(
PEEK_BYTES
);
final
ByteBuffer
byteBuffer
=
allocate
(
PEEK_BYTES
);
input
.
peekFully
(
byteBuffer
.
array
(),
0
,
PEEK_BYTES
);
input
.
peekFully
(
byteBuffer
.
array
(),
0
,
PEEK_BYTES
);
final
int
riff
=
byteBuffer
.
getInt
();
final
int
riff
=
byteBuffer
.
getInt
();
...
@@ -141,6 +141,7 @@ public class AviExtractor implements Extractor {
...
@@ -141,6 +141,7 @@ public class AviExtractor implements Extractor {
}
}
return
true
;
return
true
;
}
}
@Nullable
@Nullable
ListBox
readHeaderList
(
ExtractorInput
input
)
throws
IOException
{
ListBox
readHeaderList
(
ExtractorInput
input
)
throws
IOException
{
final
ByteBuffer
byteBuffer
=
allocate
(
20
);
final
ByteBuffer
byteBuffer
=
allocate
(
20
);
...
@@ -169,9 +170,11 @@ public class AviExtractor implements Extractor {
...
@@ -169,9 +170,11 @@ public class AviExtractor implements Extractor {
}
}
return
listBox
;
return
listBox
;
}
}
long
getDuration
()
{
long
getDuration
()
{
return
durationUs
;
return
durationUs
;
}
}
@Override
@Override
public
void
init
(
ExtractorOutput
output
)
{
public
void
init
(
ExtractorOutput
output
)
{
this
.
state
=
STATE_READ_TRACKS
;
this
.
state
=
STATE_READ_TRACKS
;
...
@@ -222,17 +225,7 @@ public class AviExtractor implements Extractor {
...
@@ -222,17 +225,7 @@ public class AviExtractor implements Extractor {
builder
.
setHeight
(
videoFormat
.
getHeight
());
builder
.
setHeight
(
videoFormat
.
getHeight
());
builder
.
setFrameRate
(
streamHeader
.
getFrameRate
());
builder
.
setFrameRate
(
streamHeader
.
getFrameRate
());
builder
.
setSampleMimeType
(
mimeType
);
builder
.
setSampleMimeType
(
mimeType
);
// final StreamDataBox codecBox = (StreamDataBox) peekNext(streamChildren, i, StreamDataBox.STRD);
// final List<byte[]> codecData;
// if (codecBox != null) {
// codecData = Collections.singletonList(codecBox.getData());
// i++;
// } else {
// codecData = null;
// }
// if (codecData != null) {
// builder.setInitializationData(codecData);
// }
final
AviTrack
aviTrack
;
final
AviTrack
aviTrack
;
switch
(
mimeType
)
{
switch
(
mimeType
)
{
case
MimeTypes
.
VIDEO_MP4V
:
case
MimeTypes
.
VIDEO_MP4V
:
...
@@ -358,7 +351,7 @@ public class AviExtractor implements Extractor {
...
@@ -358,7 +351,7 @@ public class AviExtractor implements Extractor {
indexByteBuffer
.
position
(
indexByteBuffer
.
position
()
+
4
);
indexByteBuffer
.
position
(
indexByteBuffer
.
position
()
+
4
);
//int size = indexByteBuffer.getInt();
//int size = indexByteBuffer.getInt();
if
(
aviTrack
.
isVideo
())
{
if
(
aviTrack
.
isVideo
())
{
if
((
flags
&
AVIIF_KEYFRAME
)
==
AVIIF_KEYFRAME
)
{
if
(
!
aviTrack
.
isAllKeyFrames
()
&&
(
flags
&
AVIIF_KEYFRAME
)
==
AVIIF_KEYFRAME
)
{
keyFrameList
.
add
(
aviTrack
.
frame
);
keyFrameList
.
add
(
aviTrack
.
frame
);
}
}
if
(
aviTrack
.
frame
%
seekFrameRate
==
0
)
{
if
(
aviTrack
.
frame
%
seekFrameRate
==
0
)
{
...
@@ -377,9 +370,11 @@ public class AviExtractor implements Extractor {
...
@@ -377,9 +370,11 @@ public class AviExtractor implements Extractor {
indexByteBuffer
.
compact
();
indexByteBuffer
.
compact
();
}
}
videoSeekOffset
.
pack
();
videoSeekOffset
.
pack
();
if
(!
videoTrack
.
isAllKeyFrames
())
{
keyFrameList
.
pack
();
keyFrameList
.
pack
();
final
int
[]
keyFrames
=
keyFrameList
.
array
;
final
int
[]
keyFrames
=
keyFrameList
.
getArray
()
;
videoTrack
.
setKeyFrames
(
keyFrames
);
videoTrack
.
setKeyFrames
(
keyFrames
);
}
//Correct the timings
//Correct the timings
durationUs
=
videoTrack
.
usPerSample
*
videoTrack
.
frame
;
durationUs
=
videoTrack
.
usPerSample
*
videoTrack
.
frame
;
...
@@ -387,7 +382,7 @@ public class AviExtractor implements Extractor {
...
@@ -387,7 +382,7 @@ public class AviExtractor implements Extractor {
final
SparseArray
<
int
[]>
idFrameArray
=
new
SparseArray
<>();
final
SparseArray
<
int
[]>
idFrameArray
=
new
SparseArray
<>();
for
(
Map
.
Entry
<
Integer
,
UnboundedIntArray
>
entry
:
audioIdFrameMap
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
UnboundedIntArray
>
entry
:
audioIdFrameMap
.
entrySet
())
{
entry
.
getValue
().
pack
();
entry
.
getValue
().
pack
();
idFrameArray
.
put
(
entry
.
getKey
(),
entry
.
getValue
().
array
);
idFrameArray
.
put
(
entry
.
getKey
(),
entry
.
getValue
().
getArray
()
);
final
AviTrack
aviTrack
=
idTrackMap
.
get
(
entry
.
getKey
());
final
AviTrack
aviTrack
=
idTrackMap
.
get
(
entry
.
getKey
());
//Sometimes this value is way off
//Sometimes this value is way off
long
calcUsPerSample
=
(
getDuration
()/
aviTrack
.
frame
);
long
calcUsPerSample
=
(
getDuration
()/
aviTrack
.
frame
);
...
@@ -397,7 +392,7 @@ public class AviExtractor implements Extractor {
...
@@ -397,7 +392,7 @@ public class AviExtractor implements Extractor {
Log
.
d
(
TAG
,
"Frames act="
+
getDuration
()
+
" calc="
+
(
aviTrack
.
usPerSample
*
aviTrack
.
frame
));
Log
.
d
(
TAG
,
"Frames act="
+
getDuration
()
+
" calc="
+
(
aviTrack
.
usPerSample
*
aviTrack
.
frame
));
}
}
}
}
final
AviSeekMap
seekMap
=
new
AviSeekMap
(
videoTrack
,
seekFrameRate
,
videoSeekOffset
.
array
,
final
AviSeekMap
seekMap
=
new
AviSeekMap
(
videoTrack
,
seekFrameRate
,
videoSeekOffset
.
getArray
()
,
idFrameArray
,
moviOffset
,
getDuration
());
idFrameArray
,
moviOffset
,
getDuration
());
setSeekMap
(
seekMap
);
setSeekMap
(
seekMap
);
resetFrames
();
resetFrames
();
...
@@ -483,7 +478,8 @@ public class AviExtractor implements Extractor {
...
@@ -483,7 +478,8 @@ public class AviExtractor implements Extractor {
@Override
@Override
public
void
seek
(
long
position
,
long
timeUs
)
{
public
void
seek
(
long
position
,
long
timeUs
)
{
if
(
position
==
0
)
{
chunkHandler
=
null
;
if
(
position
<=
0
)
{
if
(
moviOffset
!=
0
)
{
if
(
moviOffset
!=
0
)
{
resetFrames
();
resetFrames
();
state
=
STATE_SEEK_START
;
state
=
STATE_SEEK_START
;
...
@@ -498,12 +494,11 @@ public class AviExtractor implements Extractor {
...
@@ -498,12 +494,11 @@ public class AviExtractor implements Extractor {
void
resetFrames
()
{
void
resetFrames
()
{
for
(
int
i
=
0
;
i
<
idTrackMap
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
idTrackMap
.
size
();
i
++)
{
final
AviTrack
aviTrack
=
idTrackMap
.
valueAt
(
i
);
final
AviTrack
aviTrack
=
idTrackMap
.
valueAt
(
i
);
aviTrack
.
frame
=
0
;
aviTrack
.
seekFrame
(
0
)
;
}
}
}
}
@Override
@Override
public
void
release
()
{
public
void
release
()
{
}
}
}
}
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviTrack.java
View file @
77a18739
...
@@ -52,6 +52,10 @@ public class AviTrack {
...
@@ -52,6 +52,10 @@ public class AviTrack {
this
.
allKeyFrames
=
streamHeaderBox
.
isAudio
()
||
(
MimeTypes
.
IMAGE_JPEG
.
equals
(
streamHeaderBox
.
getMimeType
()));
this
.
allKeyFrames
=
streamHeaderBox
.
isAudio
()
||
(
MimeTypes
.
IMAGE_JPEG
.
equals
(
streamHeaderBox
.
getMimeType
()));
}
}
public
boolean
isAllKeyFrames
()
{
return
allKeyFrames
;
}
public
boolean
isKeyFrame
()
{
public
boolean
isKeyFrame
()
{
if
(
allKeyFrames
)
{
if
(
allKeyFrames
)
{
return
true
;
return
true
;
...
...
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