Residual losses are known to be one of the main factors limiting the performances of r.f. superconducting cavities for particle accelerators. In particular, in thin film sputter-coated cavities, residual terms that are strongly dependent on the r.f. field amplitude have been observed in the surface resistance. In the present paper, it is shown that r.f. losses at the grain boundaries can be one of the main sources of the residual surface resistivity in Nb and Nb-alloys thin film coated r.f. cavities. The effect of the film thickness on the surface impedance is also discussed.