sunlubo / SwiftFFmpeg

A Swift wrapper for the FFmpeg API
Apache License 2.0
511 stars 83 forks source link

could you make an example on how to force aspect ratio #68

Closed wibed closed 1 year ago

wibed commented 1 year ago

it would be nice if we could have an example on how to force the existing aspect ratio. atm i am experience a crop after scale.

even better would be to expand such an example with a link to a collection of options.

wibed commented 1 year ago

from here: https://www.ffmpeg.org/doxygen/0.5/swscale-example_8c-source.html

i can deduce the settings necessary in swsContext

an example:

    let swsContext = SwsContext(
      srcWidth: oldWidth,
      srcHeight: oldHeight,
      srcPixelFormat: destinationFrame.pixelFormat,
      dstWidth: newWidth,
      dstHeight: newHeight,
      dstPixelFormat: destinationFrame.pixelFormat,
      flags: .bilinear)!