1

ビデオを録画しようとすると、次のようなエラーが発生します

ファイル URL ではないため、URL <#file url> に記録できません。

次のように宛先 URL を定義します。

NSString *Path = [[NSString alloc] init];
Path = @"/Users/me/Documents/My fols/recording_try/newMovie.mov";
NSURL *dest = [[NSURL alloc] initWithString:[Path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

次に、セッションを作成した後、オブジェクトを入力および出力します。こんな感じで録音してみました。

mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init] ;
[mSession addOutput:mMovieFileOutput];
[mMovieFileOutput startRecordingToOutputFileURL:dest recordingDelegate:self];

セッションの実行を開始し、begin や commitconfiguration などを使用してみましたが、実行するたびに次のようなエラーが発生します。

[AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] - Cannot record to URL /Users/me/Documents/My%20fols/recording_try/newMovie.mov because it is not a file URL.

どこが間違っているのかわかりません...誰か助けてくれませんか???

前もって感謝します...

4

2 に答える 2

2

ファイルのURLタイプに準拠するようにNSURL構成を変更するだけです

このようなもの:

NSURL *dest = [[NSURL alloc] initFileURLWithPath:<#(NSString *)#>]

于 2015-06-29T07:04:42.947 に答える
1

次のようなことを試してください:

// variable names should start with lower case letters

// also, let's do as much as we can with auto-released objects
// so we don't have to worry about leaking (if we're not using ARC)
NSString *path = [NSString stringWithString: @"/Users/me/Documents/My fols/recording_try"];
NSURL *dest = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if(dest == nil)
{
    NSLog( @"does not appear to be a valid NSURL object" );
    return;
}

NSError * error = nil;
if([[NSFileManager defaultManager] createDirectoryAtURL: dest withIntermediateDirectories: YES attributes: nil error: &error] == YES)
{
    dest = [dest URLByAppendingPathComponent: @"newMovie.mov"];

    // now you can create the session plus input and output objects
    // within this block

} else {
    NSLog( @"was not able to create the directory which contains path %@ - error is %@", path, [error localizedDescription] );
}
于 2012-06-05T10:15:36.187 に答える