examples/decoding_encoding: fix encoding when all frames got buffered.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
20f47eb574
commit
28d37f7160
@ -215,6 +215,7 @@ static void video_encode_example(const char *filename, int codec_id)
|
|||||||
FILE *f;
|
FILE *f;
|
||||||
AVFrame *picture;
|
AVFrame *picture;
|
||||||
uint8_t *outbuf;
|
uint8_t *outbuf;
|
||||||
|
int had_output=0;
|
||||||
|
|
||||||
printf("Video encoding\n");
|
printf("Video encoding\n");
|
||||||
|
|
||||||
@ -284,15 +285,17 @@ static void video_encode_example(const char *filename, int codec_id)
|
|||||||
|
|
||||||
/* encode the image */
|
/* encode the image */
|
||||||
out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
|
out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
|
||||||
|
had_output |= out_size;
|
||||||
printf("encoding frame %3d (size=%5d)\n", i, out_size);
|
printf("encoding frame %3d (size=%5d)\n", i, out_size);
|
||||||
fwrite(outbuf, 1, out_size, f);
|
fwrite(outbuf, 1, out_size, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the delayed frames */
|
/* get the delayed frames */
|
||||||
for(; out_size; i++) {
|
for(; out_size || !had_output; i++) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
|
out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
|
||||||
|
had_output |= out_size;
|
||||||
printf("write frame %3d (size=%5d)\n", i, out_size);
|
printf("write frame %3d (size=%5d)\n", i, out_size);
|
||||||
fwrite(outbuf, 1, out_size, f);
|
fwrite(outbuf, 1, out_size, f);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user