Skip to content

Instantly share code, notes, and snippets.

@dreamcat4
Last active August 29, 2015 14:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dreamcat4/3250eef898a50b68dcc0 to your computer and use it in GitHub Desktop.
libav_or_ffmpeg()
{
compile_check_libav_or_ffmpeg()
{
_CFLAGS=$(pkg-config --cflags libavcodec)
CC=cc
${CC} -x c $_CFLAGS - -o /dev/null <<- EOF
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
int main()
{
#if LIBAVCODEC_VERSION_MICRO >= 100
#error ffmpeg
#elif LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 47, 100)
(void)CODEC_ID_G2M; /* not declared, it is libav */
#error ffmpeg
#else
#error libav
#endif
}
EOF
}
cc_output=$(compile_check_libav_or_ffmpeg 2>&1)
if [ "$(echo "$cc_output" | grep "error: libavcodec/avcodec.h")" ]; then
exit 1 # libavcodec header file not found
elif [ "$(echo "$cc_output" | grep "CODEC_ID_G2M")" ]; then
echo libav
else
#echo "$cc_output"
echo "$cc_output" | grep -o "ffmpeg\|libav"
fi
}
libav_or_ffmpeg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment