C#中有没有办法仅获取MP4文件的标头来读取它的元数据,而无需下载整个文件?

发布于 2025-02-06 16:02:31 字数 407 浏览 4 评论 0原文

我在服务器上托管了一个我不知道的元数据的MP4文件 - 我只知道容器格式(MP4)。我需要知道音频/视频比特率信息,二手编解码器(即H.264)和音频比特率。该视频也可能缺少音频流,在这种情况下,其中一些信息将无法使用。

有没有一种方法可以使httpclient同时读取并解析文件,以及当它完全读取标题时,请脱离连接?该文件可能很大(〜300MB),如果我唯一需要的信息是一开始,我就不想全部阅读它。

我已经想过要阅读getStreamAsync返回的流,并在收集足够的信息时调用Distose,但是有一个,但是是否有一个这个的库?我看了MP4的标题规范,这似乎相对复杂。如果有能力这样做的库,我不想重新发明轮子。

I have an MP4 file hosted on a server that I don't know the metadata of - I only know the container format (MP4). I need to know the audio/video bitrate information, the used codec (i.e. H.264), and the audio bitrate. The video can also lack an audio stream, and in that case, some of that information would be unavailable.

Is there a way to make a, say, HttpClient read and parse the file from the server at the same time, and when it fully reads the header, disconnect? The file may be large (~300mb), and I don't want to read it in its entirety if the only information I need is a couple bytes from the beginning.

I've thought of reading the stream returned by GetStreamAsync and building header information as we go, and then calling Dispose when enough information is gathered, but is there a library for this? I've looked at MP4's header specification, and it seems relatively complex. I don't want to reinvent the wheel, if a library that is capable of doing this.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文