0
A
回答
0
尼斯Question.The的解决方案是在这里...在viewDidLoad方法
-(void)splitSecondVideo
{
if (did<splitdivide){
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:_videourl options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *myPathDocs;
CMTime starttime;
CMTime duration;
myPathDocs = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"SplitFinalVideo%d.mov",did]];
double endt=CMTimeGetSeconds([asset duration]);
NSLog(@"All Duration : %f",endt);
double divide=CMTimeGetSeconds([asset duration])/splitdivide;
NSLog(@"All Duration : %f",divide);
starttime = CMTimeMakeWithSeconds(divide*did, 1);
duration = CMTimeMakeWithSeconds(divide, 1);
NSFileManager *fileManager=[[NSFileManager alloc]init];
NSError *error;
if ([fileManager fileExistsAtPath:myPathDocs] == YES) {
[fileManager removeItemAtPath:myPathDocs error:&error];
}
exportSession.outputURL = [NSURL fileURLWithPath:myPathDocs];
exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
// Trim to half duration
CMTimeRange secondrange = CMTimeRangeMake(starttime, duration);
exportSession.timeRange = secondrange;
[exportSession exportAsynchronouslyWithCompletionHandler:^(void)
{
[self exportDidFinish:exportSession];
did++;
[self splitSecondVideo];
}];
}}
- (void)exportDidFinish:(AVAssetExportSession*)session {
if (session.status == AVAssetExportSessionStatusCompleted) {
NSURL *outputURL = session.outputURL;
NSLog(@"Before Exported");
[self SaveVideoAtPathWithURL:outputURL];
}}
其中做= 0.0。 & splitdivide是您想要创建视频部分的值。在您的问题splitdivide = 5; 注意:确实&拆分均为整数值。
希望这是有帮助的....享受...
相关问题
- 1. 用gstreamer分割/分割视频流
- 2. as3中的视频分割
- 3. 分割视频转换成在Java
- 4. VB.NET - 分割成多个分割号码
- 5. 在C中分割四个文件中的视频#
- 6. 跨多个N/W接口分割视频流
- 7. 视频在多个小区
- 8. 打开cv C++:如何分割视频几个部分?
- 9. 在iPad中分割视图
- 10. 视频预览图层在分割视图中运行吗?
- 11. 视频文件即时分割
- 12. 将视频分割成帧/图像
- 13. FFmpeg:如何高效地分割视频?
- 14. 分割视频并保持运行
- 15. 将视频分割成小块
- 16. 如何分割YouTube视频ID?
- 17. FFmpeg视频分割时的帧丢失
- 18. Android:拍摄期间的分割视频
- 19. 用ffmpeg解析分割视频
- 20. 如何分割OGX(视频)文件?
- 21. 将表中的多个分区分区
- 22. 如何在单个流中合并多个实时(视频)流?所以输出将是单个视频中的多个(分割)视频?
- 23. hadoop中的文件分割/分区
- 24. 在matplotlib中分割多个饼馅饼
- 25. 分割我的代码分割成多个文件在Python 3
- 26. webrtc onaddstream事件处理程序 - 区分多个视频流
- 27. 从多个视频部分创建单个视频文件
- 28. ffmpeg创建多个输出视频,在GT上分割(场景,x)
- 29. 将色环分割为多个部分
- 30. 将双分割成多个部分
可能[this] [1]帮助你分割视频在多个部分。 [1]:http://stackoverflow.com/questions/13987357/split-a-movie-into-two-parts-an-then-concatenate-one-of-the-movie-with-另一个-m的 – Raj