diff --git a/Makefile b/Makefile index c9f0abb..f3c0be5 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ RM := rm -f -CC := gcc CFLAGS := -O3 -Wall -Isrc -I/usr/include/ffmpeg LIBS := -lavformat -lavutil -lavcodec LDFLAGS := diff --git a/src/stat.c b/src/stat.c index f654906..535280a 100644 --- a/src/stat.c +++ b/src/stat.c @@ -30,6 +30,11 @@ int main(int argc, char *argv[]) return -1; } + if (avformat_find_stream_info(format, NULL) < 0) { + printf("Couldn't read file \n"); + return -1; + } + if (!mediatools_validate_video(format)) { // Error is printed by validation function return -1; diff --git a/src/validation.c b/src/validation.c index d1a5e91..7b02e16 100644 --- a/src/validation.c +++ b/src/validation.c @@ -62,7 +62,7 @@ int mediatools_validate_video(AVFormatContext *format) ; } } - } else if (strstr(iformat->name, "gif")) { + } else if (strcmp(iformat->name, "gif") == 0) { switch (vpar->codec_id) { default: printf("Bad video codec for GIF container (must be GIF)\n"); @@ -70,18 +70,43 @@ int mediatools_validate_video(AVFormatContext *format) case AV_CODEC_ID_GIF: ; } + } else if (strcmp(iformat->name, "image2") == 0) { + switch (vpar->codec_id) { + default: + printf("Bad video codec for image2 container (must be JPEG)\n"); + return false; + case AV_CODEC_ID_MJPEG: + ; + } + } else if (strcmp(iformat->name, "png_pipe") == 0 || strcmp(iformat->name, "apng") == 0) { + switch (vpar->codec_id) { + default: + printf("Bad video codec for PNG container (must be PNG)\n"); + return false; + case AV_CODEC_ID_PNG: + case AV_CODEC_ID_APNG: + ; + } + } else if (strcmp(iformat->name, "svg_pipe") == 0) { + switch (vpar->codec_id) { + default: + printf("Bad video codec for SVG container (must be SVG)\n"); + return false; + case AV_CODEC_ID_SVG: + ; + } } else { printf("Unknown input format\n"); return false; } - if (vpar->width < 2 || vpar->width > 4096) { - printf("Bad width %d (must be 2..4096)\n", vpar->width); + if (vpar->width < 1 || vpar->width > 4096) { + printf("Bad width %d (must be 1..4096)\n", vpar->width); return false; } - if (vpar->height < 2 || vpar->height > 4096) { - printf("Bad height %d (must be 2..4096)\n", vpar->height); + if (vpar->height < 1 || vpar->height > 4096) { + printf("Bad height %d (must be 1..4096)\n", vpar->height); return false; }