Skip to content
Snippets Groups Projects
Commit 8c56fd79 authored by Eloi Bail's avatar Eloi Bail Committed by Guillaume Roguez
Browse files

daemon: enable H263 encoder

H263 version 1 allows a limited range of resolutions outdated compared
to recent camera capabilities. It was thus nearly impossible
to use it on Ring.

This patchset forces encoding of H263+ which supports all resolutions
multiple of 4 from 4x4 to 2048x1152.
On Libav we see video artifacts if multithread is enabled
on encoder side. A workaround deals with forcing h263 encoder
to monothread.

See https://bugzilla.libav.org/show_bug.cgi?id=912

Tuleap: #138
Change-Id: I7121e182fa13139d28db010e2ed0de573c616de7
parent 2074c7fb
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,7 @@ FFMPEGCONF += \ ...@@ -54,6 +54,7 @@ FFMPEGCONF += \
--enable-encoder=libvpx_vp8 \ --enable-encoder=libvpx_vp8 \
--enable-decoder=vp8 \ --enable-decoder=vp8 \
--enable-encoder=h263 \ --enable-encoder=h263 \
--enable-encoder=h263p \
--enable-decoder=h263 \ --enable-decoder=h263 \
--enable-encoder=mjpeg \ --enable-encoder=mjpeg \
--enable-decoder=mjpeg \ --enable-decoder=mjpeg \
......
...@@ -52,6 +52,7 @@ LIBAVCONF += \ ...@@ -52,6 +52,7 @@ LIBAVCONF += \
--enable-decoder=mpeg4 \ --enable-decoder=mpeg4 \
--enable-encoder=h263 \ --enable-encoder=h263 \
--enable-decoder=h263 \ --enable-decoder=h263 \
--enable-encoder=h263p \
--enable-encoder=libspeex \ --enable-encoder=libspeex \
--enable-decoder=libspeex --enable-decoder=libspeex
......
...@@ -134,6 +134,8 @@ AccountCodecInfo::AccountCodecInfo(const SystemCodecInfo& sysCodecInfo) ...@@ -134,6 +134,8 @@ AccountCodecInfo::AccountCodecInfo(const SystemCodecInfo& sysCodecInfo)
{ {
if (sysCodecInfo.minQuality != SystemCodecInfo::DEFAULT_NO_QUALITY) if (sysCodecInfo.minQuality != SystemCodecInfo::DEFAULT_NO_QUALITY)
quality = SystemCodecInfo::DEFAULT_CODEC_QUALITY; quality = SystemCodecInfo::DEFAULT_CODEC_QUALITY;
else
quality = SystemCodecInfo::DEFAULT_NO_QUALITY;
} }
AccountCodecInfo::~AccountCodecInfo() AccountCodecInfo::~AccountCodecInfo()
......
...@@ -134,6 +134,12 @@ MediaEncoder::openOutput(const char *filename, ...@@ -134,6 +134,12 @@ MediaEncoder::openOutput(const char *filename,
outputCtx_->filename[sizeof(outputCtx_->filename) - 1] = '\0'; outputCtx_->filename[sizeof(outputCtx_->filename) - 1] = '\0';
/* find the video encoder */ /* find the video encoder */
if (args.codec->systemCodecInfo.avcodecId == AV_CODEC_ID_H263)
// For H263 encoding, we force the use of AV_CODEC_ID_H263P (H263-1998)
// H263-1998 can manage all frame sizes while H263 don't
// AV_CODEC_ID_H263 decoder will be used for decoding
outputEncoder_ = avcodec_find_encoder(AV_CODEC_ID_H263P);
else
outputEncoder_ = avcodec_find_encoder((AVCodecID)args.codec->systemCodecInfo.avcodecId); outputEncoder_ = avcodec_find_encoder((AVCodecID)args.codec->systemCodecInfo.avcodecId);
if (!outputEncoder_) { if (!outputEncoder_) {
RING_ERR("Encoder \"%s\" not found!", args.codec->systemCodecInfo.name.c_str()); RING_ERR("Encoder \"%s\" not found!", args.codec->systemCodecInfo.name.c_str());
...@@ -192,6 +198,14 @@ MediaEncoder::openOutput(const char *filename, ...@@ -192,6 +198,14 @@ MediaEncoder::openOutput(const char *filename,
encoderCtx_->rc_buffer_size = maxBitrate; encoderCtx_->rc_buffer_size = maxBitrate;
encoderCtx_->bit_rate = encoderCtx_->rc_min_rate = encoderCtx_->rc_max_rate = maxBitrate; encoderCtx_->bit_rate = encoderCtx_->rc_min_rate = encoderCtx_->rc_max_rate = maxBitrate;
RING_DBG("Using Max bitrate %d", maxBitrate); RING_DBG("Using Max bitrate %d", maxBitrate);
} else if (args.codec->systemCodecInfo.avcodecId == AV_CODEC_ID_H263) {
encoderCtx_->bit_rate = encoderCtx_->rc_max_rate = maxBitrate;
encoderCtx_->rc_buffer_size = maxBitrate;
// on libav there are video artifcats if multithreading is enabled
// see https://bugzilla.libav.org/show_bug.cgi?id=912
// TODO: this is a workaround !
encoderCtx_->thread_count = 1;
RING_DBG("Using Max bitrate %d", maxBitrate);
} }
int ret; int ret;
......
...@@ -75,7 +75,7 @@ SystemCodecContainer::initCodecConfig() ...@@ -75,7 +75,7 @@ SystemCodecContainer::initCodecConfig()
DEFAULT_VIDEO_BITRATE), DEFAULT_VIDEO_BITRATE),
std::make_shared<SystemVideoCodecInfo>(AV_CODEC_ID_H263, std::make_shared<SystemVideoCodecInfo>(AV_CODEC_ID_H263,
"H263", "h263", "H263-1998", "h263",
CODEC_ENCODER_DECODER, CODEC_ENCODER_DECODER,
DEFAULT_VIDEO_BITRATE), DEFAULT_VIDEO_BITRATE),
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment