From db6c3ddf9c832f5a7a5740042095f30e046c6be3 Mon Sep 17 00:00:00 2001 From: philippegorley <philippe.gorley@savoirfairelinux.com> Date: Mon, 17 Dec 2018 16:13:41 -0500 Subject: [PATCH] encoder: make resolution even An even width/height is required by at least x264. This is especially for image and gif streaming, as video usually already has an even width/height. Change-Id: Ie660d8eb61dca48641cba89dd02e187481e3a127 --- src/media/media_encoder.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/media/media_encoder.cpp b/src/media/media_encoder.cpp index 80f97f5b07..9b17db2596 100644 --- a/src/media/media_encoder.cpp +++ b/src/media/media_encoder.cpp @@ -71,6 +71,10 @@ MediaEncoder::~MediaEncoder() void MediaEncoder::setDeviceOptions(const DeviceParams& args) { device_ = args; + // Make sure width and height are even (required by x264) + // This is especially for image/gif streaming, as video files and cameras usually have even resolutions + device_.width -= device_.width % 2; + device_.height -= device_.height % 2; if (device_.width) av_dict_set(&options_, "width", ring::to_string(device_.width).c_str(), 0); if (device_.height) -- GitLab