小编MK *_*ngh的帖子

如何将从iPhone相机拍摄的视频发送到服务器进行直播?

我有一些在线代码从iPhone的相机捕获视频,然后将其存储到视频文件,它工作正常.但我的目的不是将其保存在内存中,而是将其发送到服务器.我发现有一个名为WOWZA的免费媒体服务器,它允许流媒体和Apple有(HSL)HTTP直播流功能,服务器希望视频为h.264格式的视频和mp3的音频.通过阅读有关Apple HSL的一些文档,我也发现它在播放列表文件中为媒体文件的每个片段提供了不同的URL,然后通过浏览器以正确的顺序在设备上播放.我不确定如何获取手机摄像头录制的文件的小片段,以及如何将其转换为所需的格式.以下是捕获视频的代码:

实施档案

#import "THCaptureViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "THPlayerViewController.h"

#define VIDEO_FILE @"test.mov"

@interface THCaptureViewController ()
@property (nonatomic, strong) AVCaptureSession *captureSession;
@property (nonatomic, strong) AVCaptureMovieFileOutput *captureOutput;
@property (nonatomic, weak) AVCaptureDeviceInput *activeVideoInput;
@property (nonatomic, strong) AVCaptureVideoPreviewLayer *previewLayer;
@end

@implementation THCaptureViewController

- (void)viewDidLoad 
{
[super viewDidLoad];

    #if TARGET_IPHONE_SIMULATOR
    self.simulatorView.hidden = NO;
        [self.view bringSubviewToFront:self.simulatorView];
    #else
    self.simulatorView.hidden = YES;
    [self.view sendSubviewToBack:self.simulatorView];
    #endif

// Hide the toggle button if device has less than 2 cameras. Does 3GS support iOS 6?
self.toggleCameraButton.hidden = [[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo] count] < …
Run Code Online (Sandbox Code Playgroud)

iphone avfoundation live-streaming http-live-streaming ios

9
推荐指数
1
解决办法
4929
查看次数

将CVImageBufferRef转换为CVPixelBufferRef

我是iOS编程和多媒体的新手,我正在通过这个链接浏览一个名为RosyWriter的示例项目.在这里,我看到代码中有一个captureOutput:didOutputSampleBuffer:fromConnection在下面给出的代码中命名的函数:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection 
{   
CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer);

if ( connection == videoConnection ) {

    // Get framerate
    CMTime timestamp = CMSampleBufferGetPresentationTimeStamp( sampleBuffer );
    [self calculateFramerateAtTimestamp:timestamp];

    // Get frame dimensions (for onscreen display)
    if (self.videoDimensions.width == 0 && self.videoDimensions.height == 0)
        self.videoDimensions = CMVideoFormatDescriptionGetDimensions( formatDescription );

    // Get buffer type
    if ( self.videoType == 0 )
        self.videoType = CMFormatDescriptionGetMediaSubType( formatDescription );

    CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);

    // Synchronously process the pixel buffer to …
Run Code Online (Sandbox Code Playgroud)

iphone avfoundation ios

7
推荐指数
1
解决办法
9032
查看次数

在iPhone中的Google地图中添加UISlider或UIButtom等子视图

我是iOS编程的新手,对COCOA Touch知之甚少.我试图在Google地图底部的屏幕上添加一个按钮,以便用户选择返回上一个屏幕.我只知道它UIButton是一个子类,UIView我们可以通过使按钮成为该类的子视图来使按钮出现在视图中.以前iOS默认使用谷歌地图MKMapView,我在互联网上看过书中的例子,显示应用程序的屏幕截图,其中按钮或文本框将出现在地图上.但现在只需拖动界面构建器中的按钮就无济于事了.

MKMapView上的文本框

这是我的代码:

ViewController.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <GoogleMaps/GoogleMaps.h>


@interface ViewController : UIViewController 

@property (weak, nonatomic) IBOutlet UIButton *btn;


@end
Run Code Online (Sandbox Code Playgroud)

ViewController.m

#import "ViewController.h"
#import <MapKit/MapKit.h>
#import <GoogleMaps/GoogleMaps.h>
#import <CoreLocation/CoreLocation.h>


@interface ViewController ()

@end

@implementation ViewController
{
    GMSMapView *mapView_;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
} …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch mkmapview ios google-maps-sdk-ios

5
推荐指数
1
解决办法
5082
查看次数

在java中,如果我们在创建对象时定义一个类,那么这个类叫什么?

如果在java中我们有一个类A,如下面的代码,它的特殊名称是什么?

public static void main(String args[])
{ obj= new A()
           { ....
           };
}
Run Code Online (Sandbox Code Playgroud)

java

1
推荐指数
1
解决办法
106
查看次数

在C程序中,我们可以将变量的名称变为变量吗?

例如:就像我有一个变量char str[3]="abc";那么我可以使用这个"abc"作为另一个变量的名称(比如一个整数),这样我就可以存储任何值abc.如果是,那么在这样存储'abc'中的值时: int abc=123; 我可以通过引用来将abc称为变量str吗?

c

1
推荐指数
1
解决办法
183
查看次数

如何从XIB文件加载故事板?

我正在尝试在单击按钮时从XIB文件加载故事板文件.所以在IBAction方法中我调用了以下行:

- (IBAction)NextView:(id)sender
{
            UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    [mainStoryBoard instantiateViewControllerWithIdentifier:@"StoryViewController"];
}
Run Code Online (Sandbox Code Playgroud)

但是当我运行应用程序时,我收到此错误 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x88672d0>) doesn't contain a view controller with identifier 'StoryViewController''

我查看了人们在stackverflow上提出的其他问题,发现当一个人试图加载视图控制器的身份检查器中忘记将View控制器的标识符名称放入时,通常会抛出此错误.但我也这样做了.在故事板中,第一个正在加载的viewController是StoryViewController,我已将其标识符设置为相同.还有其他我可能会遗失的东西.请告诉我如何纠正它. 在此输入图像描述

iphone xcode interface-builder storyboard ios

1
推荐指数
1
解决办法
2887
查看次数

如何在HTML文件中使用换页符?

在普通文档文件中,换页符用作分页符.如何在HTML文件中使用它?

html

0
推荐指数
1
解决办法
2410
查看次数