简体   繁体   English

GPUImage和AVAssetWriter将文件写入哪里?

[英]GPUImage and AVAssetWriter writes files to where?

I am trying to use Brad Larson's GPUImage library to record a video file. 我正在尝试使用Brad Larson的GPUImage库来录制视频文件。 So far, the issue I am running into is the following piece of code: 到目前为止,我遇到的问题是以下代码:

NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];
unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480.0, 640.0)];

This is picked up directly from his example from his GitHub page https://github.com/BradLarson/GPUImage 这是直接从他的示例中获取的,该示例来自他的GitHub页面https://github.com/BradLarson/GPUImage

Now, I looked at the source code and I see he does the usual AVFoundation stuff - creates AVAssetWriter instance and adds inputs to it. 现在,我看了看源代码,发现他做了通常的AVFoundation东西-创建AVAssetWriter实例并向其中添加输入。 MY question here is that where is @"Documents/Movie.m4v" located? 我的问题是@“ Documents / Movie.m4v”在哪里? How can I play this video back? 如何播放此视频? Or how do I even access it? 或者我什至如何访问它? I know it is located in an arbitrary location where the app bundle is copied during run-time. 我知道它位于运行时在其中复制应用程序捆绑包的任意位置。 My goal is to be able to write the video into the Gallery or atleast an album in Gallery that is created by my app. 我的目标是能够将视频写入图库中,或者至少将由我的应用创建的相册添加到图库中。 Does anyone know where the file is being written to? 有谁知道文件要写入的位置?

Maybe I'm misunderstanding, but the movie is at the path pathToMovie (or URL movieURL . 也许我误会了,但是电影在pathToMovie (或URL movieURL路径movieURL

You can play it back with something like this: 您可以使用以下方式播放它:

#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>

// later
AVPlayerViewController *avc = [[AVPlayerViewController alloc] init];
avc.player = [[AVPlayer alloc] initWithURL:movieURL];
[myViewController presentViewController:avc animated:YES completion:nil];

If you want to download the file to your computer, you can select your connect device in Xcode > Devices, then select your app and download the package. 如果要将文件下载到计算机,则可以在“ Xcode”>“设备”中选择连接设备,然后选择您的应用并下载软件包。 Your movie will be in the Documents directory. 您的电影将位于“文档”目录中。

To save it to the gallery, do 要将其保存到图库,请执行

// TODO: use completion arguments for a better user experience
UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie,nil,nil,nil);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM