- if( av_seek_frame( p_sys->ic, -1, i64, 0 ) < 0 )
+ /* If we have a duration, we prefer to seek by time
+ but if we don't, or if the seek fails, try BYTE seeking */
+ if( p_sys->ic->duration == (int64_t)AV_NOPTS_VALUE ||
+ (av_seek_frame( p_sys->ic, -1, i64, 0 ) < 0) )