When the composition is done, we create a video composition with the requested render size. Next we insert the time range to the composition. If there is a start or end time, we adjust our time range. We pick the asset and check it's length and build a source time range. tInstructions instructionsĮ = new AVAssetExportSessionMBS(m, AVAssetExportSessionMBS.AVAssetExportPresetAppleM4VAppleTV)ĭim filetypes() as string = e.supportedFileTypesĮ.OutputFile = (folder.name+ "."+e.outputFileExtension)Īs you see we start with reading our text file in the folder of movie files. add the transformer layer instructions, then add to video composition and use a transform to move pixels into visible area of render size above dim trans as CGAffineTransformMBS = CGAffineTransformMBS.MakeTranslation(-r.Origin.x, -r.Origin.y) here we define area of interest dim r as CGRectMBS = CGMakeRectMBS( 15, 450, 1440, 600) Instruction.timeRange = CMTimeRangeMBS.AllTimeRangeĭim transformers() as AVMutableVideoCompositionLayerInstructionMBSįor each videoTrack as AVAssetTrackMBS in mvideotracksĭim transformer as AVMutableVideoCompositionLayerInstructionMBS = CompositionLayerInstructionWithAssetTrack(videoTrack) Log "videotracks count: "+str(mvideotracks.Ubound+ 1)ĭim instruction as AVMutableVideoCompositionInstructionMBS = CompositionInstruction VideoComposition.renderSize = CGMakeSizeMBS( 1440, 600)ĭim Instructions() as AVMutableVideoCompositionInstructionMBSĭim mvideotracks() as AVAssetTrackMBS = m.tracksWithMediaType(AVFoundationMBS.AVMediaTypeVideo) Log "Total duration: "+str(m.duration.Seconds)+ " seconds" dim timeRange as CMTimeRangeMBS = CMTimeRangeMBS.Make(CMTimeMBS.kCMTimeZero, m.duration) If error nil then dim e as string = error.LocalizedDescription SourceTimeRange = CMTimeRangeMBS.Make(CMTimeMBS.kCMTimeZero, t)Įnd if end if call m.insertTimeRange(sourceTimeRange, asset, m.duration, error) SourceTimeRange = CMTimeRangeMBS.Make(t, len.Subtract(t))Įnd if end if if bisZeit "" then dim t as CMTimeMBS = ParseTime(bisZeit) If abZeit "" then dim t as CMTimeMBS = ParseTime(abZeit) dim f as FolderItem = folder.Child( "list.txt")ĭim tis as TextInputStream = TextInputStream.Open(f)ĭim tab as string = ( 9)ĭim m as AVMutableCompositionMBS = positionĭim line as string = tis.ReadLine(encodings.UTF8)ĭim name as string = NthField(line, tab, 1)ĭim abZeit as string = NthField(line, tab, 2)ĭim bisZeit as string = NthField(line, tab, 3)ĭim file as FolderItem = folder.Child(name)ĭim asset as AVAssetMBS = AVAssetMBS.assetWithFile(file)ĭim sourceTimeRange as CMTimeRangeMBS = CMTimeRangeMBS.Make(CMTimeMBS.kCMTimeZero, len) we read a list.txt in folder with file names and times // Name tab StartTime tab EndTime // we merge all videos by adding the video together // than we crop videos //Create AVMutableComposition Object which will hold our multiple AVMutableCompositionTrack or we can say it will hold our video and audio files. The sample project will be included with next plugins, but here is the main work method:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |