From b57ca77132eba48b2ec275fcc3199dc34c395a74 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 7 Apr 2022 23:17:06 +0200 Subject: [PATCH] Allow to compile without ffmpeg --- Makefile | 9 ++++++++- cmd/main.c | 2 ++ http/http_ffmpeg.c | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a4e3e99..aa1905b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,14 @@ HEADERS := $(wildcard **/*.h) HTML := $(wildcard html/*.js html/*.html) CFLAGS := -Werror -g -I$(PWD) -LDLIBS := -lpthread -lavcodec -lavformat -lavutil +LDLIBS := -lpthread + +USE_FFMPEG ?= $(shell pkg-config libavutil libavformat libavcodec && echo 1) + +ifeq (1,$(USE_FFMPEG)) +CFLAGS += -DUSE_FFMPEG +LDLIBS += -lavcodec -lavformat -lavutil +endif HTML_SRC = $(addsuffix .c,$(HTML)) OBJS = $(subst .c,.o,$(SRC) $(HTML_SRC)) diff --git a/cmd/main.c b/cmd/main.c index 73cab67..53ec9b3 100644 --- a/cmd/main.c +++ b/cmd/main.c @@ -16,9 +16,11 @@ http_method_t http_methods[] = { { "GET /?action=stream", http_stream }, { "GET /video?", http_video_html }, { "GET /video.h264?", http_h264_video }, +#ifdef USE_FFMPEG { "GET /video.mkv?", http_mkv_video }, { "GET /video.mp4?", http_mp4_video }, { "GET /jmuxer.min.js?", http_jmuxer_js }, +#endif // USE_FFMPEG { "GET /?", http_index }, { } }; diff --git a/http/http_ffmpeg.c b/http/http_ffmpeg.c index 48e7a74..7811380 100644 --- a/http/http_ffmpeg.c +++ b/http/http_ffmpeg.c @@ -1,3 +1,5 @@ +#ifdef USE_FFMPEG + #include #include @@ -330,3 +332,5 @@ void http_mp4_video(http_worker_t *worker, FILE *stream) { http_ffmpeg_video(worker, stream, "video/mp4", "mp4"); } + +#endif // USE_FFMPEG