Don't seek before 0 in FFmpegDecoder; fixes errors on seek close to 0.
authorCarl Hetherington <cth@carlh.net>
Sun, 14 Jun 2015 21:52:42 +0000 (22:52 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 14 Jun 2015 21:52:42 +0000 (22:52 +0100)
src/lib/ffmpeg_decoder.cc

index f8152b56e7629021d1a197b633cbe3d1559eaaff..4ca06329b116ae9561ddb3c61fa11a17416af9c2 100644 (file)
@@ -315,7 +315,10 @@ FFmpegDecoder::seek (ContentTime time, bool accurate)
           http://www.mjbshaw.com/2012/04/seeking-in-ffmpeg-know-your-timestamp.html
        */
        
-       ContentTime const u = time - _pts_offset;
+       ContentTime u = time - _pts_offset;
+       if (u < ContentTime ()) {
+               u = ContentTime ();
+       }
        av_seek_frame (_format_context, _video_stream, u.seconds() / av_q2d (_format_context->streams[_video_stream]->time_base), AVSEEK_FLAG_BACKWARD);
 
        avcodec_flush_buffers (video_codec_context());