texture | 纹理,包含要写入当前帧的轨道的像素。 |
time | 新帧的时间戳。 |
bool 如果操作成功,则为 true。否则为 False。
将帧附加到文件的视频轨道。
使视频帧和音频样本的数量保持一致,以便尽可能地同步每个轨道。例如,在具有 30FPS 视频和 48KHz 音频的文件中,每个添加的视频帧后均应跟 1600 个样本帧的音频缓冲区。
**有关时间戳的注释**
添加帧时,可选择指定与此帧关联的时间戳。对于要使用的时间戳,它必须有效(请参阅 MediaTime.IsValid)。
如果未提供时间戳,则使用指定的视频帧率(请参阅 VideoTrackAttributes.frameRate)附加此帧,以计算帧间时间差。在以下情况下必须指定时间戳:
**1.** 在无有效速率的情况下创建视频轨道时(请参阅 VideoTrackAttributes.frameRate。在这种情况下,必须为添加的**所有**帧均提供时间戳,因为没有预定义的帧间时间差。
**2.** 当最后一帧与附加帧之间的时间差不符合预期时。例如,当在 Unity 中进行录制并且游戏循环持续时间超出预期时,帧间时间差将不再恒定。在这种情况下,必须指定与附加帧关联的时间戳。这样,当播放录制的电影时,它将匹配录制过程中所看到的内容。然后最终影片将具有**可变帧率** (VFR),因为每个帧之间没有完全相同的时间差。
对于具有预定义速率的轨道,只要这些时间值最终单调递增,混合两种变体(带有时间戳和不带时间戳)就是有效的。以这种方式添加的帧不必具有相等的时间间隔。如果所添加帧的时间戳早于最后一帧的时间戳,这是无效的。
width | 图像宽度。 |
height | 图像高度。 |
rowBytes | 一行像素中的字节。在行包含填充的情况下非常有用。如果没有填充,可设置为 0。 |
format | 像素格式。此时仅支持 TextureFormat.RGBA32。 |
data | 包含图像的字节。 |
time | 新帧的时间戳。 |
bool 如果操作成功,则为 true。否则为 False。
将帧从原始缓冲区附加到文件的视频轨道。
如果源数据不在 Texture2D 中,则此版本的 AddFrame 有助于减少图像复制。例如,当像素数据来自 AsyncGPUReadbackRequest 时。有关更多详细信息,请参阅有关采用 Texture2D 的 MediaEncoder.AddFrame 的变体中音频/视频对齐的注释。
有关 time
参数的更多信息,请参阅此方法其他重载中的**时间戳注释**。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.