diff --git a/ffmpeg.c b/ffmpeg.c
index 04fc9c99fd13963979725a049c69af6b69496718..57584b9462e38a45776c57d4436b05d1a65d3a65 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -31,6 +31,9 @@
 #include <time.h>
 #include <ctype.h>
 
+#if !defined(INFINITY) && defined(HUGE_VAL)
+#define INFINITY HUGE_VAL
+#endif
 
 #define MAXINT64 INT64_C(0x7fffffffffffffff)