[MEncoder-users] Last two frames missing

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Jul 7 14:59:11 CEST 2009


On Tue, Jul 07, 2009 at 11:50:45AM +0000, Mark Himsley wrote:
> I need to make a full table to results and post it somewhere useful so that
> people more clever than I can say "oh, I know how to fix that" ;-)

Yes, use threads=1. This is a bug in libx264, when you call
x264_encoder_encode with NULL as pic it is supposed to return the
delayed frames, but with threads it at first returns nothing, making
MPlayer think there are no more frames.
Maybe using a newer x264 will help, mine is quite outdated...
Attached patch fixes it, too (well, assuming you do not try to use more
than 255 threads or so).
-------------- next part --------------
Index: libmpcodecs/ve_x264.c
===================================================================
--- libmpcodecs/ve_x264.c	(revision 29412)
+++ libmpcodecs/ve_x264.c	(working copy)
@@ -218,10 +218,14 @@
 static int control(struct vf_instance_s* vf, int request, void *data)
 {
     h264_module_t *mod=(h264_module_t*)vf->priv;
+    int count = 256; // giant HACK, x264_encoder_encode may incorrectly return 0
+                     // when threads > 1 and delayed frames pending
     switch(request){
         case VFCTRL_FLUSH_FRAMES:
-            if(param.i_bframe)
+            if(param.i_bframe) {
+                while(encode_frame(vf, NULL) == 0 && --count);
                 while(encode_frame(vf, NULL) > 0);
+            }
             return CONTROL_TRUE;
         default:
             return CONTROL_UNKNOWN;


More information about the MEncoder-users mailing list