瀏覽代碼

Make the movie generation methods and program more versatile.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@4694 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 14 年之前
父節點
當前提交
2297613cd7
共有 3 個文件被更改,包括 38 次插入15 次删除
  1. +26
    -2
      examples/makemovie.c
  2. +3
    -2
      pipi/pipi.h
  3. +9
    -11
      pipi/sequence.c

+ 26
- 2
examples/makemovie.c 查看文件

@@ -22,7 +22,6 @@

#define WIDTH 1280
#define HEIGHT 720
#define FPS 30

int main(int argc, char *argv[])
{
@@ -30,12 +29,37 @@ int main(int argc, char *argv[])
pipi_image_t *image;
pipi_sequence_t *seq;
pipi_pixels_t *p;
int width, height, fps, par_num, par_den, bitrate;
int f;

width = 1280;
height = 720;
fps = 30;
par_num = 1;
par_den = 1;
bitrate = 16 * 1024 * 1024;

if(argc < 2)
{
fprintf(stderr, "usage: makemovie FILE [width [height [fps [par_num [par_den [bitrate]]]]]]>\n");
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)
return EXIT_FAILURE;



+ 3
- 2
pipi/pipi.h 查看文件

@@ -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_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 *);

#ifdef __cplusplus


+ 9
- 11
pipi/sequence.c 查看文件

@@ -54,12 +54,9 @@ typedef struct
ffmpeg_codec_t;
#endif

#define PAR_NUM 1
#define PAR_DEN 1
#define BITRATE (16 * 1024 * 1024)

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
static int initialised = 0;
@@ -104,18 +101,18 @@ pipi_sequence_t *pipi_open_sequence(char const *file,
if (!ff->stream)
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->width = width;
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_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.den = fps;
ff->cod_ctx->gop_size = fps * 3 / 4; /* empirical */
@@ -168,7 +165,8 @@ error:
#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
AVPacket packet;


Loading…
取消
儲存