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