Skip to content
Snippets Groups Projects
Commit db6c3ddf authored by Philippe Gorley's avatar Philippe Gorley Committed by Philippe Gorley
Browse files

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
parent e1436a12
No related branches found
No related tags found
No related merge requests found
...@@ -71,6 +71,10 @@ MediaEncoder::~MediaEncoder() ...@@ -71,6 +71,10 @@ MediaEncoder::~MediaEncoder()
void MediaEncoder::setDeviceOptions(const DeviceParams& args) void MediaEncoder::setDeviceOptions(const DeviceParams& args)
{ {
device_ = 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) if (device_.width)
av_dict_set(&options_, "width", ring::to_string(device_.width).c_str(), 0); av_dict_set(&options_, "width", ring::to_string(device_.width).c_str(), 0);
if (device_.height) if (device_.height)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment