[英]VideoView SeekTo working smoothly or delay on different devices - Android
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. 我正在开发一个功能,我点击下一个按钮然后暂停视频将寻找下一个部分并开始 。例如当video.getCurrentPosition是8000时,我点击按钮进行视频搜索(10000),因为视频显示相同的内容在8000之间和10000。
This function on some android devices runs smoothly,such as Samsung s6 edge,OnePlus,Xiaomi,Smartison
... 这个功能在一些Android设备上运行顺畅,如
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. 但问题是在某些设备上,例如华为,Moto Nexus 6,当8000上的视频和我点击按钮时,它有一些“
delay time
”。它看起来大概是1秒。 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. 相比之下,我特意改变了寻求错误(10200),这是一个错误的参数 ,这些“问题设备”平稳运行就像 “正常设备”。然而,之前“
normal devices
”上的视频跳过一些帧并从10200开始。
Is anyone know why cause this issue?Hope your answer,thank you. 有谁知道为什么导致这个问题?希望你的回答,谢谢。
Was the video encoded using h264
? 视频是使用
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
. 重新编码为使用
mpeg4
编解码器,如建议在这太问题评论 ,已经解决了,我很奇怪的问题seekTo
通过一个Android的行为ViewView
。
To check the encoding, and to re-encode, you might be able to use ffmpeg
. 要检查编码和重新编码,您可以使用
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
. $ ffprobe <inputfile> ... ... Stream #0:0(eng): Video: h264 ... ...
显示文件是使用h264
编码的,这是更近期的,通常会产生更好的质量与mpeg4
相同的比特率,但(可能是因此)更难以通过,至少对于Android VideoView
。
To encode as mpeg4
the following worked for me, but the ffmpeg
wiki has more detail. 为了编码为
mpeg4
,以下对我ffmpeg
,但ffmpeg
wiki有更多细节。
$ ffmpeg -i <inputfile> -c:v libxvid <outputfile>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.