Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create with mp4+mp4+uielement #2409

Open
akerdi opened this issue Dec 27, 2016 · 0 comments
Open

create with mp4+mp4+uielement #2409

akerdi opened this issue Dec 27, 2016 · 0 comments

Comments

@akerdi
Copy link

akerdi commented Dec 27, 2016

I need to create with
mp4-》filter↘️
mp4 —》alphaBlend ↘️
GPUImageUIElement -》alphaBlend -》GPUImageView
a thought from this one trace
`
self.movieFile = [[THImageMovie alloc]initWithURL:self.movieFileURL];//PlayerItem:playItem];
self.movieFile.runBenchmark = YES;
self.movieFile.playAtActualSpeed = YES;
self.filter = [[GPUImageToonFilter alloc] init];

            GPUImageAlphaBlendFilter *alphaBlendFilter = [[GPUImageAlphaBlendFilter alloc]init];
            [alphaBlendFilter setMix:0.5];
            
            self.secondMovie = [[THImageMovie alloc]initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Yh1" ofType:@"mp4"]]];
            self.secondMovie.runBenchmark = YES;
            self.secondMovie.playAtActualSpeed = YES;
            
            UIView *contentView = [self uielementView];
            self.uiElementInput = [[GPUImageUIElement alloc]initWithView:contentView];
            //输入
            [self.movieFile addTarget:self.filter];
            @weakify(self);
            
            //输过程
            [self.filter addTarget:alphaBlendFilter];
            //                [self.uiElementInput addTarget:alphaBlendFilter];
            [self.secondMovie addTarget:alphaBlendFilter];
            
            GPUImageTwoInputFilter *twoInputFilter = [[GPUImageTwoInputFilter alloc]init];
            [self.uiElementInput addTarget:twoInputFilter];
            [alphaBlendFilter addTarget:twoInputFilter];
            
            [self.filter setFrameProcessingCompletionBlock:^(GPUImageOutput *output, CMTime frameTime) {
                LxDBAnyVar(frameTime);
            }];
            
            NSArray *thMovies = @[self.movieFile,self.secondMovie];
            // In addition to displaying to the screen, write out a processed version of the movie to disk
            NSString *pathToMovie = [self movieSavedPath];
            unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
            NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
            LxDBAnyVar(self.mutableVideoComposition.renderSize);
            self.movieWriter = [[THImageMovieWriter alloc] initWithMovieURL:movieURL size:self.mutableVideoComposition.renderSize movies:thMovies];
            
            GPUImageView *filterView = self.movieImageView;
            [twoInputFilter addTarget:filterView];
            [twoInputFilter addTarget:self.movieWriter];
            
            // Configure this for video from the movie file, where we want to preserve all video frames and audio samples
            //渲染
            [self.movieFile startProcessing];
            [self.secondMovie startProcessing];
            [self.movieWriter startRecording];
            
            [self.movieWriter setCompletionBlock:^{
                @strongify(self);
                LxDBAnyVar(@"record complete");
                [self.filter removeTarget:self.movieWriter];
                [self.movieFile endProcessing];
                [self.secondMovie endProcessing];
                [self.movieWriter finishRecording];
                
                [movieURL saveToCameraRollWithCompletion:^(NSString * _Nullable path, NSError * _Nullable error) {
                    LxDBAnyVar(@"save complete");
                    LxDBAnyVar(error);
                }];
                [subscriber sendNext:nil];
                [subscriber sendCompleted];
            }];`

but it can't work out.
I've try mp4+mp4 ,it works well,and mp4+ uielement too.
can someone help with this,vary vary thanks.
By the way ,the THImageMovie is a class that subclass GPUImageMovie which help with write the audioTrack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant