]> git.sesse.net Git - mlt/commitdiff
make speed of editing AVCHD tolerable
authorDan Dennedy <dan@dennedy.org>
Mon, 2 Apr 2012 01:39:03 +0000 (18:39 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 2 Apr 2012 01:41:36 +0000 (18:41 -0700)
This only works for FFmpeg v0.9.1 or newer but not yet for libav.
This uses the image scaling interpolation mode as a hint to perform less
(nearest) or more (bilinear or bicubic) diligent seeking. Since most
editors are using the SDL consumer with rescale=nearest, this makes
scrubbing and cuts/transitions faster. Then, upon encoding, since the
avformat consumer uses bilinear by default, it will use the slower, more
accurate seeking to ensure the integrity of cuts with an in
point. This change has some quirks: frame-stepping backwards sometimes
does not update the image, and sometimes a big jump forward shows
artifacts.

src/modules/avformat/producer_avformat.c

index 8465d210118217e3c7d668891d49f6400916af98..8983ebd6587817936ca24d69a89cc9b77a0bc893 100644 (file)
@@ -1499,7 +1499,13 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        double delay = mlt_properties_get_double( properties, "video_delay" );
 
        // Seek if necessary
-       int paused = seek_video( self, position, req_position, must_decode, use_new_seek, &ignore );
+       const char *interp = mlt_properties_get( frame_properties, "rescale.interp" );
+       int preseek = must_decode
+#if defined(FFUDIV) && LIBAVFORMAT_VERSION_INT >= ((53<<16)+(24<<8)+2)
+               && ( !use_new_seek || ( interp && strcmp( interp, "nearest" ) ) )
+#endif
+               && codec_context->has_b_frames;
+       int paused = seek_video( self, position, req_position, preseek, use_new_seek, &ignore );
 
        // Seek might have reopened the file
        context = self->video_format;