VideoView SeekTo working smoothly or delay on different devices - Android

607 Views Asked by At

I'm developing a function that I click next button then the pause video will seekto next part and start.For example when video.getCurrentPosition is 8000, I click button to make video seekto(10000),because the video show same content between 8000 and 10000.

This function on some android devices runs smoothly,such as Samsung s6 edge,OnePlus,Xiaomi,Smartison...

But the issue is that on some devices,such as Huawei,Moto Nexus 6, when video on 8000 and I click the button,it has some "delay time".It looks like about 1sec. later,the video finally starts.

By contrast,I specially change the seekto(10200),which is wrong parameter,and these "problem devices" runs smoothly likes "normal devices".However,the video on previous "normal devices" skip some frame and start at 10200.

Is anyone know why cause this issue?Hope your answer,thank you.

1

There are 1 best solutions below

0
On

Was the video encoded using h264? Re-encoding as using the mpeg4 codec, as suggested in a comment to this SO question, has resolved for me a problem of very odd seekTo behaviour by an Android ViewView.

To check the encoding, and to re-encode, you might be able to use ffmpeg.

$ ffprobe <inputfile> ... ... Stream #0:0(eng): Video: h264 ... ... That showed the the file is encoded using h264, which is more recent and generally produces better quality for the same bitrate as mpeg4, but is (presumably as a consequence) harder to seek through, at least for the Android VideoView.

To encode as mpeg4 the following worked for me, but the ffmpeg wiki has more detail.

$ ffmpeg -i <inputfile> -c:v libxvid <outputfile>