[Ffmpeg-cvslog] CVS: ffmpeg output_example.c,1.13,1.14

Michael Niedermayer CVS michael
Fri Jul 8 12:09:02 CEST 2005


Update of /cvsroot/ffmpeg/ffmpeg
In directory mail:/var2/tmp/cvs-serv29871

Modified Files:
	output_example.c 
Log Message:
fixing output_example to work with current CVS libavcodec/libavformat patch by ("Andreas U. Trottmann": andreas trottmann, werft22 com)


Index: output_example.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/output_example.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- output_example.c	30 Apr 2005 21:43:55 -0000	1.13
+++ output_example.c	8 Jul 2005 10:08:59 -0000	1.14
@@ -37,6 +37,7 @@
 #define STREAM_DURATION   5.0
 #define STREAM_FRAME_RATE 25 /* 25 images/s */
 #define STREAM_NB_FRAMES  ((int)(STREAM_DURATION * STREAM_FRAME_RATE))
+#define STREAM_PIX_FMT PIX_FMT_YUV420P /* default pix_fmt */
 
 /**************************************************************/
 /* audio output */
@@ -150,7 +151,7 @@
 
     pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, samples);
 
-    pkt.pts= c->coded_frame->pts;
+    pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);
     pkt.flags |= PKT_FLAG_KEY;
     pkt.stream_index= st->index;
     pkt.data= audio_outbuf;
@@ -202,6 +203,7 @@
     c->time_base.den = STREAM_FRAME_RATE;  
     c->time_base.num = 1;
     c->gop_size = 12; /* emit one intra frame every twelve frames at most */
+    c->pix_fmt = STREAM_PIX_FMT;
     if (c->codec_id == CODEC_ID_MPEG2VIDEO) {
         /* just for testing, we also add B frames */
         c->max_b_frames = 2;
@@ -314,15 +316,13 @@
 {
     int out_size, ret;
     AVCodecContext *c;
-    AVFrame *picture_ptr;
     
     c = &st->codec;
     
     if (frame_count >= STREAM_NB_FRAMES) {
         /* no more frame to compress. The codec has a latency of a few
            frames if using B frames, so we get the last frames by
-           passing a NULL picture */
-        picture_ptr = NULL;
+           passing the same picture again */
     } else {
         if (c->pix_fmt != PIX_FMT_YUV420P) {
             /* as we only generate a YUV420P picture, we must convert it
@@ -334,7 +334,6 @@
         } else {
             fill_yuv_image(picture, frame_count, c->width, c->height);
         }
-        picture_ptr = picture;
     }
 
     
@@ -346,19 +345,19 @@
         
         pkt.flags |= PKT_FLAG_KEY;
         pkt.stream_index= st->index;
-        pkt.data= (uint8_t *)picture_ptr;
+        pkt.data= (uint8_t *)picture;
         pkt.size= sizeof(AVPicture);
         
         ret = av_write_frame(oc, &pkt);
     } else {
         /* encode the image */
-        out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size, picture_ptr);
+        out_size = avcodec_encode_video(c, video_outbuf, video_outbuf_size, picture);
         /* if zero size, it means the image was buffered */
         if (out_size != 0) {
             AVPacket pkt;
             av_init_packet(&pkt);
             
-            pkt.pts= c->coded_frame->pts;
+            pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);
             if(c->coded_frame->key_frame)
                 pkt.flags |= PKT_FLAG_KEY;
             pkt.stream_index= st->index;





More information about the ffmpeg-cvslog mailing list