Allow to compile without ffmpeg

This commit is contained in:
Kamil Trzcinski 2022-04-07 23:17:06 +02:00
parent 386ad37b40
commit b57ca77132
3 changed files with 14 additions and 1 deletions

View File

@ -4,7 +4,14 @@ HEADERS := $(wildcard **/*.h)
HTML := $(wildcard html/*.js html/*.html) HTML := $(wildcard html/*.js html/*.html)
CFLAGS := -Werror -g -I$(PWD) 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)) HTML_SRC = $(addsuffix .c,$(HTML))
OBJS = $(subst .c,.o,$(SRC) $(HTML_SRC)) OBJS = $(subst .c,.o,$(SRC) $(HTML_SRC))

View File

@ -16,9 +16,11 @@ http_method_t http_methods[] = {
{ "GET /?action=stream", http_stream }, { "GET /?action=stream", http_stream },
{ "GET /video?", http_video_html }, { "GET /video?", http_video_html },
{ "GET /video.h264?", http_h264_video }, { "GET /video.h264?", http_h264_video },
#ifdef USE_FFMPEG
{ "GET /video.mkv?", http_mkv_video }, { "GET /video.mkv?", http_mkv_video },
{ "GET /video.mp4?", http_mp4_video }, { "GET /video.mp4?", http_mp4_video },
{ "GET /jmuxer.min.js?", http_jmuxer_js }, { "GET /jmuxer.min.js?", http_jmuxer_js },
#endif // USE_FFMPEG
{ "GET /?", http_index }, { "GET /?", http_index },
{ } { }
}; };

View File

@ -1,3 +1,5 @@
#ifdef USE_FFMPEG
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -330,3 +332,5 @@ void http_mp4_video(http_worker_t *worker, FILE *stream)
{ {
http_ffmpeg_video(worker, stream, "video/mp4", "mp4"); http_ffmpeg_video(worker, stream, "video/mp4", "mp4");
} }
#endif // USE_FFMPEG