blind

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

blind-cut.c (1044B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include "common.h"
      3 
      4 USAGE("start-point (end-point | 'end') file")
      5 
      6 int
      7 main(int argc, char *argv[])
      8 {
      9 	struct stream stream;
     10 	size_t start = 0, end = 0;
     11 	int to_end = 0;
     12 
     13 	UNOFLAGS(argc != 3);
     14 
     15 	if (!strcmp(argv[0], "end"))
     16 		eprintf("refusing to create video with zero frames\n");
     17 	else
     18 		start = etozu_arg("the start point", argv[0], 0, SIZE_MAX);
     19 
     20 	if (!strcmp(argv[1], "end"))
     21 		to_end = 1;
     22 	else
     23 		end = etozu_arg("the end point", argv[1], 0, SIZE_MAX);
     24 
     25 	eopen_stream(&stream, argv[2]);
     26 	if (to_end)
     27 		end = stream.frames;
     28 	else if (end > stream.frames)
     29 		eprintf("end point is after end of video\n");
     30 	if (start >= end)
     31 		eprintf("%s\n", start > end ?
     32 			"start point is after end point" :
     33 			"refusing to create video with zero frames");
     34 	stream.frames = end - start;
     35 	fprint_stream_head(stdout, &stream);
     36 	efflush(stdout, "<stdout>");
     37 
     38 	esend_frames(&stream, -1, start, NULL);
     39 	esend_frames(&stream, STDOUT_FILENO, stream.frames, "<stdout>");
     40 
     41 	close(stream.fd);
     42 	return 0;
     43 }