渲染的 AVMutableComposition 中的音频与视频不同步

发布于 2024-10-07 21:45:03 字数 768 浏览 3 评论 0原文

我有一个带有以下轨道段的 AVMutableComposition

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}}

计时表示为 CMTimeRange,第一个 CMTime 是开始时间,第二个是期间。换句话说,有两个音频+视频块,它们之前和之间有一些空白的填充空间。

问题是,当我导出此合成并播放导出的视频时,第二个音频片段播放得太早,就好像第二个空填充音频片段在导出过程中被忽略一样。我得到带有正确音频的第一个视频片段,然后立即得到第二个音频片段,然后得到没有音频的第二个视频片段。

可能出什么问题了?

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 video segment with correct audio, then immediately the second audio segment and then later the second video segment without audio.

What could be wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软糯酥胸 2024-10-14 21:45:03

问题出在出口上。我使用的是直通导出模式,仅将轨道段复制到结果文件中。我猜时间戳也被简单地复制了,这会导致导出的电影的时间线混乱。将导出模式设置为直通以外的模式可以解决该问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文