[FFmpeg-devel] fix case where audio codec doesn't return a full packet

Art Clarke aclarke
Mon Feb 16 02:23:51 CET 2009


$subject



-- 
http://www.xuggle.com/
xu?ggle (z?' gl) v. To freely encode, decode, and experience audio and
video.

Use Xuggle to get the power of FFMPEG in Java.
-------------- next part --------------
Index: output_example.c
===================================================================
--- output_example.c	(revision 17348)
+++ output_example.c	(working copy)
@@ -155,6 +155,13 @@
     get_audio_frame(samples, audio_input_frame_size, c->channels);
 
     pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, samples);
+    if (pkt.size < 0) {
+        fprintf(stderr, "error while encoding audio frame\n");
+        exit(1);
+    }
+    if (pkt.size == 0)
+      // codec didn't return a packet yet
+      return;
 
     if (c->coded_frame->pts != AV_NOPTS_VALUE)
         pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, st->time_base);



More information about the ffmpeg-devel mailing list