Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
40a4e63b
Commit
40a4e63b
authored
5 years ago
by
Pierre Lespagnol
Committed by
Adrien Béraud
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
encoder: fix preset for nvenc
Change-Id: Ie365e0012c80783459d59df9114f78135cd7bfba
parent
e7fcef63
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/media/media_encoder.cpp
+20
-10
20 additions, 10 deletions
src/media/media_encoder.cpp
src/media/media_encoder.h
+1
-1
1 addition, 1 deletion
src/media/media_encoder.h
with
21 additions
and
11 deletions
src/media/media_encoder.cpp
+
20
−
10
View file @
40a4e63b
...
@@ -597,18 +597,28 @@ MediaEncoder::prepareEncoderContext(AVCodec* outputCodec, bool is_video)
...
@@ -597,18 +597,28 @@ MediaEncoder::prepareEncoderContext(AVCodec* outputCodec, bool is_video)
}
}
void
void
MediaEncoder
::
forcePresetX264
_X26
5
(
AVCodecContext
*
encoderCtx
)
MediaEncoder
::
forcePresetX2645
(
AVCodecContext
*
encoderCtx
)
{
{
if
(
accel_
&&
accel_
->
getName
()
==
"nvenc"
)
{
if
(
av_opt_set
(
encoderCtx
,
"preset"
,
"fast"
,
AV_OPT_SEARCH_CHILDREN
))
JAMI_WARN
(
"Failed to set preset to 'fast'"
);
if
(
av_opt_set
(
encoderCtx
,
"level"
,
"auto"
,
AV_OPT_SEARCH_CHILDREN
))
JAMI_WARN
(
"Failed to set level to 'auto'"
);
if
(
av_opt_set_int
(
encoderCtx
,
"zerolatency"
,
1
,
AV_OPT_SEARCH_CHILDREN
))
JAMI_WARN
(
"Failed to set zerolatency to '1'"
);
}
else
{
#if (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
#if (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
const
char
*
speedPreset
=
"ultrafast"
;
const
char
*
speedPreset
=
"ultrafast"
;
#else
#else
const
char
*
speedPreset
=
"veryfast"
;
const
char
*
speedPreset
=
"veryfast"
;
#endif
#endif
if
(
av_opt_set
(
encoderCtx
,
"preset"
,
speedPreset
,
AV_OPT_SEARCH_CHILDREN
))
if
(
av_opt_set
(
encoderCtx
,
"preset"
,
speedPreset
,
AV_OPT_SEARCH_CHILDREN
))
JAMI_WARN
(
"Failed to set
x264
preset '%s'"
,
speedPreset
);
JAMI_WARN
(
"Failed to set preset '%s'"
,
speedPreset
);
const
char
*
tune
=
"zerolatency"
;
const
char
*
tune
=
"zerolatency"
;
if
(
av_opt_set
(
encoderCtx
,
"tune"
,
tune
,
AV_OPT_SEARCH_CHILDREN
))
if
(
av_opt_set
(
encoderCtx
,
"tune"
,
tune
,
AV_OPT_SEARCH_CHILDREN
))
JAMI_WARN
(
"Failed to set x264 tune '%s'"
,
tune
);
JAMI_WARN
(
"Failed to set tune '%s'"
,
tune
);
}
}
}
void
void
...
@@ -748,11 +758,11 @@ MediaEncoder::initCodec(AVMediaType mediaType, AVCodecID avcodecId, uint64_t br)
...
@@ -748,11 +758,11 @@ MediaEncoder::initCodec(AVMediaType mediaType, AVCodecID avcodecId, uint64_t br)
if
(
avcodecId
==
AV_CODEC_ID_H264
)
{
if
(
avcodecId
==
AV_CODEC_ID_H264
)
{
auto
profileLevelId
=
libav_utils
::
getDictValue
(
options_
,
"parameters"
);
auto
profileLevelId
=
libav_utils
::
getDictValue
(
options_
,
"parameters"
);
extractProfileLevelID
(
profileLevelId
,
encoderCtx
);
extractProfileLevelID
(
profileLevelId
,
encoderCtx
);
forcePresetX264
_X26
5
(
encoderCtx
);
forcePresetX2645
(
encoderCtx
);
initH264
(
encoderCtx
,
br
);
initH264
(
encoderCtx
,
br
);
}
else
if
(
avcodecId
==
AV_CODEC_ID_HEVC
)
{
}
else
if
(
avcodecId
==
AV_CODEC_ID_HEVC
)
{
encoderCtx
->
profile
=
FF_PROFILE_HEVC_MAIN
;
encoderCtx
->
profile
=
FF_PROFILE_HEVC_MAIN
;
forcePresetX264
_X26
5
(
encoderCtx
);
forcePresetX2645
(
encoderCtx
);
initH265
(
encoderCtx
,
br
);
initH265
(
encoderCtx
,
br
);
}
else
if
(
avcodecId
==
AV_CODEC_ID_VP8
)
{
}
else
if
(
avcodecId
==
AV_CODEC_ID_VP8
)
{
initVP8
(
encoderCtx
,
br
);
initVP8
(
encoderCtx
,
br
);
...
...
This diff is collapsed.
Click to expand it.
src/media/media_encoder.h
+
1
−
1
View file @
40a4e63b
...
@@ -114,7 +114,7 @@ public:
...
@@ -114,7 +114,7 @@ public:
private
:
private
:
NON_COPYABLE
(
MediaEncoder
);
NON_COPYABLE
(
MediaEncoder
);
AVCodecContext
*
prepareEncoderContext
(
AVCodec
*
outputCodec
,
bool
is_video
);
AVCodecContext
*
prepareEncoderContext
(
AVCodec
*
outputCodec
,
bool
is_video
);
void
forcePresetX264
_X26
5
(
AVCodecContext
*
encoderCtx
);
void
forcePresetX2645
(
AVCodecContext
*
encoderCtx
);
void
extractProfileLevelID
(
const
std
::
string
&
parameters
,
AVCodecContext
*
ctx
);
void
extractProfileLevelID
(
const
std
::
string
&
parameters
,
AVCodecContext
*
ctx
);
int
initStream
(
const
std
::
string
&
codecName
,
AVBufferRef
*
framesCtx
);
int
initStream
(
const
std
::
string
&
codecName
,
AVBufferRef
*
framesCtx
);
int
initStream
(
const
SystemCodecInfo
&
systemCodecInfo
,
AVBufferRef
*
framesCtx
);
int
initStream
(
const
SystemCodecInfo
&
systemCodecInfo
,
AVBufferRef
*
framesCtx
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment