获取 ogg theora 视频的长度

发布于 2024-09-13 20:57:43 字数 193 浏览 1 评论 0原文

我目前正在使用 libtheoradec,但我找不到一种简单的方法来找出 ogg theora 文件的播放时间。 libtheoradec 发行版中有几个示例,但没有一个示例显示如何获取 theora 流的长度(即以秒左右为单位的播放时间)。此信息在标题等位置不可用吗?我真的必须阅读所有页面并从最后一个数据包的颗粒位置中获取长度吗?这真的是唯一的方法吗? 感谢您的帮助!

I'm currently playing around with libtheoradec but I cannot find an easy way of finding out the playing time of an ogg theora file. There are several examples in the libtheoradec distribution but none of them shows how to get the length (i.e. playing time in seconds or so) of a theora stream. Is this information not available somewhere in the header or so? Do I really have to read through all pages and obtain the length from the granule pos of the last packet? Is this really the only way?
Thanks for help!

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

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

发布评论

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

评论(2

梦里南柯 2024-09-20 20:57:43

是的,该信息不在 Theora 标头中,您需要从最后一个数据包的 capsulepos 中获取信息。

我在 liboggz 的 Chop-Rewrite 分支中有一些代码用于此目的。函数 oggz_get_duration() 返回一个以秒为单位的值,并被 oggz-chop 用于提供 Content-Duration HTTP 响应标头:
https://github.com/kfish/liboggz/blob /chop-rewrite/src/libogz/oggz_seek.c

Yes the information is not in the Theora header, and you need to get the information from the granulepos of the last packet.

I have some code in the chop-rewrite branch of liboggz for this. The function oggz_get_duration() returns a value in seconds, and is used by oggz-chop to provide a Content-Duration HTTP response header:
https://github.com/kfish/liboggz/blob/chop-rewrite/src/liboggz/oggz_seek.c

汐鸠 2024-09-20 20:57:43

很抱歉,在问我的问题之前我没有看到您的问题: 有没有办法在 .ogg 视频完全加载之前知道其文件大小?

我很惊讶没有人回答之前,这似乎是一个很好的问题,因为由于 HTML5,ogg 视频得到了更多的使用。

I'm sorry I didn't see your question before asking mine: Is there a way to tell the file size of an .ogg video before it is fully loaded?

I'm surprised no one answered before, as this would seem to be a good question as ogg video sees more use thanks to HTML5.

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