Search code examples
objective-ciosnsurl

AVAssetWriter invalid URL for writing


I'm getting this error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVAssetWriter initWithURL:fileType:error:] invalid parameter not satisfying: [outputURL isFileURL]'

On this line:

AVAssetWriter * assetWriter = [[AVAssetWriter alloc] initWithURL:videoURL
                                                        fileType: AVFileTypeMPEG4
                                                           error: &movieError];

Where videoURL logs as:

/var/mobile/Applications/A032EEA6-C83D-49DA-B118-E4E4B9F41C7F/Documents/videoForSegmentNumber1.mp4

the line before this is called.

I've also tested against isFileURL myself and its returning NO. What is required to be a valid fileURL?


Solution

  • Use

    + (id)fileURLWithPath:(NSString *)path
    

    instead of

    + (id)URLWithString:(NSString *)URLString