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

GPUImageMovieWriter can't export audiomix audio tracks issue #1834

zxcv740 opened this Issue Nov 13, 2014 · 1 comment


None yet
2 participants

zxcv740 commented Nov 13, 2014

i use GPUImageMovieWriter output video with one audio track is ok ,then i try with two audio tracks export video is not ok。

_movieFile = [[GPUImageMovie alloc] initWithComposition:_editor.composition andVideoComposition:_editor.videoComposition andAudioMix:_editor.audioMix];

  • (AVAssetReader*)createAssetReader_mix
    // NSLog(@"creating reader from composition: %@, video: %@, audio: %@ with duration: %@", _compositon, _videoComposition, _audioMix, CFBridgingRelease(CMTimeCopyDescription(kCFAllocatorDefault, _compositon.duration)));

    NSError *error = nil;
    AVAssetReader *assetReader = [AVAssetReader assetReaderWithAsset:self.compositon error:&error];
    NSMutableDictionary *outputSettings = [NSMutableDictionary dictionary];
    if ([GPUImageContext supportsFastTextureUpload]) {
    [outputSettings setObject:@(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) forKey:(id)kCVPixelBufferPixelFormatTypeKey];
    isFullYUVRange = YES;
    else {
    [outputSettings setObject:@(kCVPixelFormatType_32BGRA) forKey:(id)kCVPixelBufferPixelFormatTypeKey];
    isFullYUVRange = NO;

    AVAssetReaderVideoCompositionOutput *readerVideoOutput = [AVAssetReaderVideoCompositionOutput assetReaderVideoCompositionOutputWithVideoTracks:[_compositon tracksWithMediaType:AVMediaTypeVideo]


    if( [_videoComposition isKindOfClass:[AVMutableVideoComposition class]] )
    [(AVMutableVideoComposition*)_videoComposition setRenderScale:1.0];


    readerVideoOutput.videoComposition = _videoComposition;
    readerVideoOutput.alwaysCopiesSampleData = YES;
    [assetReader addOutput:readerVideoOutput];

    NSArray *audioTracks = [_compositon tracksWithMediaType:AVMediaTypeAudio];
    BOOL shouldRecordAudioTrack = (([audioTracks count] > 0) && (self.audioEncodingTarget != nil) );
    AVAssetReaderAudioMixOutput *readerAudioOutput = nil;

    if (shouldRecordAudioTrack)
    [self.audioEncodingTarget setShouldInvalidateAudioSampleWhenDone:YES];

    readerAudioOutput = [AVAssetReaderAudioMixOutput assetReaderAudioMixOutputWithAudioTracks:audioTracks audioSettings:nil];
    readerAudioOutput.audioMix = self.audioMix;
    readerAudioOutput.alwaysCopiesSampleData = YES;
    [assetReader addOutput:readerAudioOutput];


    return assetReader;

add this but GPUImageMovieWriter always can't write ,and self.assetWriter.status is AVAssetWriterStatusFailed .


This comment has been minimized.

Show comment
Hide comment

tuo Jan 10, 2015

Hi @zxcv740 ,
this pull request should slove your problem: #1887

tuo commented Jan 10, 2015

Hi @zxcv740 ,
this pull request should slove your problem: #1887

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