Skip to content

Instantly share code, notes, and snippets.

@csparker247
Last active August 29, 2015 13:56
Show Gist options
  • Save csparker247/9004231 to your computer and use it in GitHub Desktop.
Save csparker247/9004231 to your computer and use it in GitHub Desktop.
ffmpeg - scale within limits
TARGET_WIDTH="1920"
TARGET_HEIGHT="1080"
TARGET_DAR="16/9"
ffmpeg -i "input.mov" -vf \
"scale=iw*sar:ih,
scale=
'w=if(lt(dar, $TARGET_DAR), trunc(oh*a/2)*2, min($TARGET_WIDTH,ceil(iw/2)*2)):
h=if(gte(dar, $TARGET_DAR), trunc(ow/a/2)*2, min($TARGET_HEIGHT,ceil(ih/2)*2))',
setsar=1" \
output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment