Audio writing issues with GPUImageMovieWriter #934

Open
georgejecook opened this Issue Apr 20, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@georgejecook

Hi Brad,

I've got a video (which I have verified has valid audio) and was recorded directly from the camera on the device
I add a sepia effect and a movie writer.
When processing is finished, I write the movie to the library.

From all my experiments (>1 hour of changing things around) I have 2 results:
I can write the file to the library successfully if I do not set that my movieWriter has Audio and thus produce a file with no audio,
No matter what I try, I cannot get a valid video produced, which will copy to the library if I specify that i have audio. The resulting file is always zero kb.

I also find the completion block is always called twice.

All the code here is rough and messy; but I think it show's what's going on.

All of the paths are correct - All urls resolve to existing files.
The filters work.

I downloaded all app files using xcode's organizer. I can see that when I specify I have audio, that I get a zerokb file. the file is fine otherwise.

   [button touchUpInside:^(UIEvent *event) {
        self.didFinishEffect = NO;
        NSString *outputPath = [blockSelf tempFilePath];
        [blockSelf removeTempFile];

        NSString *path = [[PDCaptureManager shared] tempFilePath];
        BOOL exists = [[NSFileManager defaultManager]
                                      fileExistsAtPath:path];
        NSLog(@">>>performing effect on file :%@ - exists %d", path, exists);
        NSLog(@">>>Exists %d", exists);


        blockSelf.movie1 = [[GPUImageMovie alloc] initWithURL:[NSURL fileURLWithPath:path]];
        blockSelf.movie1.runBenchmark = YES;
        blockSelf.movie1.playAtActualSpeed = NO;
        blockSelf.testFilter = [[GPUImageSepiaFilter alloc] init];
        blockSelf.movieWriter = [[GPUImageMovieWriter alloc]

                                                      initWithMovieURL:
                                                              [NSURL fileURLWithPath:outputPath]
                                                                  size:
                                                                          CGSizeMake(640, 480)];
        [blockSelf.movie1 addTarget:blockSelf.testFilter];
        [blockSelf.testFilter addTarget:blockSelf.movieWriter];

        blockSelf.movieWriter.shouldPassthroughAudio = NO;
        [blockSelf.movieWriter setHasAudioTrack:YES audioSettings:nil];
        blockSelf.movieWriter.completionBlock = ^{
            if (blockSelf.didFinishEffect)
            {
                NSLog(@"already called for this video - ignoring");
            } else
            {
                blockSelf.didFinishEffect = YES;
                NSLog(@"GPU FILTER complete");
                [blockSelf writeMovieToLibraryWithPath:[NSURL fileURLWithPath: [self tempFilePath]]];
            }
        };

        blockSelf.movieWriter.failureBlock = ^(NSError *error) {
            NSLog(@"GPU FILTER failed %@", error);
        };
        [blockSelf.movieWriter startRecording];
        [blockSelf.movie1 startProcessing];
    }];
}

- (void)writeMovieToLibraryWithPath:(NSURL *)path
{
    NSLog(@"writing %@ to library", path);
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    [library writeVideoAtPathToSavedPhotosAlbum:path
                                completionBlock:^(NSURL *assetURL, NSError *error) {
                                    if (error)
                                    {
                                        NSLog(@"Error saving to library%@", [error localizedDescription]);
                                    } else
                                    {
                                        NSLog(@"SAVED %@ to photo lib",path);
                                    }
                                }];
}

@georgejecook

This comment has been minimized.

Show comment
Hide comment
@georgejecook

georgejecook Apr 20, 2013

Oh btw. All the frames get processed - I can see the "Current frame time" debugging statements for them all.

Oh btw. All the frames get processed - I can see the "Current frame time" debugging statements for them all.

@gerfarfel

This comment has been minimized.

Show comment
Hide comment
@gerfarfel

gerfarfel Apr 27, 2013

Have you made any headway on this issue? I think that I'm seeing the same issue. (#943, although I didn't express it as an audio problem.)

Have you made any headway on this issue? I think that I'm seeing the same issue. (#943, although I didn't express it as an audio problem.)

@georgejecook

This comment has been minimized.

Show comment
Hide comment
@georgejecook

georgejecook Apr 27, 2013

I gave up and wrote my own code. GPUImage is great but it has so many issues and the code is not very easy to read for openGL noobs like me.

I learned more by writing it myself - all roads lead to rome, and all of GPUImage is basically based on a few examples out there on the net anyhow..

good luck.

On 27 Apr 2013, at 17:20, Dick Fryling notifications@github.com wrote:

Have you made any headway on this issue? I think that I'm seeing the same issue. (#941, although I didn't express it as an audio problem.)


Reply to this email directly or view it on GitHub.

I gave up and wrote my own code. GPUImage is great but it has so many issues and the code is not very easy to read for openGL noobs like me.

I learned more by writing it myself - all roads lead to rome, and all of GPUImage is basically based on a few examples out there on the net anyhow..

good luck.

On 27 Apr 2013, at 17:20, Dick Fryling notifications@github.com wrote:

Have you made any headway on this issue? I think that I'm seeing the same issue. (#941, although I didn't express it as an audio problem.)


Reply to this email directly or view it on GitHub.

@tuo tuo referenced this issue Feb 5, 2015

Closed

Fix movie writer #1913

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment