From 4125cc7cee7817ec5c7e2e0328011f3e234a4b46 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 14 Jan 2017 05:27:50 +0100 Subject: Fix blind-stack and blind-concate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-concat.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/blind-concat.c') diff --git a/src/blind-concat.c b/src/blind-concat.c index e8ed00d..d789a5a 100644 --- a/src/blind-concat.c +++ b/src/blind-concat.c @@ -34,10 +34,10 @@ concat_to_stdout(int argc, char *argv[]) fprint_stream_head(stdout, streams); efflush(stdout, ""); - for (; argc--; streams++) { - for (; eread_stream(streams, SIZE_MAX); streams->ptr = 0) - ewriteall(STDOUT_FILENO, streams->buf, streams->ptr, ""); - close(streams->fd); + for (i = 0; i < argc; i++) { + for (; eread_stream(streams + i, SIZE_MAX); streams[i].ptr = 0) + ewriteall(STDOUT_FILENO, streams[i].buf, streams[i].ptr, ""); + close(streams[i].fd); } free(streams); @@ -47,7 +47,7 @@ static void concat_to_file(int argc, char *argv[], char *output_file) { struct stream stream, refstream; - int first = 0; + int first = 1; int fd = eopen(output_file, O_RDWR | O_CREAT | O_TRUNC, 0666); char head[STREAM_HEAD_MAX]; ssize_t headlen, size = 0; @@ -59,7 +59,8 @@ concat_to_file(int argc, char *argv[], char *output_file) einit_stream(&stream); if (first) { - stream = refstream; + refstream = stream; + first = 1; } else { if (refstream.frames > SIZE_MAX - stream.frames) eprintf("resulting video is too long\n"); @@ -68,7 +69,7 @@ concat_to_file(int argc, char *argv[], char *output_file) } for (; eread_stream(&stream, SIZE_MAX); stream.ptr = 0) { - ewriteall(STDOUT_FILENO, stream.buf, stream.ptr, ""); + ewriteall(fd, stream.buf, stream.ptr, output_file); size += stream.ptr; } close(stream.fd); -- cgit v1.2.3-70-g09d2