MOV to Mp4 video conversion iPhone programmatically

后端 未结 7 1602
南方客
南方客 2020-12-01 01:11

I am developing media server for Play station 3 in iPhone.

I came to know that PS3 doesn\'t support .MOV file so I have to convert it into Mp4 or something other tra

7条回答
  •  萌比男神i
    2020-12-01 01:29

    You can convert video in mp4 by AVAssets.

    AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:videoURL options:nil];
    NSArray *compatiblePresets = [AVAssetExportSession     
    exportPresetsCompatibleWithAsset:avAsset];
    AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:avAsset presetName:AVAssetExportPresetLowQuality];
    
    NSString* documentsDirectory=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
      exportSession.outputURL = url;
     //set the output file format if you want to make it in other file format (ex .3gp)
     exportSession.outputFileType = AVFileTypeMPEG4;
     exportSession.shouldOptimizeForNetworkUse = YES;
    
     [exportSession exportAsynchronouslyWithCompletionHandler:^{
     switch ([exportSession status])
     {
          case AVAssetExportSessionStatusFailed:
               NSLog(@"Export session failed");
               break;
          case AVAssetExportSessionStatusCancelled:
               NSLog(@"Export canceled");
               break;
          case AVAssetExportSessionStatusCompleted:
          {
               //Video conversion finished
               NSLog(@"Successful!");
          }
               break;
          default:
               break;
      }
     }];
    

    To easily convert video to mp4 use this link.

    You can also find sample project to convert video to mp4.

提交回复
热议问题