blind-next-frame.c - blind - suckless command-line video editing utility
 (HTM) git clone git://git.suckless.org/blind
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       blind-next-frame.c (1158B)
       ---
            1 /* See LICENSE file for copyright and license details. */
            2 #include "common.h"
            3 
            4 NUSAGE(2, "[-f frames] width height pixel-format ...")
            5 
            6 int
            7 main(int argc, char *argv[])
            8 {
            9         struct stream stream = { .frames = 1, .fd = STDIN_FILENO, .file = "<stdin>" };
           10         size_t n;
           11         int i;
           12         char *p;
           13 
           14         ARGBEGIN {
           15         case 'f':
           16                 stream.frames = entozu_flag(2, 'f', UARGF(), 1, SIZE_MAX);
           17                 break;
           18         default:
           19                 usage();
           20         } ARGEND;
           21 
           22         if (argc < 3)
           23                 usage();
           24 
           25         stream.pixfmt[0] = '\0';
           26         stream.width  = entozu_arg(2, "the width",  argv[0], 1, SIZE_MAX);
           27         stream.height = entozu_arg(2, "the height", argv[1], 1, SIZE_MAX);
           28         argv += 2, argc -= 2;
           29 
           30         n = (size_t)argc - 1;
           31         for (i = 0; i < argc; i++)
           32                 n += strlen(argv[i]);
           33         if (n < sizeof(stream.pixfmt)) {
           34                 p = stpcpy(stream.pixfmt, argv[0]);
           35                 for (i = 1; i < argc; i++) {
           36                         *p++ = ' ';
           37                         p = stpcpy(p, argv[i]);
           38                 }
           39         }
           40         enset_pixel_format(2, &stream, NULL);
           41 
           42         fprint_stream_head(stdout, &stream);
           43         enfflush(2, stdout, "<stdout>");
           44 
           45         n = ensend_frames(2, &stream, STDOUT_FILENO, stream.frames, "<stdout>");
           46         if (!n)
           47                 return 1;
           48         else if (n < stream.frames)
           49                 enprintf(2, "%s: is shorter than expected\n", stream.file);
           50         return 0;
           51 }