summaryrefslogtreecommitdiff
path: root/libavcodec/apiexample.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-07-23 10:41:07 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-07-23 10:41:07 +0000
commit17d71fb922a59ae0e6221917d3f94adc67fa992f (patch)
tree728a16ba009534c436736788fa6f52b0deb90a7d /libavcodec/apiexample.c
parente9174ba460aee4dd6b90ad598ebbaea683f774bf (diff)
last frames & b frames encoding fix
Originally committed as revision 2075 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/apiexample.c')
-rw-r--r--libavcodec/apiexample.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libavcodec/apiexample.c b/libavcodec/apiexample.c
index 27ec8241e1..94ec222cf3 100644
--- a/libavcodec/apiexample.c
+++ b/libavcodec/apiexample.c
@@ -195,6 +195,7 @@ void video_encode_example(const char *filename)
c->frame_rate = 25;
c->frame_rate_base= 1;
c->gop_size = 10; /* emit one intra frame every ten frames */
+ c->max_b_frames=1;
/* open it */
if (avcodec_open(c, codec) < 0) {
@@ -225,7 +226,6 @@ void video_encode_example(const char *filename)
/* encode 1 second of video */
for(i=0;i<25;i++) {
- printf("encoding frame %3d\r", i);
fflush(stdout);
/* prepare a dummy image */
/* Y */
@@ -245,6 +245,16 @@ void video_encode_example(const char *filename)
/* encode the image */
out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
+ printf("encoding frame %3d (size=%5d)\n", i, out_size);
+ fwrite(outbuf, 1, out_size, f);
+ }
+
+ /* get the delayed frames */
+ for(; out_size; i++) {
+ fflush(stdout);
+
+ out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
+ printf("write frame %3d (size=%5d)\n", i, out_size);
fwrite(outbuf, 1, out_size, f);
}
@@ -353,7 +363,7 @@ void video_decode_example(const char *outfilename, const char *filename)
exit(1);
}
if (got_picture) {
- printf("saving frame %3d\r", frame);
+ printf("saving frame %3d\n", frame);
fflush(stdout);
/* the picture is allocated by the decoder. no need to
@@ -374,7 +384,7 @@ void video_decode_example(const char *outfilename, const char *filename)
len = avcodec_decode_video(c, picture, &got_picture,
NULL, 0);
if (got_picture) {
- printf("saving frame %3d\r", frame);
+ printf("saving last frame %3d\n", frame);
fflush(stdout);
/* the picture is allocated by the decoder. no need to