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

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

问题描述

我已经到处寻找解决方案(包括 SO),但仍然没有找到解决方案.

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

我需要在我的应用中进行简单的视频播放.它比带有视频的简单窗口要简单一些.简而言之,我的屏幕上有两种布局,一种包含一些其他内容,另一种是具有视频窗口.还有一个按钮可以在两者之间切换.这一切都很好,在我发现视频视图不能出现在可见性消失"的视图上之后 - 因此我在需要时将它添加到容器布局中/从容器布局中删除.

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 上的问题之一是讨论视频格式 (Android -- 无法播放任何视频(mp4/mov/3gp/等)?)- 但是我已经有了似乎正确的格式,宽度为 320 像素和其他所有内容.该线程上的一个答案提到来自这里的视频绝对有效".我从那里尝试了几个 - 但我得到了另一个常见的野兽:抱歉,此视频无法流式传输到此设备.

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 (Android -- Can't 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 及更高版本(客户要求).我正在测试的设备是带有 Android 2.1 的 LG GT540 Optimus(目前我没有任何其他设备可用).

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,我会收到错误 抱歉,此视频无法流式传输到此设备.code> 如果我确实使用了 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.

这是我的播放代码:

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() 返回 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 视频).我确保视频是 baseline 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天全站免登陆