Skip to content

Commit 8b8233e

Browse files
JackLau1222Jimmy385898
authored andcommitted
transcoder: fix the output size is too large
set the codec key and value through av_opt_set Signed-off-by: Jack Lau <[email protected]>
1 parent 90f9949 commit 8b8233e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/transcoder/include/transcoder_ffmpeg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern "C" {
2222
#include <libavcodec/avcodec.h>
2323
#include <libavformat/avformat.h>
2424
#include <libavutil/avutil.h>
25+
#include <libavutil/opt.h>
2526
};
2627

2728
#define ENCODE_BIT_RATE 5000000

src/transcoder/src/transcoder_ffmpeg.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ bool TranscoderFFmpeg::prepare_Encoder_Video(StreamContext *decoder,
434434
return false;
435435
}
436436

437+
av_opt_set(encoder->videoCodecCtx->priv_data, "preset", "medium", 0);
438+
if (encoder->videoCodecCtx->codec_id == AV_CODEC_ID_H264)
439+
av_opt_set(encoder->videoCodecCtx->priv_data, "x264-params", "keyint=60:min-keyint=60:scenecut=0:force-cfr=1", 0);
440+
else if (encoder->videoCodecCtx->codec_id == AV_CODEC_ID_HEVC)
441+
av_opt_set(encoder->videoCodecCtx->priv_data, "x265-params", "keyint=60:min-keyint=60:scenecut=0", 0);
442+
437443
if (decoder->videoCodecCtx->codec_type == AVMEDIA_TYPE_VIDEO) {
438444
encoder->videoCodecCtx->height = decoder->videoCodecCtx->height;
439445
encoder->videoCodecCtx->width = decoder->videoCodecCtx->width;

0 commit comments

Comments
 (0)