开发者

Audio out of sync with video in rendered AVMutableComposition

I have an AVMutableComposition with the following track segments:

video:
    empty: Y, {{0/1 = 0.000}, {48/100 = 0.480}}
    empty: N, {{48/100 = 0.480}, {600/600 = 1.000}}
    empty: Y, {{888/600 = 1.480}, {900/600 = 1.500}}
    empty: N, {{894/300 = 2.980}, {1040/600 = 1.733}}
audio:
    empty: Y, {{0/1 = 0.000}, {48/100 = 0.480}}
    empty: N, {{48/100 = 0.480}, {45056/44100 = 1.022}}
    empty: Y, {{66224/44100 = 1.502}, {65194/44100 = 1.478}}
    empty: N, {{894/300 = 2.980}, {77824/44100 = 1.765}}

The timing is expressed as CMTimeRange, the first CMTime is the start time, the second one is duration. In other words, there are two audio+video chunks with some empty padding space before and between them.

The problem is that when I export this composition and play back the exported video, the second audio segment plays too early, as if the second empty padding audio segment was ignored during the export. I get the first vide开发者_如何转开发o segment with correct audio, then immediately the second audio segment and then later the second video segment without audio.

What could be wrong?


The problem was in the export. I was using the pass-through export mode that merely copies the track segments into the resulting file. I guess the time stamps are simply copied, too, which causes a mess in the timeline of the exported movie. Setting the export mode to something else than the pass-through solves the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜