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 | FILE *f; | 215 | FILE *f; |
| 216 | AVFrame *picture; | 216 | AVFrame *picture; |
| 217 | uint8_t *outbuf; | 217 | uint8_t *outbuf; |
| 218 | int had_output=0; | ||
| 218 | 219 | ||
| 219 | printf("Video encoding\n"); | 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 | /* encode the image */ | 286 | /* encode the image */ |
| 286 | out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture); | 287 | out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture); |
| 288 | had_output |= out_size; | ||
| 287 | printf("encoding frame %3d (size=%5d)\n", i, out_size); | 289 | printf("encoding frame %3d (size=%5d)\n", i, out_size); |
| 288 | fwrite(outbuf, 1, out_size, f); | 290 | fwrite(outbuf, 1, out_size, f); |
| 289 | } | 291 | } |
| 290 | 292 | ||
| 291 | /* get the delayed frames */ | 293 | /* get the delayed frames */ |
| 292 | for(; out_size; i++) { | 294 | for(; out_size || !had_output; i++) { |
| 293 | fflush(stdout); | 295 | fflush(stdout); |
| 294 | 296 | ||
| 295 | out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL); | 297 | out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL); |
| 298 | had_output |= out_size; | ||
| 296 | printf("write frame %3d (size=%5d)\n", i, out_size); | 299 | printf("write frame %3d (size=%5d)\n", i, out_size); |
| 297 | fwrite(outbuf, 1, out_size, f); | 300 | fwrite(outbuf, 1, out_size, f); |
| 298 | } | 301 | } |