GPUImage 和 AVAssetWriter 将文件写入哪里?

GPUImage and AVAssetWriter writes files to where?

我正在尝试使用 Brad Larson 的 GPUImage 库来录制视频文件。到目前为止,我 运行 关注的问题是以下代码:

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)];

这是直接从他的 GitHub 页面中的示例中提取的 https://github.com/BradLarson/GPUImage

现在,我查看了源代码,发现他执行了通常的 AVFoundation 操作——创建 AVAssetWriter 实例并向其添加输入。我的问题是 @"Documents/Movie.m4v" 在哪里?我怎样才能播放这个视频?或者我什至如何访问它?我知道它位于 运行 期间复制应用程序包的任意位置。我的目标是能够将视频写入图库或至少是我的应用程序创建的图库中的相册。有谁知道文件被写入哪里?

可能是我理解错了,电影在路径pathToMovie(或URL movieURL.

您可以像这样播放它:

#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];

如果您想将文件下载到您的计算机,您可以在 Xcode > 设备中 select 连接设备,然后 select 您的应用程序并下载包。您的电影将位于 Documents 目录中。

要将其保存到图库,请执行

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