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
651fa0db
authored
Jan 26, 2022
by
claincly
Committed by
Andrew Lewis
Jan 28, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Apply suggested AVC profile depending on the API version.
PiperOrigin-RevId: 424322341
parent
76ceca70
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
3 deletions
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/DefaultCodecFactory.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/DefaultCodecFactory.java
View file @
651fa0db
...
...
@@ -33,6 +33,7 @@ import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import
com.google.android.exoplayer2.util.MediaFormatUtil
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.TraceUtil
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.IOException
;
import
java.util.List
;
import
org.checkerframework.checker.nullness.qual.RequiresNonNull
;
...
...
@@ -123,9 +124,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
format
=
getVideoEncoderSupportedFormat
(
format
,
allowedMimeTypes
);
MediaFormat
mediaFormat
=
MediaFormat
.
createVideoFormat
(
checkNotNull
(
format
.
sampleMimeType
),
format
.
width
,
format
.
height
);
String
mimeType
=
checkNotNull
(
format
.
sampleMimeType
);
MediaFormat
mediaFormat
=
MediaFormat
.
createVideoFormat
(
mimeType
,
format
.
width
,
format
.
height
);
mediaFormat
.
setFloat
(
MediaFormat
.
KEY_FRAME_RATE
,
format
.
frameRate
);
mediaFormat
.
setInteger
(
MediaFormat
.
KEY_BIT_RATE
,
format
.
averageBitrate
);
...
...
@@ -138,6 +138,29 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
}
}
// TODO(b/210593256): Remove overriding profile/level (before API 29) after switching to in-app
// muxing.
if
(
mimeType
.
equals
(
MimeTypes
.
VIDEO_H264
))
{
// Applying suggested profile/level settings from
// https://developer.android.com/guide/topics/media/sharing-video#b-frames_and_encoding_profiles
if
(
Util
.
SDK_INT
>=
29
)
{
// Use the highest supported profile and use B-frames.
mediaFormat
.
setInteger
(
MediaFormat
.
KEY_PROFILE
,
MediaCodecInfo
.
CodecProfileLevel
.
AVCProfileHigh
);
mediaFormat
.
setInteger
(
MediaFormat
.
KEY_MAX_B_FRAMES
,
1
);
}
else
if
(
Util
.
SDK_INT
>=
26
)
{
// Use the highest-supported profile, but disable the generation of B-frames. This
// accommodates some limitations in the MediaMuxer in these system versions.
mediaFormat
.
setInteger
(
MediaFormat
.
KEY_PROFILE
,
MediaCodecInfo
.
CodecProfileLevel
.
AVCProfileHigh
);
mediaFormat
.
setInteger
(
MediaFormat
.
KEY_LATENCY
,
1
);
}
else
{
// Use the baseline profile for safest results.
mediaFormat
.
setInteger
(
MediaFormat
.
KEY_PROFILE
,
MediaCodecInfo
.
CodecProfileLevel
.
AVCProfileBaseline
);
}
}
mediaFormat
.
setInteger
(
MediaFormat
.
KEY_COLOR_FORMAT
,
DEFAULT_COLOR_FORMAT
);
mediaFormat
.
setInteger
(
MediaFormat
.
KEY_I_FRAME_INTERVAL
,
DEFAULT_I_FRAME_INTERVAL_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