ffmpeg uses a "filtergraph" to apply filters like scaling, cropping etc.
If you look into the filtering video example you will see how filters are
applied programmatically. If you can integrate that example into your code,
then all you have to do is to change the string - filter_descr - to have
the video scaled to your desired resolution.
Filters are defined the same way as with the stand-alone program. See
the documentation for more details.