Android VideoView 流式传输
我有一个包含 VideoView 的项目,我正在使用以下方法从在线流式传输视频:
mVideoView.setVideoURI(Uri.parse("http://db.tt/ij7w1Nw"));
我的视频是从 Youtube 下载的 mp4 文件。然后我将它们上传到我的保管箱,这就是网址的来源。如果我下载视频并且不对其进行任何更改,然后将其直接上传到保管箱,则效果很好。但是,如果我尝试对其进行任何更改,例如从 .flv 转换为 .mp4,或更改大小,那么我将其上传到保管箱,它不再在 VideoView 中播放。我收到一个对话框,显示“无法播放视频”。无效的流数据”。如果我拍摄完全相同的视频并手动将其放在 SD 卡上,或者甚至让我的应用程序从 URL 下载它,然后使用
mVideoView.setVideoPath(path);
它从 SD 卡上播放它,效果很好。我正在使用 Wondershare Video Converter Platinum 进行转换和大小更改。
是否需要某种特定的编码来流式传输 mp4 文件而不是从本地副本播放它?我收到此消息是因为 Wondershare 出现某种错误/错误吗?有其他人遇到过此类问题吗?如果是的话,您最终是如何解决的。
谢谢。
I have a project with a VideoView in it I am streaming a video from online using this method:
mVideoView.setVideoURI(Uri.parse("http://db.tt/ij7w1Nw"));
My videos are mp4 files downloaded from Youtube. I then upload them to my dropbox, that is where the url comes from. This works fine if I download the video and do not make any changes to it, and upload it straight to dropbox. However if I try to make any changes to it for instance convert from .flv to .mp4, or change the size, then I upload it to dropbox it no longer plays in the VideoView. I get a dialog that says 'Unable to play video. Invalid streaming data'. If I take this same exact video and put it on the SD card either manually or even by having my app download it from the url then play it off of the SD card using
mVideoView.setVideoPath(path);
it works fine. I am using Wondershare Video Converter Platinum to do the conversions and size changes.
Is there some sort of specific encoding that is required to stream an mp4 file rather than play it from a local copy? Am I getting this because of some sort of bug/error with wondershare? Has anyone else experienced this type of problem, if so how did you end up fixing it.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
媒体格式指南可以帮助您了解可用的内容。根据我的经验,将 H.264 AVC 或 MPEG 4 编码视频封装在 3GPP 容器中提供了最简单的集成。 Android 在音频和视频流方面都非常变化无常。
The media format guide may help you see what's available. In my experience wrapping a H.264 AVC or MPEG 4-encoded video in a 3GPP container provides the easiest integration. Android is very fickle with both audio and video streaming.