警告:数据未对齐!这可能导致速度损失

时间:2016-06-22 08:48:42

标签: objective-c streaming video-streaming rtsp

我看这个project,它正在为一个视频工作。我试着有一个以上,所以我尝试了2个视频。我是这样做的:`

-(void)displayNextFrame:(NSTimer *)timer
{
    NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];

    if (![video2 stepFrame]) {
        [timer invalidate];
        [video2 closeAudio];
        return;
    }

    if (![video stepFrame]) {
        [timer invalidate];
        [video closeAudio];
        return;
    }

    imageView.image = video.currentImage;
    imageView2.image = video2.currentImage;


    float frameTime = 1.0/([NSDate timeIntervalSinceReferenceDate]-startTime);
    if (lastFrameTime<0) {
        lastFrameTime = frameTime;
    } else {
        lastFrameTime = LERP(frameTime, lastFrameTime, 0.8);
    }
    [label setText:[NSString stringWithFormat:@"%.0f",lastFrameTime]];

}`

我稍微改变了第一个项目(删除播放按钮,播放应用程序后播放视频)。以下是我开始播放视频的方式:

-(void)playVideo{
    lastFrameTime = -1;

    // seek to 0.0 seconds
    [video seekTime:0.0];

    [video2 seekTime:0.0];

    [_nextFrameTimer invalidate];
    self.nextFrameTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/30
                                                           target:self
                                                         selector:@selector(displayNextFrame:)
                                                         userInfo:nil
                                                          repeats:YES];
}



  - (void)viewDidLoad
{
    [super viewDidLoad];

    [imageView setContentMode:UIViewContentModeScaleAspectFit];
    [imageView2 setContentMode:UIViewContentModeScaleAspectFit];
    [self playVideo];


}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        //http://www.wowza.com/_h264/BigBuckBunny_115k.mov
        //rtsp://media1.law.harvard.edu/Media/policy_a/2012/02/02_unger.mov
        //rtsp://streaming.parliament.act.gov.au/medium

        //rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov
        //rtsp://127.0.0.1:8554/test
        //rtsp://mm2.pcslab.com/mm/7h800.mp4


        //video 1
        video = [[RTSPPlayer alloc] initWithVideo:@"rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov" usesTcp:NO];
        video.outputWidth = 426;
        video.outputHeight = 320;

        NSLog(@"video duration: %f",video.duration);
        NSLog(@"video size: %d x %d", video.sourceWidth, video.sourceHeight);

        //video 2
        video2 = [[RTSPPlayer alloc] initWithVideo:@"rtsp://mm2.pcslab.com/mm/7h800.mp4" usesTcp:NO];
        video2.outputWidth = 426;
        video2.outputHeight = 320;

        NSLog(@"video 2 duration: %f",video2.duration);
        NSLog(@"video 2 size: %d x %d", video2.sourceWidth, video2.sourceHeight);
    }

    return self;
}

但是,当我构建此代码时,没有错误,显示2个视频,然后崩溃并显示警告:数据未对齐!这可能导致速度损失。有什么不对吗?我不明白为什么它不起作用..提前谢谢

0 个答案:

没有答案