Changeset 4694


Ignore:
Timestamp:
Oct 16, 2010, 11:53:01 PM (9 years ago)
Author:
Sam Hocevar
Message:

Make the movie generation methods and program more versatile.

Location:
libpipi/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/examples/makemovie.c

    r3627 r4694  
    2323#define WIDTH 1280
    2424#define HEIGHT 720
    25 #define FPS 30
    2625
    2726int main(int argc, char *argv[])
     
    3130    pipi_sequence_t *seq;
    3231    pipi_pixels_t *p;
     32    int width, height, fps, par_num, par_den, bitrate;
    3333    int f;
    3434
     35    width = 1280;
     36    height = 720;
     37    fps = 30;
     38    par_num = 1;
     39    par_den = 1;
     40    bitrate = 16 * 1024 * 1024;
     41
    3542    if(argc < 2)
     43    {
     44        fprintf(stderr, "usage: makemovie FILE [width [height [fps [par_num [par_den [bitrate]]]]]]>\n");
    3645        return EXIT_FAILURE;
     46    }
    3747
    38     seq = pipi_open_sequence(argv[1], WIDTH, HEIGHT, FPS);
     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, fps,
     62                             par_num, par_den, bitrate);
    3963    if(!seq)
    4064        return EXIT_FAILURE;
  • libpipi/trunk/pipi/pipi.h

    r3630 r4694  
    238238__extern int pipi_render_histogram(pipi_image_t *, pipi_histogram_t*, int);
    239239
    240 __extern pipi_sequence_t *pipi_open_sequence(char const *, int, int, int);
    241 __extern int pipi_feed_sequence(pipi_sequence_t *, uint8_t *, int, int);
     240__extern pipi_sequence_t *pipi_open_sequence(char const *, int, int, int,
     241                                             int, int, int);
     242__extern int pipi_feed_sequence(pipi_sequence_t *, uint8_t const *, int, int);
    242243__extern int pipi_close_sequence(pipi_sequence_t *);
    243244
  • libpipi/trunk/pipi/sequence.c

    r3630 r4694  
    5555#endif
    5656
    57 #define PAR_NUM 1
    58 #define PAR_DEN 1
    59 #define BITRATE (16 * 1024 * 1024)
    60 
    6157pipi_sequence_t *pipi_open_sequence(char const *file,
    62                                     int width, int height, int fps)
     58                                    int width, int height, int fps,
     59                                    int par_num, int par_den, int bitrate)
    6360{
    6461#if defined USE_FFMPEG
     
    105102        goto error;
    106103
    107     ff->stream->sample_aspect_ratio.num = PAR_NUM;
    108     ff->stream->sample_aspect_ratio.den = PAR_DEN;
     104    ff->stream->sample_aspect_ratio.num = par_num;
     105    ff->stream->sample_aspect_ratio.den = par_den;
    109106
    110107    ff->cod_ctx = ff->stream->codec;
     
    112109    ff->cod_ctx->width = width;
    113110    ff->cod_ctx->height = height;
    114     ff->cod_ctx->sample_aspect_ratio.num = PAR_NUM;
    115     ff->cod_ctx->sample_aspect_ratio.den = PAR_DEN;
     111    ff->cod_ctx->sample_aspect_ratio.num = par_num;
     112    ff->cod_ctx->sample_aspect_ratio.den = par_den;
    116113    ff->cod_ctx->codec_id = ff->fmt_ctx->oformat->video_codec;
    117114    ff->cod_ctx->codec_type = CODEC_TYPE_VIDEO;
    118     ff->cod_ctx->bit_rate = BITRATE;
     115    ff->cod_ctx->bit_rate = bitrate;
    119116    ff->cod_ctx->time_base.num = 1;
    120117    ff->cod_ctx->time_base.den = fps;
     
    169166}
    170167
    171 int pipi_feed_sequence(pipi_sequence_t *seq, uint8_t *buffer, int width, int height)
     168int pipi_feed_sequence(pipi_sequence_t *seq, uint8_t const *buffer,
     169                       int width, int height)
    172170{
    173171#if defined USE_FFMPEG
Note: See TracChangeset for help on using the changeset viewer.