I am trying to scale a video from 1080p to 480p. However, whenever I am calling sws_scale_frame() function, I keep getting undefined reference. When I checked the header file, I found that the function signature is missing from the header file. I have installed libswscale using the command sudo apt install libswscale-dev. If this is not the right appoarch, can anyone help with how to get the function or alternative if this is deprecated?
P.S. My build options in VS Code are as follows: "-lavformat","-lavcodec","-lswscale","-lavutil", "-lm", "-lpthread"
EDIT: Version of libswscale-dev is 7:4.4.2-0ubuntu0.22.04.1 if needed.
libswscale-dev_4.4.2is actually too old, and doesn't yet supportsws_scale_frame().I think
sws_scale_frame()was added in FFmpeg version 5.0 (and version 4.4.2 applies FFmpeg version 4.4.2 or so).The following page has instructions for installing FFmpeg version 5.0 on Ubuntu.
What worked for me is (for upgrading
libswscale-dev):sudo apt install ppa-purgesudo add-apt-repository ppa:savoury1/ffmpeg5sudo apt install libswscale-devWe better also install FFmpeg 5:
sudo apt install ffmpegNow the file
/usr/include/x86_64-linux-gnu/libswscale/has declaration of the function:Note:
I tested with Ubuntu 18.04, and installing FFmpeg 5 was not working.