summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-05-03 12:25:17 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-05-03 12:25:17 +0200
commit28d37f71607bd63f7f09f9125a3e243179ebf9af (patch)
treeb9271e31c8dc1164fe2f8247689e85a3c9176eba /doc/examples
parent20f47eb5741ce895a80dc775fffa08b9b99ffed1 (diff)
examples/decoding_encoding: fix encoding when all frames got buffered.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/decoding_encoding.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c
index 4b93b58fec..cb63294b14 100644
--- a/doc/examples/decoding_encoding.c
+++ b/doc/examples/decoding_encoding.c
@@ -215,6 +215,7 @@ static void video_encode_example(const char *filename, int codec_id)
FILE *f;
AVFrame *picture;
uint8_t *outbuf;
+ int had_output=0;
printf("Video encoding\n");
@@ -284,15 +285,17 @@ static void video_encode_example(const char *filename, int codec_id)
/* encode the image */
out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
+ had_output |= out_size;
printf("encoding frame %3d (size=%5d)\n", i, out_size);
fwrite(outbuf, 1, out_size, f);
}
/* get the delayed frames */
- for(; out_size; i++) {
+ for(; out_size || !had_output; i++) {
fflush(stdout);
out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
+ had_output |= out_size;
printf("write frame %3d (size=%5d)\n", i, out_size);
fwrite(outbuf, 1, out_size, f);
}