如何保存在相机胶卷中创建的幻灯片?
(NSString *))handler;
{
AVMutableComposition* mixComposition = [AVMutableComposition composition];
AVURLAsset* videoAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:videoPath] options:nil];
NSError * error = nil;
for (int i=0;i<[arrayOfSounds count];i++)
{
NSString *pathString = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@", [arrayOfSounds objectAtIndex:i]] ofType:@"mp3"];
NSLog(@"pathString = %@",pathString);
AVURLAsset * urlAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:pathString] options:nil];
AVAssetTrack * audioAssetTrack = [[urlAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
AVMutableCompositionTrack *compositionAudioTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio
preferredTrackID: kCMPersistentTrackID_Invalid];
CMTime audioDuration = videoAsset.duration;
audioDurationSeconds = CMTimeGetSeconds(audioDuration);
int startDur= [[arrayOfTime objectAtIndex:i] intValue];
NSLog(@"startDur = %d",startDur);
CMTime audioStartTime = CMTimeMake(i,1);
CMTime presentTime = CMTimeMake(1, 1);
CMTime EndTime = CMTimeMake(audioDurationSeconds, 1);
CMTime audioEndTime = CMTimeAdd(presentTime, EndTime);
[compositionAudioTrack insertTimeRange:CMTimeRangeMake(presentTime,audioEndTime) ofTrack:audioAssetTrack atTime:audioStartTime error:&error];
}
NSString* movPath = [NSString stringWithFormat:@"%@/%@",documentsDirectory,@"Export.mov"];
//AVURLAsset* videoAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:movPath] options:nil];
AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
NSError* vidError;
[compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:([videoAsset tracksWithMediaType:AVMediaTypeVideo].count >0)? [[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]:nil atTime:kCMTimeZero error:&vidError];
NSLog(@"Vid error = %@",vidError);
AVAssetExportSession* _assetExport = [[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPresetPassthrough];
NSString* videoName = @"exportFinal.mov";
NSString *exportPath = [NSString stringWithFormat:@"%@/%@",documentsDirectory,videoName];
NSLog(@"exportPath = %@",exportPath);
NSURL *exportUrl = [NSURL fileURLWithPath:exportPath];
if ([[NSFileManager defaultManager] fileExistsAtPath:exportPath])
{
[[NSFileManager defaultManager] removeItemAtPath:exportPath error:nil];
}
_assetExport.outputFileType = @"com.apple.quicktime-movie";
NSLog(@"file type %@",_assetExport.outputFileType);
_assetExport.outputURL = exportUrl;
_assetExport.shouldOptimizeForNetworkUse = YES;
[_assetExport exportAsynchronouslyWithCompletionHandler:
^(void ) {
switch (_assetExport.status)
{
case AVAssetExportSessionStatusCompleted:
//export complete
NSLog(@"Export Complete");
//[self uploadToYouTube];
[self cleanUpProcess];
break;
case AVAssetExportSessionStatusFailed:
NSLog(@"Export Failed");
NSLog(@"ExportSessionError: %@", [_assetExport.error localizedDescription]);
//export error (see exportSession.error)
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export Failed");
NSLog(@"ExportSessionError: %@", [_assetExport.error localizedDescription]);
//export cancelled
break;
}
}];
}
- (void)cleanUpProcess{
NSError* error;
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:&error];
for(NSString* myFiles in files){
if([[myFiles pathExtension] isEqualToString:@"mov"]){
continue;
}
NSString* filePath = [NSString stringWithFormat:@"%@/%@",documentsDirectory,myFiles];
if(![[NSFileManager defaultManager] removeItemAtPath:filePath error:&error]){
NSLog(@"Error Deleting");
}
}
}
它保存在此路径中:
&#34;用户/ devendrasingh /库/开发商/ CoreSimulator /设备/ 394AD1C9-E950-422E-BDA1-083CDCEE83F6 /数据/容器/数据/应用/ 98BEC162-C686-4BC1-B698-567B45D65F27 /文档/ exportFinal .MOV &#34;
没有保存在相机胶卷中
答案 0 :(得分:1)
试试这个:
#include<stdio.h>
#include<string.h>
int main(){
int i,j,diff=0,min=0;
char arr[100],var;
printf("Enter the string to check for: ");
scanf("%s",&arr);
for(i=0;i<strlen(arr);i++){
arr[i]=toupper(arr[i]);
printf("%c ",arr[i]);
}
printf("\n");
for(i=0;i<strlen(arr);i++){
for(j=i+1;j<strlen(arr);j++){
if(arr[i]==arr[j]){
diff=j-i;
//THIS IF BLOCK IS USED FOR FIRST CONDITION FAILURE OF MIN AND DIFFERENCE
if(diff > min){
min=diff;
var=arr[i];
}
//THIS ELSE BLOCK IS USED FOR REGULAR CHECK FOR THE MIN AND DIFF AND ADJUST MIN TO DIFF ACCORDINGLY
else if(diff < min){
min=diff;
var=arr[i];
}
}
}
}
printf("Final Answer : %c\n",var);
return 0;
}