blind

suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log | Files | Refs | README | LICENSE

commit 4a0bec23f06a4e119531fb8a62c07d346116c709
parent 55c37130e2747b4d4562c35462e0d9e40c5531c0
Author: Mattias Andrée <maandree@kth.se>
Date:   Sat, 14 Jan 2017 08:41:44 +0100

Fix blind-split and add example

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
Aexamples/.gitignore | 5+++++
Aexamples/split/Makefile | 39+++++++++++++++++++++++++++++++++++++++
Msrc/blind-cut.c | 2+-
Msrc/blind-split.c | 17+++++++++++------
4 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/examples/.gitignore b/examples/.gitignore @@ -0,0 +1,5 @@ +*.uivf +*.mp4 +*.mkv +*.avi +*.webm diff --git a/examples/split/Makefile 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 @@ -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 @@ -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))