MPMoviePlayer播放音频,但不是视频,当寻找到一个文件 [英] MPMoviePlayer playing audio but not video when seeking into a file

查看:169
本文介绍了MPMoviePlayer播放音频,但不是视频,当寻找到一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在某一点寻找到视频文件。假设视频长度为5分钟,我在110秒时跳。

I'm trying to seek into a video file at a certain point. Lets say the video is 5 minutes long and I'm jumping in at 110 seconds.

当我从头开始玩时,一切都很好,但是当我尝试寻找到文件,我可以听到音频,但我看不到视频。我第一次认为这可能是一个问题,我加载子视图的顺序,但我仍然可以看到(和使用)的玩家的控件。回到0:00开始播放视频。

When I play from the beginning, everything plays through fine, however, when I try to seek into the file, I can hear the audio but I can't see the video. I first thought this was maybe an issue with the order I'm loading the subviews but I can still see (and use) the controls for the player. Sliding back to 0:00 starts the video.

以下是我的视频类的代码。 initIntoView方法接受一个 UIView ,然后返回一个修改的副本,然后写入主视图。对于凌乱代码提前对不起。

The following is code from my video class. The initIntoView method accepts a UIView and then returns an amended copy which then gets written to the main view. Sorry in advance for the messy code. I'm still quite new to Objective-C.

开始视频视图

- (WWFVideo*) initIntoView: (UIView*) view withContent:(NSDictionary*)contentDict{
    self=[super init];
    viewRef=view;
    contentData = contentDict;
    NSURL *videoUrl = [[NSURL alloc]initWithString:[contentDict objectForKey:@"cnloc"]]; //Returns a HTTP link to my video file (MP4, H.246, AAC Audio)
    videoController = [[MPMoviePlayerController alloc] init];
    videoController.movieSourceType = MPMovieSourceTypeFile;
    [videoController setContentURL:videoUrl];   
    videoController.view.frame = viewRef.bounds;
    [videoController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
    [viewRef addSubview:videoController.view];
    return self;
}

开始播放视频 b
$ b

Start playing the video

-(void)play:(int)offset { //Offset is "110"
    [videoController setInitialPlaybackTime:offset];
    [videoController play];
}



我尝试将videoController添加到 viewRef 在视频开始播放之前和之后,但它有相同的结果。

I've tried adding the videoController to viewRef both before and after the video starts playing but it has the same outcome.

我也试过使用 MPMoviePlayerViewController

I've also tried using an MPMoviePlayerViewController with no avail.

我尝试的另一件事是将流类型更改为 MPMovieSourceTypeStreaming 但它似乎没有效果。

Another thing I tried was changing the streaming type to MPMovieSourceTypeStreaming but it seemed to have no effect.

如果我错过了任何更重要的代码,请问,我会看到我能做什么。

If I've missed any more vital code, just ask and I'll see what I can do.

编辑

Xcode 4.6.3

iOS 6

在iPad上测试2


Xcode 4.6.3
iOS 6
Testing on an iPad 2

编辑#2:

在模拟器上完美运行,而不是在设备上。 / p>

Edit #2:
Works perfectly on the simulator, just not on the device.

推荐答案

在尝试将一个示例应用程序拼凑在一起后,我发现 w3版本的大巴克兔兔工作得很好。这表明它是一个编码问题,而不是一个客观的C问题。

After trying to piece together a sample app to upload here, I found that the w3 version of Big Buck Bunny worked fine. This indicates it was an encoding problem and not an objective C issue.

我已经重新编码相同的文件,我试图玩之前,但现在与 basic 配置文件:

I've re-encoded the same file I was trying to play before but now with the baseline profile with the following command:


ffmpeg -i {filename} ac 2 -strict experimental -ab 160k -s {ssize} -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b 1200k -f mp4-threads 0 {filename} .ipad.mp4

ffmpeg -i {filename} -acodec aac -ac 2 -strict experimental -ab 160k -s {ssize} -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b 1200k -f mp4 -threads 0 {filename}.ipad.mp4

我在此处,通过此Stack Overflow信息


主要用于需要额外的数据丢失鲁棒性的低成本应用,此配置文件用于某些视频会议和移动应用。此配置文件包括受约束基准配置文件中支持的所有功能,以及可用于损耗鲁棒性(或用于其他目的,如低延迟多点视频流合成)的三个附加功能。自从2009年的约束基线简档的定义以来,该简档的重要性已经褪色。所有约束的基线简档比特流也被认为是基线简档比特流,因为这两个简档共享相同的简档标识符代码值。

Primarily for low-cost applications that require additional data loss robustness, this profile is used in some videoconferencing and mobile applications. This profile includes all features that are supported in the Constrained Baseline Profile, plus three additional features that can be used for loss robustness (or for other purposes such as low-delay multi-point video stream compositing). The importance of this profile has faded somewhat since the definition of the Constrained Baseline Profile in 2009. All Constrained Baseline Profile bitstreams are also considered to be Baseline Profile bitstreams, as these two profiles share the same profile identifier code value.

- 来自维基百科

我意识到这可能不帮助任何人在这里寻找Objective-C帮助,但如果它只保存一个人我5天试图得到这个工作,这将是值得的。

I realise this may not help anyone here looking for Objective-C help but if it saves just one person the 5 hours I spent today trying to get this working, this will be worth it.

这篇关于MPMoviePlayer播放音频,但不是视频,当寻找到一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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