很抱歉,此视频无法播放 - 流式MP4到Android [英] Sorry, this video cannot be played - streaming mp4 to android

查看:1283
本文介绍了很抱歉,此视频无法播放 - 流式MP4到Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找遍了一个解决这个(包括SO),但仍然没有找到一个解决方案。

I've searched all over for a solution to this (including SO), however still haven't found a solution.

我需要在我的应用程序一个简单的视频播放。这是一个有点比视频简单的窗口那么简单。简化的,我有两个布局,我的屏幕上,一个包含一些其他的东西,另一种是有声视频的窗口。还有一个按钮,在两者之间切换。这一切工作就好了,之后我想通了,该videoview不能上能见度'走了'视图present - 所以我添加/在需要时从容器布局卸下来/

I need to have a simple video playback in my app. It's a bit less straightforward than a simple window with a video. Simplified, I have two layouts on my screen, one containing some other stuff and the other is to have the video window. There's also a button to switch between the two. This all works just fine, after I figured out that the videoview cannot be present on a view with visibility 'gone' - therefore I'm adding/removing it to/from container layout when needed.

不过,我有一个实际的视频播放问题。当我尝试激活它,我得到了可怕的错误抱歉,此视频无法播放这里的一个问题上的SO正在讨论的视频格式上(http://计算器.COM /问题/ 2544365 / Android的着播放的,任何-视频,MP4,MOV,3GP,等等) - 但是我已经有什么似乎是正确的格式,以320px的宽度和一切。一位在该线程的答案提到,从视频这里肯定工作。我试着一对夫妇从那里 - 但我有另一种常见的野兽:抱歉,此视频是无效的流此设备

However, I have the problem with the actual video playback. When I try to activate it, I get the dreaded error Sorry, this video cannot be played. One of the questions here on SO is discussing video formats (http://stackoverflow.com/questions/2544365/android-cant-play-any-videos-mp4-mov-3gp-etc) - however I already have what seems to be the correct format, with 320px width and everything else. One of the answers on that thread mentions that videos from here "definitely work". I tried a couple from there - but I got another common beast: Sorry, this video is not valid for streaming to this device.

请注意,我测试在实际设备上,视频播放不工作的模拟器。还要注意的是该溶液必须工作在Android 1.6及以上(客户的要求)。我测试的设备是LG GT540擎天柱采用Android 2.1(以present我没有使用任何其他设备)。

Please note that I'm testing on an actual device, as video playback is not working in the emulator. Also note that the solution must work on Android 1.6 and above (client's requirement). The device I'm testing on is LG GT540 Optimus with Android 2.1 (at present I don't have any other devices available).

从我想通了,如果我不使用 QT-的fastStart 上的视频,我得到错误抱歉,此视频是不是有效分流到该设备。如果我使用 QT-的fastStart ,然后我得到抱歉,此视频不能播放。

From what I figured out, if I don't use qt-faststart on the videos, I get error Sorry, this video is not valid for streaming to this device. If I do use qt-faststart, then I get Sorry, this video cannot be played.

下面是我的code的回放:

Here's my code for the playback:

VideoViewer videoPlayer = new VideoViewer(this);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoPlayer);
videoPlayer.setMediaController(mediaController);
videoPlayer.setVideoURI(Uri.parse(object.getVideoURL()));
LinearLayout container = (LinearLayout)ObjectInfo.this.findViewById(R.id.VideoContainer);
container.setVisibility(VISIBLE);
container.addView(videoPlayer, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
videoPlayer.requestFocus();
videoPlayer.start();

现在,视频我想扮演的是要进步的,下载从http: object.getVideoURL()返回<一href="http://www.ooklnet.com/files/381/381489/video.mp4">http://www.ooklnet.com/files/381/381489/video.mp4

Now, the video I'm trying to play is to be progressive-downloaded from HTTP: object.getVideoURL() returns http://www.ooklnet.com/files/381/381489/video.mp4

任何人都可以请帮我整理了这一点?这是我需要完成整个应用程序准备就绪之前的最后一件事。

Can anybody please help me sort this out? This is the last thing I need to complete before the whole app is ready.

非常感谢!

编辑:我试图用MediaPlayer的 - 却得到了比VideoView更糟糕的结果,所以又回到VideoView。现在,在模拟器中,我得到一个黑色的屏幕与对照盘旋在它的视频播放声音时细,也进度调整为播放继续。但是在我的实际设备,我仍然得到抱歉,此视频无法播放。错误

I tried using MediaPlayer - but got even worse results than with VideoView, so went back to VideoView. Now, in simulator, I get a black screen with controls hovering over it and the sound of the video is playing fine, also the progress is adjusting as the playback continues. However on my actual device, I'm still getting Sorry, this video cannot be played. error

推荐答案

原来问题出在的视频(具体而言,我使用的参数的ffmpeg 格式创建MP4视频)。我保证了视频的基线 H.264 - 和一切工作正常。请参见这个问题了解更多详情。

Turned out the problem was with the format of the videos (specifically, the parameters I used with ffmpeg to create the MP4 videos). I ensured that the videos are baseline H.264 - and everything worked properly. See this question for more details.

这篇关于很抱歉,此视频无法播放 - 流式MP4到Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆