Skip to content

Commit

Permalink
bugfix mp4 more robust against odd dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed May 10, 2019
1 parent 57e243a commit 92ccf6e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,23 @@ ${inject.body || ''}

if (isMp4) {
ffmpegP = new Promise((resolve, reject) => {
let scale = `scale=${width}:-2`

if (width % 2 !== 0) {
if (height % 2 !== 0) {
scale = `scale=-2:${height}`
} else {
scale = `scale=${width + 1}:-2`
}
}

const ffmpegArgs = [
'-v', 'error',
'-stats',
'-hide_banner',
'-y',
'-f', 'image2pipe', '-c:v', 'png', '-r', fps, '-i', '-',
'-vf', `scale=${width}:-2`,
'-vf', scale,
'-c:v', 'libx264',
'-profile:v', 'main',
'-preset', 'medium',
Expand Down

0 comments on commit 92ccf6e

Please sign in to comment.