1 | /* |
---|
2 | * makemovie read image names from stdin and create a movie |
---|
3 | * Copyright (c) 2009 Sam Hocevar <sam@hocevar.net> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: makemovie.c 4765 2011-02-08 22:09:53Z sam $ |
---|
7 | * |
---|
8 | * This program is free software. It comes without any warranty, to |
---|
9 | * the extent permitted by applicable law. You can redistribute it |
---|
10 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
11 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
12 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
13 | */ |
---|
14 | |
---|
15 | #include "config.h" |
---|
16 | |
---|
17 | #include <stdlib.h> |
---|
18 | #include <stdio.h> |
---|
19 | #include <string.h> |
---|
20 | |
---|
21 | #include <pipi.h> |
---|
22 | |
---|
23 | #define WIDTH 1280 |
---|
24 | #define HEIGHT 720 |
---|
25 | |
---|
26 | int main(int argc, char *argv[]) |
---|
27 | { |
---|
28 | char file[1024]; |
---|
29 | pipi_image_t *image; |
---|
30 | pipi_sequence_t *seq; |
---|
31 | pipi_pixels_t *p; |
---|
32 | int width, height, fps, par_num, par_den, bitrate; |
---|
33 | int f; |
---|
34 | |
---|
35 | width = 1280; |
---|
36 | height = 720; |
---|
37 | fps = 30; |
---|
38 | par_num = 1; |
---|
39 | par_den = 1; |
---|
40 | bitrate = 16 * 1024 * 1024; |
---|
41 | |
---|
42 | if(argc < 2) |
---|
43 | { |
---|
44 | fprintf(stderr, "usage: makemovie FILE [width [height [fps [par_num [par_den [bitrate]]]]]]>\n"); |
---|
45 | return EXIT_FAILURE; |
---|
46 | } |
---|
47 | |
---|
48 | if (argc > 2) |
---|
49 | width = atoi(argv[2]); |
---|
50 | if (argc > 3) |
---|
51 | height = atoi(argv[3]); |
---|
52 | if (argc > 4) |
---|
53 | fps = atoi(argv[4]); |
---|
54 | if (argc > 5) |
---|
55 | par_num = atoi(argv[5]); |
---|
56 | if (argc > 6) |
---|
57 | par_den = atoi(argv[6]); |
---|
58 | if (argc > 7) |
---|
59 | bitrate = atoi(argv[7]); |
---|
60 | |
---|
61 | seq = pipi_open_sequence(argv[1], width, height, 0 /* YUV */, fps, |
---|
62 | par_num, par_den, bitrate); |
---|
63 | if(!seq) |
---|
64 | return EXIT_FAILURE; |
---|
65 | |
---|
66 | for(f = 0; ; f++) |
---|
67 | { |
---|
68 | uint8_t *start; |
---|
69 | int w = 0, h = 0; |
---|
70 | |
---|
71 | if(!fgets(file, sizeof(file), stdin)) |
---|
72 | break; |
---|
73 | file[strlen(file) - 1] = '\0'; |
---|
74 | |
---|
75 | image = pipi_load(file); |
---|
76 | if(!image) |
---|
77 | return EXIT_FAILURE; |
---|
78 | p = pipi_get_pixels(image, PIPI_PIXELS_RGBA_U8); |
---|
79 | start = (uint8_t *)p->pixels; |
---|
80 | pipi_feed_sequence(seq, start, p->w, p->h); |
---|
81 | pipi_free(image); |
---|
82 | |
---|
83 | fprintf(stderr, "frame %d\r", f); |
---|
84 | } |
---|
85 | |
---|
86 | fprintf(stderr, "\n"); |
---|
87 | |
---|
88 | pipi_close_sequence(seq); |
---|
89 | |
---|
90 | return EXIT_SUCCESS; |
---|
91 | } |
---|
92 | |
---|