ios - 将 .MOV 转换为 .MP4,同时从图库中选择或从相机录制
<p><p>当我从图库中选择一个视频时,我选择的文件扩展名为 .MOV,因此想将其转换为 .MP4 进行研究,但在这种情况下不知道如何做到这一点。如果你有任何想法,请帮忙。</p>
<pre><code> - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
selectedVideoURL = info;
if( == UIImagePickerControllerSourceTypeCamera )
{
NSURL *videoURL=info;
ALAssetsLibrary *library = [init];
[library writeVideoAtPathToSavedPhotosAlbum:videoURL completionBlock:^(NSURL *assetURL, NSError *error )
{
//here is your URL : assetURL
NSLog(@"url is%@",assetURL);
// here in debugger it shows asassets.MOVi want .MP4
PHFetchResult<PHAsset*> *assets =
options:nil];
PHAsset *asset1 = assets.firstObject;
[ requestAVAssetForVideo:asset1 options:nil resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
if (]) {
AVURLAsset* urlAsset = (AVURLAsset*)asset;
NSNumber *size;
;
NSLog(@"size video of camera %f",/(1024.0*1024.0)); //size is 43.703005
NSData *data = ;
NSLog(@"length of camera %f",/(1024.0*1024.0)); // data size is 43.703005
sizeofVideo=/(1024.0*1024.0);
NSLog(@"sizeofVideo arvin %f",sizeofVideo);
if (!sizeofVideo>50.00) {
selectedVideoURL=nil;
UIAlertView *alert=[initWithTitle:@"Alert" message:@"size of video exist 50MB" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
;
attachnoteLbl.text=;
}
attachnoteLbl.text=;
}
}];
}];
}
</code></pre>
<p>我尝试了以下方法,将文件扩展名从 .MOV 删除为 .MP4,但没有成功。所以我认为只有在从图库或相机中选择时才需要在乞求中转换它。</p>
<pre><code>-(void)afnetworking{
NSString *videoUrl=;
if(videoUrl){
NSString *videoName = [stringByDeletingPathExtension];
NSData *videoData= ;
dataUsingEncoding:NSUTF8StringEncoding]];
NSString *tmpfileinfo = ;
];
];
];
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>查看这个库。希望这可以解决您的问题。 <a href="https://github.com/Darktt/DTVideoConverter" rel="noreferrer noopener nofollow">https://github.com/Darktt/DTVideoConverter</a> </p></p>
<p style="font-size: 20px;">关于ios - 将 .MOV 转换为 .MP4,同时从图库中选择或从相机录制,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/37832277/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/37832277/
</a>
</p>
页:
[1]