如何使用RTMPStreamPublisher发布视频时在iPhone上存储视频?

Use*_*343 15 iphone objective-c rtmp ios avcapturesession

现在我正在使用RTMPStreamPublisherwowzaserver发布视频.它正在成功上传,但有人能告诉我如何在上传到服务器时将相同的视频存储在iPhone上吗?

我使用https://github.com/slavavdovichenko/MediaLibDemos,但没有太多可用的文档.如果我可以存储发送的数据,那么我的工作就会成功.

以下是他们用于上传流的方法,但我找不到在iPhone设备上存储相同视频的方法:

// ACTIONS

-(void)doConnect {
#if 0 // use ffmpeg rtmp 
    NSString *url = [NSString stringWithFormat:@"%@/%@", hostTextField.text, streamTextField.text];
    upstream = [[BroadcastStreamClient alloc] init:url  resolution:RESOLUTION_LOW];
    upstream.delegate = self;
    upstream.encoder = [MPMediaEncoder new];
    [upstream start];
    socket = [[RTMPClient alloc] init:host]
    btnConnect.title = @"Disconnect";     
    return;
#endif

#if 0 // use inside RTMPClient instance
    upstream = [[BroadcastStreamClient alloc] init:hostTextField.text resolution:RESOLUTION_LOW];
    //upstream = [[BroadcastStreamClient alloc] initOnlyAudio:hostTextField.text];
    //upstream = [[BroadcastStreamClient alloc] initOnlyVideo:hostTextField.text resolution:RESOLUTION_LOW];

#else // use outside RTMPClient instance

    if (!socket) {
        socket = [[RTMPClient alloc] init:hostTextField.text];
        if (!socket) {
            [self showAlert:@"Socket has not be created"];
            return;
        }
        [socket spawnSocketThread];
   }
    upstream = [[BroadcastStreamClient alloc] initWithClient:socket resolution:RESOLUTION_LOW];
#endif

    [upstream setVideoOrientation:AVCaptureVideoOrientationLandscapeRight];
    //[upstream setVideoOrientation:AVCaptureVideoOrientationLandscapeLeft];
    //[upstream setVideoBitrate:512000];
    upstream.delegate = self;
    [upstream stream:streamTextField.text publishType:PUBLISH_LIVE];
    //[upstream stream:streamTextField.text publishType:PUBLISH_RECORD];
    //[upstream stream:streamTextField.text publishType:PUBLISH_APPEND];
    btnConnect.title = @"Disconnect";     
}
Run Code Online (Sandbox Code Playgroud)

我确实发现,在BroadcastStreamClient命名为"upstream" 的实例中,我可以AVCaptureSession通过以下行获取

[upstream getCaptureSession];
Run Code Online (Sandbox Code Playgroud)

如何使用它AVCaptureSession在iPhone上录制视频?

Avi*_*are 0

当您从相册中选择视频或录制视频时,请尝试此操作。或在 didFinishPickingMediaWithInfo 方法中

NSURL __block *videoUrl=(NSURL*)[info objectForKey:UIImagePickerControllerMediaURL];

NSString *moviePath = [videoUrl path];

if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
             UISaveVideoAtPathToSavedPhotosAlbum (moviePath, nil, nil, nil);
 }
Run Code Online (Sandbox Code Playgroud)