diff --git a/media/ffvpx/libavcodec/moz.build b/media/ffvpx/libavcodec/moz.build
index 61d9962a71..d028ec9d70 100644
--- a/media/ffvpx/libavcodec/moz.build
+++ b/media/ffvpx/libavcodec/moz.build
@@ -109,10 +109,14 @@ if not CONFIG['MOZ_FFVPX_AUDIOONLY']:
         'vp9recon.c',
         'vpx_rac.c',
     ]
-    USE_LIBS += [
-        'dav1d',
-        'media_libdav1d_asm',
-    ]
+    if CONFIG["MOZ_SYSTEM_AV1"]:
+      CFLAGS += CONFIG['MOZ_SYSTEM_LIBDAV1D_CFLAGS']
+      OS_LIBS += CONFIG['MOZ_SYSTEM_LIBDAV1D_LIBS']
+    else:
+      USE_LIBS += [
+          'dav1d',
+          'media_libdav1d_asm',
+      ]
     if CONFIG['MOZ_WAYLAND']:
         LOCAL_INCLUDES += ['/media/mozva']
         SOURCES += [
