Skip to content

Commit

Permalink
Fixed: Video Scaling doesn't work with specific video size.
Browse files Browse the repository at this point in the history
Fixed: Issue where video can't be compressed using H.264 codec (mp4 or
mkv presets) when its size (width or height) is not divisible by 2
(append a lot when the user try to scale a video) (github issue #2).
  • Loading branch information
Tichau committed Apr 19, 2016
1 parent e0beb08 commit 946b6fc
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ private static string ComputeTransformArgs(ConversionPreset conversionPreset)
{
float scaleFactor = conversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.VideoScale);
string scaleArgs = string.Empty;
if (Math.Abs(scaleFactor - 1f) >= 0.005f)

if (conversionPreset.OutputType == OutputType.Mkv || conversionPreset.OutputType == OutputType.Mp4)
{
// This presets use h264 codec, the size of the video need to be divisible by 2.
scaleArgs = string.Format("scale=trunc(iw*{0}/2)*2:trunc(ih*{0}/2)*2", scaleFactor.ToString("#.##", CultureInfo.InvariantCulture));
}
else if (Math.Abs(scaleFactor - 1f) >= 0.005f)
{
scaleArgs = string.Format("scale=iw*{0}:ih*{0}", scaleFactor.ToString("#.##", CultureInfo.InvariantCulture));
}
Expand Down

0 comments on commit 946b6fc

Please sign in to comment.