1
A
回答
0
您可以保存使用UISaveVideoAtPathToSavedPhotosAlbum
解決方案
UISaveVideoAtPathToSavedPhotosAlbum(yourVideoPath, nil, nil, nil);
要獲取視頻的路徑,你必須在任何地方保存。您可以保存到目標路徑。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSString * yourVideoPath = [basePath stringByAppendingPathComponent:@"video.mov"];
[yourVideoData writeToFile:yourFilePath atomically:YES];
0
2
試試這個,這是爲我工作
-(void)SaveVideoTOPhotoAlbum
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSString *getImagePath = [basePath stringByAppendingPathComponent:videoName];
printf(" \n\n\n-Video file == %s--\n\n\n",[getImagePath UTF8String]);
UISaveVideoAtPathToSavedPhotosAlbum (getImagePath,self, @selector(video:didFinishSavingWithError: contextInfo:), nil);
}
//
- (void) video: (NSString *) videoPath didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo
{
NSLog(@"Finished saving video with error: %@", error);
//kapil here ****
}
祝親愛的
0
試試這個...
NSURL *videoUrl = [NSURL URLWithString:[NSString stringWithFormat:@"Your Video Url"]];
dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(q, ^{
NSData *videoData = [NSData dataWithContentsOfURL:videoUrl];
dispatch_async(dispatch_get_main_queue(), ^{
// Write it to cache directory
NSString *videoPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"file.mov"];
[videoData writeToFile:videoPath atomically:YES];
// After that use this path to save it to PhotoLibrary
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:[NSURL fileURLWithPath:videoPath] completionBlock:^(NSURL *assetURL, NSError *error)
{
if (error)
{
NSLog("Error");
}
else
{
NSLog("Success");
}
}];
});
});
相關問題
- 1. 如何從網站下載視頻並保存在圖庫中?
- 2. c#AForge.NET - 如何將視頻從相機保存到文件中
- 3. 將視頻加載到庫中的視圖/緩存
- 4. 如何在Objective-C中保存具有特定名稱的視頻文件?
- 5. 如何將視頻從文檔目錄保存到圖庫?
- 6. 如何將視頻文件保存在數據庫中?
- 7. 如何使用objective-C將圖像保存到iphone的Wallpaper文件夾中?
- 8. 將總視頻文件的幀數保存到.txt文件中
- 9. OpenCV將視頻保存到文件
- 10. 如何使用java將視頻下載到文件中?
- 11. 將圖像保存到Android上的下載文件夾中
- 12. 如何將URL中的文件保存爲Objective-c中的本地文件
- 13. Cocoa Objective C - 如何將圖像數組轉換爲視頻文件並將其保存到磁盤?
- 14. 將desktopCapturer保存到Electron中的視頻文件中
- 15. 將記錄的視頻保存到文檔文件夾中
- 16. 如何使用c#將視頻保存到數據庫?
- 17. 將視頻文件加載到C++中的緩衝區中
- 18. 如何將下載的文件保存在緩存中android
- 19. 如何將保存的圖像下載到yii中的表格
- 20. 將視頻文件從獨立存儲保存到媒體庫
- 21. 使用Cordova插件在iOS圖庫中保存視頻文件
- 22. 在Objective-C(iPhone)中將字符串保存到文件中
- 23. 如何下載YouTube視頻iphone - 使用的Objective-C編程
- 24. 如何將下載的文件保存到android的內部存儲中?
- 25. Cordova將圖像下載保存到www文件夾中
- 26. 將視頻保存到視頻文件夾wp8
- 27. 如何將我的視頻保存到相冊中的特殊文件夾?
- 28. 如何將圖像添加到ios objective c中的uiactivityindicator視圖?
- 29. Swift保存下載的視頻NSURLSession
- 30. 如何將下載的文件保存到指定的路徑?
你可以張貼一些代碼,其中需要修復的..? – NREZ