diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-01-14 08:41:44 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-01-14 08:41:44 +0100 |
| commit | 4a0bec23f06a4e119531fb8a62c07d346116c709 (patch) | |
| tree | 4e15bd8037011383f0f6dccaa4c7e60ad5a4c582 | |
| parent | Update todo (diff) | |
| download | blind-4a0bec23f06a4e119531fb8a62c07d346116c709.tar.gz blind-4a0bec23f06a4e119531fb8a62c07d346116c709.tar.bz2 blind-4a0bec23f06a4e119531fb8a62c07d346116c709.tar.xz | |
Fix blind-split and add example
Signed-off-by: Mattias Andrée <maandree@kth.se>
| -rw-r--r-- | examples/.gitignore | 5 | ||||
| -rw-r--r-- | examples/split/Makefile | 39 | ||||
| -rw-r--r-- | src/blind-cut.c | 2 | ||||
| -rw-r--r-- | src/blind-split.c | 17 |
4 files changed, 56 insertions, 7 deletions
diff --git a/examples/.gitignore b/examples/.gitignore new file mode 100644 index 0000000..9ad46d0 --- /dev/null +++ b/examples/.gitignore @@ -0,0 +1,5 @@ +*.uivf +*.mp4 +*.mkv +*.avi +*.webm diff --git a/examples/split/Makefile b/examples/split/Makefile new file mode 100644 index 0000000..9e434b1 --- /dev/null +++ b/examples/split/Makefile @@ -0,0 +1,39 @@ +INPUT_VIDEO = '<please select a video file as INPUT_VIDEO>' + +SHELL = bash +# We need Bash's process substitution operator >() +# because we want to convert the files back to a +# cooked format, because raw takes a serious amount +# of space. + +DRAFT = -d +# Useful for better performance when not working +# with colours or not caring about colours. + +FFMPEG_ARGS = -c:v libx264 -preset veryslow -crf 0 -pix_fmt yuv444p + +TEMPFILE = temp.uivf + +FRAME_1 = 10 +FRAME_2 = 20 +FRAME_3 = 30 +FRAME_4 = 40 +FRAME_5 = end + +1.mkv 2.mkv 3.mkv 4.mkv 5.mkv: $(TEMPFILE) + framerate=$$(ffprobe -v quiet -show_streams -select_streams v - < "$(INPUT_VIDEO)" | \ + grep '^r_frame_rate=' | cut -d = -f 2) && \ + ../../blind-split >(../../blind-to-video $(DRAFT) $${framerate} $(FFMPEG_ARGS) 1.mkv) $(FRAME_1) \ + >(../../blind-to-video $(DRAFT) $${framerate} $(FFMPEG_ARGS) 2.mkv) $(FRAME_2) \ + >(../../blind-to-video $(DRAFT) $${framerate} $(FFMPEG_ARGS) 3.mkv) $(FRAME_3) \ + >(../../blind-to-video $(DRAFT) $${framerate} $(FFMPEG_ARGS) 4.mkv) $(FRAME_4) \ + >(../../blind-to-video $(DRAFT) $${framerate} $(FFMPEG_ARGS) 5.mkv) $(FRAME_5) \ + < $(TEMPFILE) + +$(TEMPFILE): $(INPUT_VIDEO) + ../../blind-from-video $(DRAFT) $(INPUT_VIDEO) $(TEMPFILE) + +clean: + -rm 1.mkv 2.mkv 3.mkv 4.mkv 5.mkv $(TEMPFILE) + +.PHONY: clean diff --git a/src/blind-cut.c b/src/blind-cut.c index e2a7fa6..6112120 100644 --- a/src/blind-cut.c +++ b/src/blind-cut.c @@ -43,7 +43,7 @@ main(int argc, char *argv[]) efflush(stdout, "<stdout>"); echeck_frame_size(stream.width, stream.height, stream.pixel_size, 0, stream.file); frame_size = stream.width * stream.height * stream.pixel_size; - if (stream.frames > SSIZE_MAX / frame_size) + if (stream.frames > (size_t)SSIZE_MAX / frame_size) eprintf("%s: video is too large\n", stream.file); if (start >= end) diff --git a/src/blind-split.c b/src/blind-split.c index ff6ce38..6b06da5 100644 --- a/src/blind-split.c +++ b/src/blind-split.c @@ -26,7 +26,7 @@ main(int argc, char *argv[]) einit_stream(&stream); echeck_frame_size(stream.width, stream.height, stream.pixel_size, 0, stream.file); frame_size = stream.width * stream.height * stream.pixel_size; - if (stream.frames > SSIZE_MAX / frame_size) + if (stream.frames > (size_t)SSIZE_MAX / frame_size) eprintf("%s: video is too large\n", stream.file); parts = (size_t)argc / 2; @@ -55,12 +55,17 @@ main(int argc, char *argv[]) efflush(fp, argv[i * 2]); for (end = ends[i] * frame_size; ptr < end; ptr += n) { - if (stream.ptr == sizeof(stream.buf)) - n = stream.ptr < end - ptr ? stream.ptr : end - ptr; - else if (!(n = eread_stream(&stream, end - ptr))) + n = end - ptr; + if (stream.ptr) { + n = stream.ptr < n ? stream.ptr : n; + ewriteall(fd, stream.buf, n, argv[i * 2]); + memmove(stream.buf, stream.buf + n, stream.ptr -= n); + } else if ((n = eread_stream(&stream, n))) { + ewriteall(fd, stream.buf, n, argv[i * 2]); + stream.ptr = 0; + } else { eprintf("%s: file is shorter than expected\n", stream.file); - ewriteall(STDOUT_FILENO, stream.buf, n, "<stdout>"); - memmove(stream.buf, stream.buf + n, stream.ptr -= n); + } } if (fclose(fp)) |
