Skip to content

Commit

Permalink
libav_encoder: Allow other libav encoders to be selected.
Browse files Browse the repository at this point in the history
Add a general codec options function that will allow other libav
encoders to be selected correctly.

Signed-off-by: Naushir Patuck <[email protected]>
  • Loading branch information
naushir committed Nov 20, 2023
1 parent dd744cb commit e385591
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions encoder/libav_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@

namespace {

void encoderOptionsH264M2M(VideoOptions const *options, AVCodecContext *codec)
void encoderOptionsGeneral(VideoOptions const *options, AVCodecContext *codec)
{
codec->pix_fmt = AV_PIX_FMT_DRM_PRIME;
codec->max_b_frames = 0;
codec->pix_fmt = AV_PIX_FMT_YUV420P;

if (options->bitrate)
codec->bit_rate = options->bitrate.bps();
}

void encoderOptionsLibx264(VideoOptions const *options, AVCodecContext *codec)
void encoderOptionsH264M2M(VideoOptions const *options, AVCodecContext *codec)
{
codec->pix_fmt = AV_PIX_FMT_YUV420P;
codec->pix_fmt = AV_PIX_FMT_DRM_PRIME;
codec->max_b_frames = 0;
}

void encoderOptionsLibx264(VideoOptions const *options, AVCodecContext *codec)
{
if (options->bitrate)
codec->bit_rate = options->bitrate.bps();

Expand Down Expand Up @@ -140,6 +143,9 @@ void LibAvEncoder::initVideoCodec(VideoOptions const *options, StreamInfo const
codec_ctx_[Video]->gop_size = options->intra ? options->intra
: (int)(options->framerate.value_or(DEFAULT_FRAMERATE));

// Apply general options.
encoderOptionsGeneral(options, codec_ctx_[Video]);

// Apply any codec specific options:
auto fn = optionsMap.find(options->libav_video_codec);
if (fn != optionsMap.end())
Expand Down

0 comments on commit e385591

Please sign in to comment.