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

Get Filter Video #23

Open
AshishPatel48 opened this issue Jul 21, 2017 · 26 comments
Open

Get Filter Video #23

AshishPatel48 opened this issue Jul 21, 2017 · 26 comments

Comments

@AshishPatel48
Copy link

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
Copy link
Owner

wysaid commented Jul 21, 2017

It's set by yourself.

@AshishPatel48
Copy link
Author

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
Copy link
Author

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

@wysaid
Copy link
Owner

wysaid commented Jul 21, 2017

The source code is just there. Please track the code

@Pemmasaniaruna
Copy link

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

@wysaid
Copy link
Owner

wysaid commented Aug 22, 2017

@AshishPatel48
Copy link
Author

  • (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
Copy link
Author

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

@Pemmasaniaruna
Copy link

_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
Copy link

hi @AshishPatel48 we are working on objective-c

@wysaid
Copy link
Owner

wysaid commented Sep 1, 2017

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

@Pemmasaniaruna
Copy link

@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
Copy link
Owner

wysaid commented Sep 1, 2017

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

@Pemmasaniaruna
Copy link

@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
Copy link
Owner

wysaid commented Sep 1, 2017

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

@Pemmasaniaruna
Copy link

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
Copy link
Owner

wysaid commented Sep 1, 2017

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

@Pemmasaniaruna
Copy link

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

@Pemmasaniaruna
Copy link

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

am using pod like this

@wysaid
Copy link
Owner

wysaid commented Sep 1, 2017

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

@Pemmasaniaruna
Copy link

_videoFrameRecorder is getting nill in my case.

@wysaid
Copy link
Owner

wysaid commented Sep 1, 2017

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

@Pemmasaniaruna
Copy link

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
Copy link
Owner

wysaid commented Sep 1, 2017

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

@indulgeIn
Copy link

demo is also not work

@wysaid
Copy link
Owner

wysaid commented Nov 20, 2017

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

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

4 participants