On Wed, Apr 27, 2011 at 11:31 AM, anders musikka
<[email protected]> wrote:
> Would it be possible to change MLT, so that the rendered length of a
> clip would always be exactly (out-in+1) frames? I.e, if there aren't
> enough frames in the clip, simply repeat the last frame as required?

I did some analysis and testing and found that normally the avformat
produce already exhibits the requested behavior by duplicating the
last frame. You can verify this on some reliable clips by inflating
the length:
melt somefile length=500 out=499
Of course, choose values greater than your clip length.
However, I did find that when a video frame fails to decode, then it
does not duplicate the last good frame. Instead, it produces the white
"test" frame I mentioned until it succeeds or never in the case of bad
frames at the end of a file. Can you test this patch against mlt head
that tries to fix that?

diff --git a/src/modules/avformat/producer_avformat.c
b/src/modules/avformat/producer_avformat.c
index d28be80..7afd2f1 100644
--- a/src/modules/avformat/producer_avformat.c
+++ b/src/modules/avformat/producer_avformat.c
@@ -1276,6 +1276,7 @@ static int producer_get_image( mlt_frame frame,
uint8_t **buffer, mlt_image_form
                int decode_errors = 0;
                int got_picture = 0;

+               self->got_picture = 0;
                av_init_packet( &pkt );

                // Construct an AVFrame for YUV422 conversion
@@ -1480,6 +1481,37 @@ static int producer_get_image( mlt_frame frame,
uint8_t **buffer, mlt_image_form
                memcpy( image, *buffer, image_size );
                mlt_cache_put( self->image_cache, (void*) position, image, 
*format,
mlt_pool_release );
        }
+       // Try to duplicate last image if there was a decoding failure
+       else if ( !self->got_picture && self->av_frame &&
self->av_frame->linesize[0] )
+       {
+               // Duplicate it
+               if ( ( image_size = allocate_buffer( frame, codec_context, 
buffer,
format, width, height ) ) )
+               {
+                       // Workaround 1088 encodings missing cropping info.
+                       if ( *height == 1088 && mlt_profile_dar( 
mlt_service_profile(
MLT_PRODUCER_SERVICE( producer ) ) ) == 16.0/9.0 )
+                               *height = 1080;
+#ifdef VDPAU
+                       if ( self->vdpau && self->vdpau->buffer )
+                       {
+                               AVPicture picture;
+                               picture.data[0] = self->vdpau->buffer;
+                               picture.data[2] = self->vdpau->buffer + 
codec_context->width *
codec_context->height;
+                               picture.data[1] = self->vdpau->buffer + 
codec_context->width *
codec_context->height * 5 / 4;
+                               picture.linesize[0] = codec_context->width;
+                               picture.linesize[1] = codec_context->width / 2;
+                               picture.linesize[2] = codec_context->width / 2;
+                               convert_image( (AVFrame*) &picture, *buffer,
+                                       PIX_FMT_YUV420P, format, *width, 
*height, self->colorspace );
+                       }
+                       else
+#endif
+                       convert_image( self->av_frame, *buffer, 
codec_context->pix_fmt,
+                               format, *width, *height, self->colorspace );
+                       self->got_picture = 1;
+               }
+               else
+                       mlt_frame_get_image( frame, buffer, format, width, 
height, writable );
+       }

        // Regardless of speed, we expect to get the next frame (cos we
ain't too bright)
        self->video_expected = position + 1;

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Mlt-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to