Showing the changes to doc/examples/decoding_encoding.c (1 of 1 file). Show all
Unified · Split
| @@ -215,6 +215,7 @@ static void video_encode_example(const char *filename, int codec_id) · 214 unmodified lines | ||
| 215 | 215 | FILE *f; |
| 216 | 216 | AVFrame *picture; |
| 217 | 217 | uint8_t *outbuf; |
| 218 | + int had_output=0; | |
| 218 | 219 | |
| 219 | 220 | printf("Video encoding\n"); |
| 220 | 221 | |
| @@ -284,15 +285,17 @@ static void video_encode_example(const char *filename, int codec_id) · 63 unmodified lines | ||
| 284 | 285 | |
| 285 | 286 | /* encode the image */ |
| 286 | 287 | out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture); |
| 288 | + had_output |= out_size; | |
| 287 | 289 | printf("encoding frame %3d (size=%5d)\n", i, out_size); |
| 288 | 290 | fwrite(outbuf, 1, out_size, f); |
| 289 | 291 | } |
| 290 | 292 | |
| 291 | 293 | /* get the delayed frames */ |
| 292 | − for(; out_size; i++) { | |
| 294 | + for(; out_size || !had_output; i++) { | |
| 293 | 295 | fflush(stdout); |
| 294 | 296 | |
| 295 | 297 | out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL); |
| 298 | + had_output |= out_size; | |
| 296 | 299 | printf("write frame %3d (size=%5d)\n", i, out_size); |
| 297 | 300 | fwrite(outbuf, 1, out_size, f); |
| 298 | 301 | } |