ios-gpuimage-plus icon indicating copy to clipboard operation
ios-gpuimage-plus copied to clipboard

Get Filter Video

Open AshishPatel48 opened this issue 8 years ago • 26 comments

Hi,

I am iOS developer, Can you please let me know how to get video after filtering, I didnt get filter video URL.

Thanks, Ashish

AshishPatel48 avatar Jul 21 '17 06:07 AshishPatel48

Hi I have create Function

-(void)filterVideoFileTestCase { if(_videoFrameRecorder != nil && [_videoFrameRecorder videoLoopRunning]) { [_videoFrameRecorder end]; [_videoFrameRecorder clear]; _videoFrameRecorder = nil; return; }

NSURL* video2Save = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/photoVideo.mp4"]];

NSDictionary* videoConfig = @{
                              //      @"sourceAsset" : (AVAsset*)sourceAsset     //input video Asset(Choose just one of "Asset" & "URL")
                              @"sourceURL" : _defaultVideoURL,                          //input video URL  (Choose just one of "Asset" & "URL")
                              @"filterConfig" : [NSString stringWithUTF8String:config],  //Filter String (optional)
                              @"filterIntensity" : @(0.9f),                //filter intensity (default 1.0, rane [0, 1])
                              @"blendImage" : imgVideo,       //blend image (optional)
                              @"blendMode" : @(CGE_BLEND_OVERLAY),         //blend mode (nonsense if there's no blend image), see: CGETextureBlendMode
                              @"blendIntensity" : @(0.8f)                  //blend intensity (default 1.0, range [0, 1])
                              };

_videoFrameRecorder = [CGEVideoFrameRecorder generateVideoWithFilter:video2Save size:CGSizeMake(0, 0) withDelegate:self videoConfig:videoConfig];

}

But Delegate method do not calling

-(void)videoReadingComplete:(CGEVideoFrameRecorder *)videoFrameRecorder{

AshishPatel48 avatar Jul 21 '17 07:07 AshishPatel48

Can u please let me know what is the issue..?

AshishPatel48 avatar Jul 21 '17 07:07 AshishPatel48

The source code is just there. Please track the code

wysaid avatar Jul 21 '17 07:07 wysaid

please let me know how to save the filtered video...?

Pemmasaniaruna avatar Aug 21 '17 14:08 Pemmasaniaruna

@Pemmasaniaruna the test case will show you: https://github.com/wysaid/ios-gpuimage-plus/blob/master/demo/cgeDemo/SimpleTestCasesViewController.m#L237

wysaid avatar Aug 22 '17 11:08 wysaid

  • (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL handler:(void (^)(AVAssetExportSession*))handler { [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil]; AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality]; exportSession.outputURL = outputURL; exportSession.outputFileType = AVFileTypeQuickTimeMovie; [exportSession exportAsynchronouslyWithCompletionHandler:^(void) { handler(exportSession); // [exportSession release]; }]; }

-(void)filterVideoFileTestCase { imgVideoGet = TRUE;

if(_videoFrameRecorder != nil && [_videoFrameRecorder videoLoopRunning])
{
    [_videoFrameRecorder end];
    [_videoFrameRecorder clear];
    _videoFrameRecorder = nil;
    return;
}

NSURL *url = _defaultVideoURL;//[[NSBundle mainBundle] URLForResource:@"test" withExtension:@"mp4"];
// NSURL *url =  _defaultVideoURL;
NSURL* video2Save = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/photoVideo.mp4"]];


NSDictionary* videoConfig = @{@"sourceURL" : url,
                              @"filterConfig" : [NSString stringWithUTF8String:config], @"filterIntensity" : @(0.9f),
                              @"blendMode" : @(CGE_BLEND_OVERLAY),
                              @"blendIntensity" : @(0.8f) };

_videoFrameRecorder = [CGEVideoFrameRecorder generateVideoWithFilter:video2Save size:CGSizeMake(0, 0) withDelegate:self videoConfig:videoConfig];

}

  • (void)filterButtonClicked: (MyButton*)sender { _currentFilterIndex = [sender index]; NSLog(@"Filter %d Clicked...\n", _currentFilterIndex);

    const char* config = g_effectConfig[_currentFilterIndex]; [_videoPlayerHandler setFilterWithConfig:config]; }

AshishPatel48 avatar Aug 23 '17 05:08 AshishPatel48

Hi @Pemmasaniaruna u can save like this way in iOS Swift 3

AshishPatel48 avatar Aug 23 '17 05:08 AshishPatel48

_videoFrameRecorder = [CGEVideoFrameRecorder generateVideoWithFilter:video2Save size:CGSizeMake(0, 0) withDelegate:self videoConfig:videoConfig];

after executing the above line of code next line is not executing ...please help me

Pemmasaniaruna avatar Aug 31 '17 13:08 Pemmasaniaruna

hi @AshishPatel48 we are working on objective-c

Pemmasaniaruna avatar Aug 31 '17 13:08 Pemmasaniaruna

@Pemmasaniaruna Have you tried the test case in the demo?

wysaid avatar Sep 01 '17 01:09 wysaid

@wysaid yes i tried if i use the code in my project everything is working fine but after "_videoFrameRecorder = [CGEVideoFrameRecorder generateVideoWithFilter:video2Save size:CGSizeMake(0, 0) withDelegate:self videoConfig:videoConfig];" this line nothing is happening and also i cant able to debung

Pemmasaniaruna avatar Sep 01 '17 06:09 Pemmasaniaruna

The instance variable _videoFrameRecorder must be retained or kept by other variables, or it may be dealloced because of the ARC.

wysaid avatar Sep 01 '17 06:09 wysaid

@wysaid in demo " The video preferred rotation: 0" but in my project " The video preferred rotation: 1.5708" i find this issue after this line no line is executing.please help me

Pemmasaniaruna avatar Sep 01 '17 07:09 Pemmasaniaruna

Both rotation are supported. It's not the problem.

wysaid avatar Sep 01 '17 07:09 wysaid

NSURL *url = _videoUrl;
NSURL* video2Save = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/photoVideo.mp4"]];

NSDictionary* videoConfig = @{
                              //      @"sourceAsset" : (AVAsset*)sourceAsset     //input video Asset(Choose just one of "Asset" & "URL")
                              @"sourceURL" : url,                          //input video URL  (Choose just one of "Asset" & "URL")
                              @"filterConfig" : [NSString stringWithUTF8String:g_effectConfig[_currentFilterIndex]],  //Filter String (optional)
                              @"filterIntensity" : @(0.9f),                //filter intensity (default 1.0, rane [0, 1])
                              @"blendImage" : [UIImage imageNamed:@"mask1.png"],       //blend image (optional)
                             @"blendMode" : @(CGE_BLEND_OVERLAY),         //blend mode (nonsense if there's no blend image), see: CGETextureBlendMode
                              @"blendIntensity" : @(0.8f)                  //blend intensity (default 1.0, range [0, 1])
                              };

_videoFrameRecorder = [CGEVideoFrameRecorder generateVideoWithFilter:video2Save size:CGSizeMake(0, 0) withDelegate:self videoConfig:videoConfig];

above line of code am executing..

Pemmasaniaruna avatar Sep 01 '17 07:09 Pemmasaniaruna

So what is the difference between your code and the origin demo?

wysaid avatar Sep 01 '17 07:09 wysaid

nothing ,,but still am unable to save the filterd video

Pemmasaniaruna avatar Sep 01 '17 07:09 Pemmasaniaruna

pod 'libCGE', :git => 'https://github.com/wysaid/ios-gpuimage-plus-pod.git'

am using pod like this

Pemmasaniaruna avatar Sep 01 '17 07:09 Pemmasaniaruna

cgeTest.zip Check this, and see what's wrong with you.

wysaid avatar Sep 01 '17 08:09 wysaid

_videoFrameRecorder is getting nill in my case.

Pemmasaniaruna avatar Sep 01 '17 09:09 Pemmasaniaruna

@Pemmasaniaruna Can you run the demo above? Is it getting nil on your device?

wysaid avatar Sep 01 '17 10:09 wysaid

problem is in my project not in demo ....but photo thing is working fine only for filterd video saving giving issue after that line of code whole application is going to stuck.

Pemmasaniaruna avatar Sep 01 '17 10:09 Pemmasaniaruna

If so…… I can't find your problem now……

wysaid avatar Sep 01 '17 10:09 wysaid

demo is also not work

indulgeIn avatar Nov 18 '17 09:11 indulgeIn

@indulgeIn The demo is right on my device. You can provide your device type.

wysaid avatar Nov 20 '17 02:11 wysaid