History

examples/decoding_encoding: fix encoding when all frames got buffered.

Michael Niedermayer committed 14 years ago

Commit 28d37f71 parent 20f47eb1 file · +4 −1Browse files

Showing the changes to doc/examples/decoding_encoding.c (1 of 1 file). Show all

Unified · Split

doc/examples/decoding_encoding.c+4−1
@@ -215,6 +215,7 @@ static void video_encode_example(const char *filename, int codec_id) · 214 unmodified lines
215215 FILE *f;
216216 AVFrame *picture;
217217 uint8_t *outbuf;
218+ int had_output=0;
218219
219220 printf("Video encoding\n");
220221
@@ -284,15 +285,17 @@ static void video_encode_example(const char *filename, int codec_id) · 63 unmodified lines
284285
285286 /* encode the image */
286287 out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
288+ had_output |= out_size;
287289 printf("encoding frame %3d (size=%5d)\n", i, out_size);
288290 fwrite(outbuf, 1, out_size, f);
289291 }
290292
291293 /* get the delayed frames */
292− for(; out_size; i++) {
294+ for(; out_size || !had_output; i++) {
293295 fflush(stdout);
294296
295297 out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
298+ had_output |= out_size;
296299 printf("write frame %3d (size=%5d)\n", i, out_size);
297300 fwrite(outbuf, 1, out_size, f);
298301 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t