git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@4694 92316355-f0b4-4df1-b90c-862c8a59935fmaster
| @@ -22,7 +22,6 @@ | |||||
| #define WIDTH 1280 | #define WIDTH 1280 | ||||
| #define HEIGHT 720 | #define HEIGHT 720 | ||||
| #define FPS 30 | |||||
| int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||
| { | { | ||||
| @@ -30,12 +29,37 @@ int main(int argc, char *argv[]) | |||||
| pipi_image_t *image; | pipi_image_t *image; | ||||
| pipi_sequence_t *seq; | pipi_sequence_t *seq; | ||||
| pipi_pixels_t *p; | pipi_pixels_t *p; | ||||
| int width, height, fps, par_num, par_den, bitrate; | |||||
| int f; | int f; | ||||
| width = 1280; | |||||
| height = 720; | |||||
| fps = 30; | |||||
| par_num = 1; | |||||
| par_den = 1; | |||||
| bitrate = 16 * 1024 * 1024; | |||||
| if(argc < 2) | if(argc < 2) | ||||
| { | |||||
| fprintf(stderr, "usage: makemovie FILE [width [height [fps [par_num [par_den [bitrate]]]]]]>\n"); | |||||
| return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
| } | |||||
| if (argc > 2) | |||||
| width = atoi(argv[2]); | |||||
| if (argc > 3) | |||||
| height = atoi(argv[3]); | |||||
| if (argc > 4) | |||||
| fps = atoi(argv[4]); | |||||
| if (argc > 5) | |||||
| par_num = atoi(argv[5]); | |||||
| if (argc > 6) | |||||
| par_den = atoi(argv[6]); | |||||
| if (argc > 7) | |||||
| bitrate = atoi(argv[7]); | |||||
| seq = pipi_open_sequence(argv[1], WIDTH, HEIGHT, FPS); | |||||
| seq = pipi_open_sequence(argv[1], width, height, fps, | |||||
| par_num, par_den, bitrate); | |||||
| if(!seq) | if(!seq) | ||||
| return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
| @@ -237,8 +237,9 @@ __extern int pipi_get_image_histogram(pipi_image_t *, pipi_histogram_t *, int); | |||||
| __extern int pipi_free_histogram(pipi_histogram_t*); | __extern int pipi_free_histogram(pipi_histogram_t*); | ||||
| __extern int pipi_render_histogram(pipi_image_t *, pipi_histogram_t*, int); | __extern int pipi_render_histogram(pipi_image_t *, pipi_histogram_t*, int); | ||||
| __extern pipi_sequence_t *pipi_open_sequence(char const *, int, int, int); | |||||
| __extern int pipi_feed_sequence(pipi_sequence_t *, uint8_t *, int, int); | |||||
| __extern pipi_sequence_t *pipi_open_sequence(char const *, int, int, int, | |||||
| int, int, int); | |||||
| __extern int pipi_feed_sequence(pipi_sequence_t *, uint8_t const *, int, int); | |||||
| __extern int pipi_close_sequence(pipi_sequence_t *); | __extern int pipi_close_sequence(pipi_sequence_t *); | ||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| @@ -54,12 +54,9 @@ typedef struct | |||||
| ffmpeg_codec_t; | ffmpeg_codec_t; | ||||
| #endif | #endif | ||||
| #define PAR_NUM 1 | |||||
| #define PAR_DEN 1 | |||||
| #define BITRATE (16 * 1024 * 1024) | |||||
| pipi_sequence_t *pipi_open_sequence(char const *file, | pipi_sequence_t *pipi_open_sequence(char const *file, | ||||
| int width, int height, int fps) | |||||
| int width, int height, int fps, | |||||
| int par_num, int par_den, int bitrate) | |||||
| { | { | ||||
| #if defined USE_FFMPEG | #if defined USE_FFMPEG | ||||
| static int initialised = 0; | static int initialised = 0; | ||||
| @@ -104,18 +101,18 @@ pipi_sequence_t *pipi_open_sequence(char const *file, | |||||
| if (!ff->stream) | if (!ff->stream) | ||||
| goto error; | goto error; | ||||
| ff->stream->sample_aspect_ratio.num = PAR_NUM; | |||||
| ff->stream->sample_aspect_ratio.den = PAR_DEN; | |||||
| ff->stream->sample_aspect_ratio.num = par_num; | |||||
| ff->stream->sample_aspect_ratio.den = par_den; | |||||
| ff->cod_ctx = ff->stream->codec; | ff->cod_ctx = ff->stream->codec; | ||||
| ff->cod_ctx->width = width; | ff->cod_ctx->width = width; | ||||
| ff->cod_ctx->height = height; | ff->cod_ctx->height = height; | ||||
| ff->cod_ctx->sample_aspect_ratio.num = PAR_NUM; | |||||
| ff->cod_ctx->sample_aspect_ratio.den = PAR_DEN; | |||||
| ff->cod_ctx->sample_aspect_ratio.num = par_num; | |||||
| ff->cod_ctx->sample_aspect_ratio.den = par_den; | |||||
| ff->cod_ctx->codec_id = ff->fmt_ctx->oformat->video_codec; | ff->cod_ctx->codec_id = ff->fmt_ctx->oformat->video_codec; | ||||
| ff->cod_ctx->codec_type = CODEC_TYPE_VIDEO; | ff->cod_ctx->codec_type = CODEC_TYPE_VIDEO; | ||||
| ff->cod_ctx->bit_rate = BITRATE; | |||||
| ff->cod_ctx->bit_rate = bitrate; | |||||
| ff->cod_ctx->time_base.num = 1; | ff->cod_ctx->time_base.num = 1; | ||||
| ff->cod_ctx->time_base.den = fps; | ff->cod_ctx->time_base.den = fps; | ||||
| ff->cod_ctx->gop_size = fps * 3 / 4; /* empirical */ | ff->cod_ctx->gop_size = fps * 3 / 4; /* empirical */ | ||||
| @@ -168,7 +165,8 @@ error: | |||||
| #endif | #endif | ||||
| } | } | ||||
| int pipi_feed_sequence(pipi_sequence_t *seq, uint8_t *buffer, int width, int height) | |||||
| int pipi_feed_sequence(pipi_sequence_t *seq, uint8_t const *buffer, | |||||
| int width, int height) | |||||
| { | { | ||||
| #if defined USE_FFMPEG | #if defined USE_FFMPEG | ||||
| AVPacket packet; | AVPacket packet; | ||||