wysaid / ios-gpuimage-plus

GPU accelerated image filters for iOS, based on OpenGL.
MIT License
249 stars 73 forks source link

Get Filter Video #23

Open AshishPatel48 opened 7 years ago

AshishPatel48 commented 7 years ago

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

wysaid commented 7 years ago

It's set by yourself.

AshishPatel48 commented 7 years ago

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 commented 7 years ago

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

wysaid commented 7 years ago

The source code is just there. Please track the code

Pemmasaniaruna commented 7 years ago

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

wysaid commented 7 years ago

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

AshishPatel48 commented 7 years ago

-(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];

}

AshishPatel48 commented 7 years ago

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

Pemmasaniaruna commented 7 years ago

_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 commented 7 years ago

hi @AshishPatel48 we are working on objective-c

wysaid commented 7 years ago

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

Pemmasaniaruna commented 7 years ago

@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

wysaid commented 7 years ago

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

Pemmasaniaruna commented 7 years ago

@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

wysaid commented 7 years ago

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

Pemmasaniaruna commented 7 years ago
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..

wysaid commented 7 years ago

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

Pemmasaniaruna commented 7 years ago

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

Pemmasaniaruna commented 7 years ago

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

am using pod like this

wysaid commented 7 years ago

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

Pemmasaniaruna commented 7 years ago

_videoFrameRecorder is getting nill in my case.

wysaid commented 7 years ago

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

Pemmasaniaruna commented 7 years ago

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.

wysaid commented 7 years ago

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

indulgeIn commented 6 years ago

demo is also not work

wysaid commented 6 years ago

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