How to use AVAssetReader and AVAssetWriter for multiple tracks (audio and video) simultaneously?

后端 未结 3 574
名媛妹妹
名媛妹妹 2021-02-01 09:28

I know how to use AVAssetReader and AVAssetWriter, and have successfully used them to grab a video track from one movie and transcode it into another.

3条回答
  •  半阙折子戏
    2021-02-01 10:01

    Have you tried using two AVAssetWriterInputs and pushing the samples through a worker queue? Here is a rough sketch.

    processing_queue = dispatch_queue_create("com.mydomain.gcdqueue.mediaprocessor", NULL);
    
    [videoAVAssetWriterInput requestMediaDataWhenReadyOnQueue:myInputSerialQueue usingBlock:^{
        dispatch_asyc(processing_queue, ^{process video});
    }];
    
    [audioAVAssetWriterInput requestMediaDataWhenReadyOnQueue:myInputSerialQueue usingBlock:^{
        dispatch_asyc(processing_queue, ^{process audio});
    }];
    

提交回复
热议问题